Merged in chore/sw-3145-move-caption (pull request #2503)
chore(SW-3145): Move Caption to design-system * Move Caption to design-system * Mark Caption as deprecated Approved-by: Linus Flood Approved-by: Joakim Jäderberg
This commit is contained in:
47
packages/design-system/lib/components/Caption/index.tsx
Normal file
47
packages/design-system/lib/components/Caption/index.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Slot } from '@radix-ui/react-slot'
|
||||
|
||||
import { captionVariants, fontOnlycaptionVariants } from './variants'
|
||||
import { VariantProps } from 'class-variance-authority'
|
||||
|
||||
interface CaptionProps
|
||||
extends Omit<React.HTMLAttributes<HTMLHeadingElement>, 'color'>,
|
||||
VariantProps<typeof captionVariants> {
|
||||
asChild?: boolean
|
||||
fontOnly?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `@scandic-hotels/design-system/Typography` instead.
|
||||
*/
|
||||
export default function Caption({
|
||||
asChild = false,
|
||||
className = '',
|
||||
color,
|
||||
fontOnly = false,
|
||||
textAlign,
|
||||
textTransform,
|
||||
uppercase,
|
||||
striked,
|
||||
type,
|
||||
...props
|
||||
}: CaptionProps) {
|
||||
const Comp = asChild ? Slot : 'p'
|
||||
const classNames = fontOnly
|
||||
? fontOnlycaptionVariants({
|
||||
className,
|
||||
textTransform,
|
||||
uppercase,
|
||||
striked,
|
||||
type,
|
||||
})
|
||||
: captionVariants({
|
||||
className,
|
||||
color,
|
||||
textTransform,
|
||||
textAlign,
|
||||
uppercase,
|
||||
striked,
|
||||
type,
|
||||
})
|
||||
return <Comp className={classNames} {...props} />
|
||||
}
|
||||
Reference in New Issue
Block a user