Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for compactTertiary variant #961

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-feet-confess.md
@@ -0,0 +1,5 @@
---
'@hashicorp/react-call-to-action': minor
---

Add support for compactTertiary variant
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions packages/call-to-action/index.tsx
Expand Up @@ -5,6 +5,7 @@

import type { ReactNode } from 'react'
import Button from '@hashicorp/react-button'
import type { ThemeVariant } from '@hashicorp/react-button/types'
import type { Products } from '@hashicorp/platform-product-meta'
import classNames from 'classnames'
import variantCentered from './styles/variant-centered.module.css'
Expand All @@ -15,6 +16,7 @@ import variantLinks from './styles/variant-links.module.css'
const stylesDict = {
centered: variantCentered,
compact: variantCompact,
compactTertiary: variantCompact,
compactGrid: variantCompactGrid,
links: variantLinks,
}
Expand All @@ -27,7 +29,7 @@ interface CallToActionProps {
text: string
url: string
}[]
variant?: 'centered' | 'compact' | 'compactGrid' | 'links'
variant?: keyof typeof stylesDict
product?: Products
theme?: 'light' | 'gray' | 'dark' | 'brand'
className?: string
Expand Down Expand Up @@ -72,12 +74,13 @@ function CallToAction({
{links && (
<div className={s.links} data-testid="links">
{links.map((link, stableIdx) => {
const buttonVariant =
variant === 'links'
? 'tertiary-neutral'
: stableIdx === 0
? 'primary'
: 'secondary'
let buttonVariant: ThemeVariant =
stableIdx === 0 ? 'primary' : 'secondary'
if (variant === 'links') {
buttonVariant = 'tertiary-neutral'
} else if (variant === 'compactTertiary') {
buttonVariant = 'tertiary'
}
const linkType =
variant === 'links' ? link.type || 'inbound' : link.type
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/call-to-action/props.js
Expand Up @@ -8,7 +8,7 @@ module.exports = {
type: 'string',
description:
'Controls the visual appearance of the call to action, defaults to `centered`.',
options: ['centered', 'compact', 'compactGrid', 'links'],
options: ['centered', 'compact', 'compactGrid', 'compactTertiary', 'links'],
},
heading: {
type: 'string',
Expand Down