fix(BOOK-293): changed variants and props on IconButton component * fix(BOOK-293): changed variants and props on IconButton component * fix(BOOK-293): inherit color for icon Approved-by: Bianca Widstam Approved-by: Christel Westerberg
55 lines
1.1 KiB
TypeScript
55 lines
1.1 KiB
TypeScript
import { cva } from 'class-variance-authority'
|
|
|
|
|
|
import { deepmerge } from 'deepmerge-ts'
|
|
import styles from './button.module.css'
|
|
|
|
export const config = {
|
|
variants: {
|
|
variant: {
|
|
Primary: styles['variant-primary'],
|
|
Secondary: styles['variant-secondary'],
|
|
Tertiary: styles['variant-tertiary'],
|
|
Text: styles['variant-text'],
|
|
},
|
|
color: {
|
|
Primary: styles['color-primary'],
|
|
Inverted: styles['color-inverted'],
|
|
},
|
|
size: {
|
|
sm: styles['size-sm'],
|
|
md: styles['size-md'],
|
|
lg: styles['size-lg'],
|
|
},
|
|
wrapping: {
|
|
true: undefined,
|
|
false: styles['no-wrapping'],
|
|
},
|
|
fullWidth: {
|
|
true: styles['full-width'],
|
|
false: undefined,
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: 'Primary',
|
|
color: 'Primary',
|
|
size: 'lg',
|
|
wrapping: true,
|
|
},
|
|
} as const
|
|
|
|
const buttonConfig = {
|
|
variants: {
|
|
...config.variants,
|
|
},
|
|
defaultVariants: {
|
|
...config.defaultVariants,
|
|
},
|
|
} as const
|
|
|
|
export const variants = cva(styles.button, buttonConfig)
|
|
|
|
export function withButton<T>(config: T) {
|
|
return deepmerge(buttonConfig, config)
|
|
}
|