-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3540e5
commit 8ae931a
Showing
6 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
|
||
import { Prose } from "./Prose" | ||
|
||
type Story = StoryObj<typeof Prose> | ||
|
||
// Meta | ||
export default { | ||
title: "Typography/Prose", | ||
component: Prose, | ||
args: { | ||
children: ( | ||
<> | ||
<h1>Heading 1</h1> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt | ||
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation | ||
ullamco laboris nisi ut aliquip ex ea commodo <a href="#">consequat</a>. | ||
</p> | ||
<h2>Heading 2</h2> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt | ||
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation | ||
ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
</p> | ||
<h3>Heading 3</h3> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt | ||
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation | ||
ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
</p> | ||
<h4>Heading 4</h4> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt | ||
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation | ||
ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
</p> | ||
<ul> | ||
<li>Unordered List Item 1</li> | ||
<li>Unordered List Item 2</li> | ||
<li>Unordered List Item 3</li> | ||
</ul> | ||
</> | ||
), | ||
...Prose.defaultProps, | ||
}, | ||
} satisfies Meta | ||
|
||
// Stories | ||
export const Large = { | ||
args: { | ||
size: "lg", | ||
}, | ||
} satisfies Story | ||
|
||
export const Medium = { | ||
args: { | ||
size: "md", | ||
}, | ||
} satisfies Story | ||
|
||
export const Small = { | ||
args: { | ||
size: "sm", | ||
}, | ||
} satisfies Story |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Slot } from "@radix-ui/react-slot" | ||
import type { HTMLAttributes } from "react" | ||
import { forwardRef } from "react" | ||
|
||
import { type VariantProps, cx } from "~/shared/cva" | ||
|
||
import { proseVariants } from "./Prose.variants" | ||
|
||
export type ProseElement = HTMLDivElement | ||
|
||
export type ProseProps = Omit<HTMLAttributes<ProseElement>, "size"> & | ||
VariantProps<typeof proseVariants> & { | ||
/** | ||
* If set to `true`, the button will be rendered as a child within the component. | ||
* This child component must be a valid React component. | ||
*/ | ||
asChild?: boolean | ||
} | ||
|
||
export const Prose = forwardRef<ProseElement, ProseProps>((props, ref) => { | ||
const { className, asChild, size, ...rest } = props | ||
const Comp = asChild ? Slot : "div" | ||
|
||
return <Comp className={cx(proseVariants({ size, className }))} ref={ref} {...rest} /> | ||
}) | ||
|
||
Prose.defaultProps = { | ||
size: "md", | ||
asChild: false, | ||
} | ||
|
||
Prose.displayName = "Prose" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { cva } from "~/shared/cva" | ||
|
||
export const proseVariants = cva({ | ||
base: [ | ||
"text-pretty text-start prose", | ||
// Prose Headings | ||
"prose-headings:font-medium prose-h1:-tracking-1 prose-h2:-tracking-1", | ||
], | ||
|
||
variants: { | ||
size: { | ||
sm: "prose-sm", | ||
md: "prose-base", | ||
lg: "prose-lg", | ||
}, | ||
}, | ||
|
||
defaultVariants: { | ||
size: "md", | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { Prose } from "./Prose" | ||
export type { ProseProps, ProseElement } from "./Prose" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters