Skip to content

Commit

Permalink
wip: component and storybook refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
mewdev committed Jan 4, 2025
1 parent ba9315b commit bee51eb
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 53 deletions.
39 changes: 39 additions & 0 deletions apps/design-system/stories/bodyText.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { Meta, StoryObj } from "@storybook/react";

import { BodyText } from "@repo/design-system/ui";

const meta: Meta<typeof BodyText> = {
title: "Typography/Body",
component: BodyText,
argTypes: {
variant: {
control: "radio",
options: ["small", "medium", "large"],
},
},
};

type BodyTextStory = StoryObj<typeof meta>;

export const Large: BodyTextStory = {
args: {
children: "Large quick brown fox jumps over the lazy dog",
variant: "large",
},
};

export const Medium: BodyTextStory = {
args: {
children: "Medium quick brown fox jumps over the lazy dog",
variant: "medium",
},
};

export const Small: BodyTextStory = {
args: {
children: "Small quick brown fox jumps over the lazy dog",
variant: "small",
},
};

export default meta;
31 changes: 31 additions & 0 deletions apps/design-system/stories/buttonText.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Meta, StoryObj } from "@storybook/react";

import { ButtonText } from "@repo/design-system/ui";

const meta: Meta<typeof ButtonText> = {
title: "Typography/Button",
component: ButtonText,
argTypes: {
variant: {
control: "radio",
options: ["extraSmall", "small"],
},
},
};

type ButtonTextStory = StoryObj<typeof meta>;

export const Small: ButtonTextStory = {
args: {
children: "Button text",
variant: "small",
},
};

export const ExtraSmall: ButtonTextStory = {
args: {
children: "Button text",
variant: "extraSmall",
},
};
export default meta;
42 changes: 42 additions & 0 deletions apps/design-system/stories/headline.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Meta, StoryObj } from "@storybook/react";

import { Headline } from "@repo/design-system/ui";

const meta: Meta<typeof Headline> = {
title: "Typography/Headline",
component: Headline,
argTypes: {
variant: {
control: "radio",
options: ["small", "medium", "large"],
},
},
};

type HeadlineStory = StoryObj<typeof meta>;

export const Large: HeadlineStory = {
args: {
children: "Headline large",
variant: "large",
type: "h1",
},
};

export const Medium: HeadlineStory = {
args: {
children: "Headline medium",
variant: "medium",
type: "h2",
},
};

export const Small: HeadlineStory = {
args: {
children: "Headline small",
variant: "small",
type: "h3",
},
};

export default meta;
18 changes: 18 additions & 0 deletions apps/design-system/stories/labelText.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Meta, StoryObj } from "@storybook/react";

import { LabelText } from "@repo/design-system/ui";

const meta: Meta<typeof LabelText> = {
title: "Typography/Label",
component: LabelText,
};

type LabelTextStory = StoryObj<typeof meta>;

export const Default: LabelTextStory = {
args: {
children: "Label text (inter).",
},
};

export default meta;
32 changes: 32 additions & 0 deletions apps/design-system/stories/title.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Meta, StoryObj } from "@storybook/react";

import { Title } from "@repo/design-system/ui";

const meta: Meta<typeof Title> = {
title: "Typography/Title",
component: Title,
argTypes: {
variant: {
control: "radio",
options: ["medium", "large"],
},
},
};

type TitleStory = StoryObj<typeof meta>;

export const Large: TitleStory = {
args: {
children: "Title large",
variant: "large",
},
};

export const Medium: TitleStory = {
args: {
children: "Title medium",
variant: "medium",
},
};

export default meta;
3 changes: 2 additions & 1 deletion packages/design-system/src/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export * from "./button/index";
export * from "./card/index";
export * from "./progress/index";
export * from "./question/index";
export * from "./blobs";
export * from "./blobs/index";
export * from "./typography/index";
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cva, VariantProps } from "class-variance-authority";

