-
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.
refactor: Typography 폴더로 Text 컴포넌트 이동
- Loading branch information
Showing
6 changed files
with
36 additions
and
34 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/components/Common/Text/Text.stories.tsx → ...s/Common/Typography/Text/Text.stories.tsx
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,28 @@ | ||
import cx from 'classnames'; | ||
import type { ElementType } from 'react'; | ||
|
||
import { typography } from '../typography.css'; | ||
import type { OverridableComponentPropsWithoutRef, TypographyVariants } from '../typography.types'; | ||
|
||
export type TextElement = Extract<ElementType, 'p' | 'span'>; | ||
type TextProps<T extends TextElement> = OverridableComponentPropsWithoutRef<T, TypographyVariants>; | ||
|
||
const Text = <T extends TextElement = 'p'>({ | ||
children, | ||
size = 'body', | ||
weight = 'regular', | ||
color = 'default', | ||
as, | ||
className, | ||
...props | ||
}: TextProps<T>) => { | ||
const Component = as || 'p'; | ||
|
||
return ( | ||
<Component className={cx(typography({ color, size, weight }), className)} {...props}> | ||
{children} | ||
</Component> | ||
); | ||
}; | ||
|
||
export default 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
9 changes: 4 additions & 5 deletions
9
src/components/Common/Text/text.types.ts → ...nts/Common/Typography/typography.types.ts
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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
import type { ElementType, ComponentPropsWithoutRef } from 'react'; | ||
|
||
import type { text } from './text.css'; | ||
import type { typography } from './typography.css'; | ||
|
||
import type { RecipeVariants } from '@vanilla-extract/recipes'; | ||
|
||
export const colors = ['default', 'sub', 'info', 'disabled', 'white'] as const; | ||
export const sizes = ['caption4', 'caption3', 'caption2', 'caption1', 'body', 'headline'] as const; | ||
export const sizes = ['caption4', 'caption3', 'caption2', 'caption1', 'body', 'headline', 'display1'] as const; | ||
export const weights = ['regular', 'medium', 'semiBold'] as const; | ||
|
||
export type Color = (typeof colors)[number]; | ||
export type Size = (typeof sizes)[number]; | ||
export type Weight = (typeof weights)[number]; | ||
|
||
export type TextVariants = RecipeVariants<typeof text>; | ||
|
||
export type OverridableComponentPropsWithoutRef<T extends ElementType, P = unknown> = P & | ||
ComponentPropsWithoutRef<T> & { as?: T }; | ||
export type TextElement = Extract<ElementType, 'p' | 'span'>; | ||
|
||
export type TypographyVariants = RecipeVariants<typeof typography>; |
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