feat: loosen up the zod validations and return null instead of throwing

This commit is contained in:
Simon Emanuelsson
2024-06-07 10:36:23 +02:00
parent 5c50ac060d
commit aca9221ea6
89 changed files with 1117 additions and 821 deletions

View File

@@ -1,8 +1,12 @@
.body {
.caption {
margin: 0;
padding: 0;
}
.captionFontOnly {
font-style: normal;
}
.bold {
font-family: var(--typography-Caption-Bold-fontFamily);
font-size: var(--typography-Caption-Bold-fontSize);

View File

@@ -6,4 +6,5 @@ export interface CaptionProps
extends Omit<React.HTMLAttributes<HTMLHeadingElement>, "color">,
VariantProps<typeof captionVariants> {
asChild?: boolean
fontOnly?: boolean
}

View File

@@ -1,6 +1,6 @@
import { Slot } from "@radix-ui/react-slot"
import { captionVariants } from "./variants"
import { captionVariants, fontOnlycaptionVariants } from "./variants"
import type { CaptionProps } from "./caption"
@@ -8,14 +8,20 @@ export default function Caption({
asChild = false,
className = "",
color,
fontOnly = false,
textTransform,
...props
}: CaptionProps) {
const Comp = asChild ? Slot : "p"
const classNames = captionVariants({
className,
color,
textTransform,
})
const classNames = fontOnly
? fontOnlycaptionVariants({
className,
textTransform,
})
: captionVariants({
className,
color,
textTransform,
})
return <Comp className={classNames} {...props} />
}

View File

@@ -21,3 +21,20 @@ const config = {
} as const
export const captionVariants = cva(styles.caption, config)
const fontOnlyConfig = {
variants: {
textTransform: {
bold: styles.bold,
regular: styles.regular,
},
},
defaultVariants: {
textTransform: "regular",
},
} as const
export const fontOnlycaptionVariants = cva(
styles.captionFontOnly,
fontOnlyConfig
)