const BodyVariants = cva("k1-font-primary, k1-font-bold, k1-tracking-tighter", {
const BodyVariants = cva("k1-font-primary k1-tracking-tighter", {
variants: {
variant: {
large: "k1-text-xl k1-tracking-tight",
Expand All @@ -15,6 +15,6 @@ type Props = {
children: React.ReactNode;
} & VariantProps<typeof BodyVariants>;

export default function Body({ children, variant }: Props) {
export function BodyText({ children, variant }: Props) {
return <p className={BodyVariants({ variant })}>{children}</p>;
}
12 changes: 2 additions & 10 deletions packages/design-system/src/ui/typography/ButtonText.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cva, VariantProps } from "class-variance-authority";

const ButtonTextVariants = cva(
"k1-font-secondary, k1-font-bold, k1-uppercase k1-tracking-wider",
"k1-font-secondary k1-font-bold k1-uppercase k1-tracking-wider",
{
variants: {
variant: {
Expand All @@ -16,14 +16,6 @@ type Props = {
children: React.ReactNode;
} & VariantProps<typeof ButtonTextVariants>;

export default function ButtonText({ children, variant }: Props) {
export function ButtonText({ children, variant }: Props) {
return <span className={ButtonTextVariants({ variant })}>{children}</span>;
}

// <span className="k1-font-secondary k1-text-sm k1-font-bold k1-uppercase k1-tracking-wider">
// Button text
// </span>

// <span className="k1-font-secondary k1-text-xs k1-font-bold k1-uppercase k1-tracking-wider">
// Small button text (radio canada).
// </span>
32 changes: 16 additions & 16 deletions packages/design-system/src/ui/typography/Headline.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cva, VariantProps } from "class-variance-authority";

const HeadlineVariants = cva(
"k1-font-secondary, k1-font-bold, k1-tracking-tighter",
"k1-font-secondary k1-font-bold k1-tracking-tighter",
{
variants: {
variant: {
Expand All @@ -13,24 +13,24 @@ const HeadlineVariants = cva(
},
);

type HeadingType = "h1" | "h2" | "h3";

type Props = {
children: React.ReactNode;
type: HeadingType;
} & VariantProps<typeof HeadlineVariants>;

// TODO: solve h1,h2,h3 problem

export default function Headline({ children, variant }: Props) {
return <h1 className={HeadlineVariants({ variant })}>{children}</h1>;
}
export function Headline({ children, variant, type }: Props) {
switch (type) {
case "h1": {
return <h1 className={HeadlineVariants({ variant })}>{children}</h1>;
}
case "h2": {
return <h2 className={HeadlineVariants({ variant })}>{children}</h2>;
}

{
/* <h1 className="k1-font-secondary k1-text-6xl k1-font-bold k1-tracking-tighter">
Headline large
</h1>
<h2 className="k1-font-secondary k1-text-5xl k1-font-bold k1-tracking-tighter">
Headline medium
</h2>
<h3 className="k1-font-secondary k1-text-4xl k1-font-bold k1-tracking-tighter">
Headline small
</h3> */
case "h3": {
return <h3 className={HeadlineVariants({ variant })}>{children}</h3>;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ type Props = {
children: React.ReactNode;
};

export default function Label({ children }: Props) {
export function LabelText({ children }: Props) {
return (
<span className="k1-font-primary k1-text-xs k1-font-bold k1-uppercase k1-tracking-wider">
{children}
Expand Down
28 changes: 7 additions & 21 deletions packages/design-system/src/ui/typography/Title.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
import { cva, VariantProps } from "class-variance-authority";

const TitleVariants = cva(
"k1-font-secondary, k1-font-bold, k1-tracking-tight",
{
variants: {
variant: {
large: "k1-text-3xl",
medium: "k1-text-2xl",
},
const TitleVariants = cva("k1-font-secondary k1-font-bold k1-tracking-tight", {
variants: {
variant: {
large: "k1-text-3xl",
medium: "k1-text-2xl",
},
},
);
});

type Props = {
children: React.ReactNode;
} & VariantProps<typeof TitleVariants>;

// solve h1,h2,h3 problem ?

export default function Title({ children, variant }: Props) {
export function Title({ children, variant }: Props) {
return <span className={TitleVariants({ variant })}>{children}</span>;
}

{
/* <h1 className="k1-font-secondary k1-text-3xl k1-font-bold k1-tracking-tight">
Title large
</h1>
<h1 className="k1-font-secondary k1-text-2xl k1-font-bold k1-tracking-tight">
Title medium
</h1> */
}
4 changes: 2 additions & 2 deletions packages/design-system/src/ui/typography/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./Body";
export * from "./BodyText";
export * from "./ButtonText";
export * from "./Headline";
export * from "./Label";
export * from "./LabelText";
export * from "./Title";

0 comments on commit bee51eb

Please sign in to comment.