@@ -6,6 +6,7 @@ import theme from '../theme';
66import { cardCSS , headerCSS , collapsibleCardCSS } from './styles' ;
77import { classNames } from '../utils' ;
88import { useId } from '@react-aria/utils' ;
9+ import { CardVariant } from './types' ;
910
1011const headerTitleWrapCSS = css `
1112 flex : 1 1 auto;
@@ -28,24 +29,31 @@ const bodyCSS = css`
2829 padding : ${ theme . spacing . padding16 } px;
2930` ;
3031
31- export type CardProps = {
32+ export interface CardBaseProps {
3233 title ?: string ;
3334 subTitle ?: string ;
35+ variant ?: CardVariant ;
3436 children : ReactNode ;
3537 style ?: CSSProperties ;
3638 bodyStyle ?: CSSProperties ;
3739 extra ?: ReactNode ; // Extra controls on the header
3840 className ?: string ;
3941 titleExtra ?: ReactNode ;
42+ id ?: string ;
43+ }
44+
45+ interface CollapsibleCardProps {
4046 collapsible ?: boolean ;
4147 defaultOpen ?: boolean ;
4248 onToggle ?: ( open : boolean ) => void ;
43- id ?: string ;
44- } ;
49+ }
50+
51+ export interface CardProps extends CardBaseProps , CollapsibleCardProps { }
4552
4653export function Card ( {
4754 title,
4855 subTitle,
56+ variant = 'default' ,
4957 children,
5058 style,
5159 bodyStyle,
@@ -60,8 +68,10 @@ export function Card({
6068 const idPrefix = useId ( id ) ;
6169 const contentId = `${ idPrefix } -content` ,
6270 headerId = `${ idPrefix } -heading` ;
71+ const titleSize = variant === 'default' ? 'xlarge' : 'large' ;
72+ const subTitleSize = variant === 'default' ? 'medium' : 'xsmall' ;
6373 const defaultTitle = (
64- < Text textSize = "xlarge" elementType = "h3" weight = "heavy" >
74+ < Text textSize = { titleSize } elementType = "h3" weight = "heavy" >
6575 { title }
6676 </ Text >
6777 ) ;
@@ -76,14 +86,15 @@ export function Card({
7686 ) ;
7787 const subTitleEl =
7888 subTitle != null ? (
79- < Text textSize = "medium" elementType = "h4" color = "white70" >
89+ < Text textSize = { subTitleSize } elementType = "h4" color = "white70" >
8090 { subTitle }
8191 </ Text >
8292 ) : (
8393 undefined
8494 ) ;
95+ const titleClassName = `ac-card__title-wrap ac-card__title-wrap--${ variant } ` ;
8596 const titleComponent = collapsible ? (
86- < div css = { headerTitleWrapCSS } >
97+ < div css = { headerTitleWrapCSS } className = { titleClassName } >
8798 < CollapsibleCardTitle
8899 isOpen = { isOpen }
89100 onOpen = { ( ) => setIsOpen ( ! isOpen ) }
@@ -95,7 +106,7 @@ export function Card({
95106 />
96107 </ div >
97108 ) : (
98- < div css = { headerTitleWrapCSS } >
109+ < div css = { headerTitleWrapCSS } className = { titleClassName } >
99110 { titleEl }
100111 { subTitleEl }
101112 </ div >
@@ -104,7 +115,7 @@ export function Card({
104115 < section
105116 css = { collapsible ? collapsibleCardCSS : cardCSS }
106117 style = { style }
107- className = { classNames ( 'ac-card' , className , {
118+ className = { classNames ( 'ac-card' , `ac-card-- ${ variant } ` , className , {
108119 'is-open' : isOpen ,
109120 } ) }
110121 >
@@ -116,9 +127,10 @@ export function Card({
116127 css = { css (
117128 bodyCSS ,
118129 css `
119- ${ ! isOpen && `display: none;` }
130+ ${ ! isOpen && `display: none !important ;` }
120131 `
121132 ) }
133+ className = "ac-card__body"
122134 style = { bodyStyle }
123135 id = { contentId }
124136 aria-labelledby = { headerId }
0 commit comments