-
Notifications
You must be signed in to change notification settings - Fork 35
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
Showing
4 changed files
with
220 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { type Props, Text } from './text' |
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,93 @@ | ||
import { Text } from './text' | ||
|
||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
type Component = typeof Text | ||
|
||
const meta: Meta<Component> = { | ||
title: 'Components/Text', | ||
component: Text, | ||
args: { | ||
children: 'The quick brown fox jumped over the lazy dog.', | ||
}, | ||
parameters: { | ||
design: { | ||
type: 'figma', | ||
url: 'https://www.figma.com/file/v98g9ZiaSHYUdKWrbFg9eM/Foundations?node-id=617-208&t=ppNe6QC4ntgNciqw-11', | ||
}, | ||
}, | ||
|
||
render: props => ( | ||
<div className="grid gap-6"> | ||
<div className="grid gap-2"> | ||
<Text {...props} size={88} weight="regular" /> | ||
<Text {...props} size={88} weight="medium" /> | ||
<Text {...props} size={88} weight="semibold" /> | ||
<Text {...props} size={88} weight="bold" /> | ||
</div> | ||
|
||
<div className="grid gap-2"> | ||
<Text {...props} size={64} weight="regular" /> | ||
<Text {...props} size={64} weight="medium" /> | ||
<Text {...props} size={64} weight="semibold" /> | ||
<Text {...props} size={64} weight="bold" /> | ||
</div> | ||
|
||
<div className="grid gap-2"> | ||
<Text {...props} size={40} weight="regular" /> | ||
<Text {...props} size={40} weight="medium" /> | ||
<Text {...props} size={40} weight="semibold" /> | ||
<Text {...props} size={40} weight="bold" /> | ||
</div> | ||
|
||
<div className="grid gap-2"> | ||
<Text {...props} size={27} weight="regular" /> | ||
<Text {...props} size={27} weight="medium" /> | ||
<Text {...props} size={27} weight="semibold" /> | ||
</div> | ||
|
||
<div className="grid gap-2"> | ||
<Text {...props} size={19} weight="regular" /> | ||
<Text {...props} size={19} weight="medium" /> | ||
<Text {...props} size={19} weight="semibold" /> | ||
</div> | ||
|
||
<div className="grid gap-2"> | ||
<Text {...props} size={15} weight="regular" /> | ||
<Text {...props} size={15} weight="medium" /> | ||
<Text {...props} size={15} weight="semibold" /> | ||
</div> | ||
|
||
<div className="grid gap-2"> | ||
<Text {...props} size={13} weight="regular" /> | ||
<Text {...props} size={13} weight="medium" /> | ||
<Text {...props} size={13} weight="semibold" /> | ||
</div> | ||
|
||
<div className="grid gap-2"> | ||
<Text {...props} size={11} weight="regular" /> | ||
<Text {...props} size={11} weight="medium" /> | ||
<Text {...props} size={11} weight="semibold" /> | ||
<Text {...props} size={11} weight="regular" uppercase /> | ||
<Text {...props} size={11} weight="medium" uppercase /> | ||
<Text {...props} size={11} weight="semibold" uppercase /> | ||
</div> | ||
</div> | ||
), | ||
} | ||
|
||
type Story = StoryObj<Component> | ||
|
||
export const Light: Story = { | ||
args: {}, | ||
} | ||
|
||
export const Dark: Story = { | ||
parameters: { | ||
backgrounds: { | ||
default: 'dark', | ||
}, | ||
}, | ||
} | ||
|
||
export default meta |
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,61 @@ | ||
import { forwardRef } from 'react' | ||
|
||
import { cva, type VariantProps } from 'cva' | ||
|
||
const styles = cva({ | ||
variants: { | ||
type: { | ||
default: 'font-sans', | ||
monospace: 'font-mono', | ||
}, | ||
size: { | ||
88: 'text-88', | ||
64: 'text-64', | ||
40: 'text-40', | ||
27: 'text-27', | ||
19: 'text-19', | ||
15: 'text-15', | ||
13: 'text-13', | ||
11: 'text-11', | ||
}, | ||
weight: { | ||
regular: 'font-regular', | ||
medium: 'font-medium', | ||
semibold: 'font-semibold', | ||
bold: 'font-bold', | ||
}, | ||
uppercase: { | ||
true: 'uppercase', | ||
}, | ||
wrap: { | ||
false: 'whitespace-nowrap', | ||
}, | ||
truncate: { | ||
true: 'truncate', | ||
}, | ||
select: { | ||
false: 'select-none', | ||
}, | ||
}, | ||
defaultVariants: { | ||
type: 'default', | ||
weight: 'regular', | ||
}, | ||
}) | ||
|
||
type Props<C extends React.ElementType> = VariantProps<typeof styles> & | ||
React.ComponentPropsWithoutRef<C> & { | ||
as?: C | ||
} | ||
|
||
const Text = <C extends React.ElementType = 'span'>(props: Props<C>) => { | ||
const { as: Component = 'span', children, className, ...rest } = props | ||
return ( | ||
<Component {...rest} className={styles({ ...props, className })}> | ||
{children} | ||
</Component> | ||
) | ||
} | ||
|
||
export { Text } | ||
export type { Props as TextProps } |
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