feat(WEB-304): remaning UI from design system primitives

This commit is contained in:
Simon Emanuelsson
2024-06-07 10:36:23 +02:00
parent 6737970f54
commit 7c4b8401e9
228 changed files with 3516 additions and 3237 deletions
@@ -1,21 +1,27 @@
import { Slot } from "@radix-ui/react-slot"
import { subtitleVariants } from "./variants"
import type { SubtitleProps } from "./subtitle"
export default function Subtitle({
children,
asChild = false,
className = "",
color,
hideEmpty = true,
textAlign,
textTransform,
...props
}: SubtitleProps) {
if (hideEmpty && !children) {
if (hideEmpty && !props.children) {
return null
}
const Comp = asChild ? Slot : "p"
const classNames = subtitleVariants({
className,
color,
textAlign,
textTransform,
})
return <p className={classNames}>{children}</p>
return <Comp className={classNames} {...props} />
}
@@ -8,8 +8,8 @@
font-weight: var(--typography-Subtitle-fontWeight);
letter-spacing: var(--typography-Subtitle-letterSpacing);
line-height: var(--typography-Subtitle-lineHeight);
margin: 0;
padding: 0;
margin: var(--Spacing-x0);
padding: var(--Spacing-x0);
}
.regular {
@@ -20,6 +20,14 @@
text-transform: uppercase;
}
.center {
text-align: center;
}
.left {
text-align: left;
}
.burgundy {
color: var(--Scandic-Brand-Burgundy);
}
@@ -5,5 +5,6 @@ import type { VariantProps } from "class-variance-authority"
export interface SubtitleProps
extends Omit<React.HTMLAttributes<HTMLHeadingElement>, "color">,
VariantProps<typeof subtitleVariants> {
asChild?: boolean
hideEmpty?: boolean
}
@@ -8,6 +8,10 @@ const config = {
burgundy: styles.burgundy,
pale: styles.pale,
},
textAlign: {
center: styles.center,
left: styles.left,
},
textTransform: {
regular: styles.regular,
uppercase: styles.uppercase,
@@ -15,6 +19,7 @@ const config = {
},
defaultVariants: {
color: "burgundy",
textAlign: "left",
textTransform: "regular",
},
} as const