-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from GDSC-Hongik/feat/text-component
- Loading branch information
Showing
13 changed files
with
8,185 additions
and
9,529 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
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 |
---|---|---|
|
@@ -42,6 +42,8 @@ | |
"node": ">=18" | ||
}, | ||
"dependencies": { | ||
"clsx": "^2.1.1", | ||
"wowds-tokens": "^0.1.1", | ||
"wowds-ui": "^0.1.8" | ||
} | ||
} |
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
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,61 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import Text from "."; | ||
|
||
const meta: Meta<typeof Text> = { | ||
title: "UI/Text", | ||
component: Text, | ||
tags: ["autodocs"], | ||
parameters: { | ||
componentSubtitle: "Text 컴포넌트", | ||
}, | ||
argTypes: { | ||
as: { | ||
control: { type: "select" }, | ||
options: ["p", "h1", "h2", "h3", "span", "div"], | ||
description: "HTML 태그 이름", | ||
}, | ||
typo: { | ||
control: { type: "text" }, | ||
description: "텍스트 타이포", | ||
}, | ||
color: { | ||
control: { type: "color" }, | ||
description: "텍스트 색상", | ||
}, | ||
children: { | ||
control: { type: "text" }, | ||
description: "텍스트 내용", | ||
}, | ||
style: { | ||
control: { type: "object" }, | ||
description: "커스텀 스타일 객체", | ||
}, | ||
className: { | ||
control: { type: "text" }, | ||
description: "커스텀 클래스 이름", | ||
}, | ||
}, | ||
} satisfies Meta<typeof Text>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: "예시", | ||
as: "p", | ||
typo: "body1", | ||
color: "textBlack", | ||
}, | ||
}; | ||
|
||
export const AsDiv: Story = { | ||
args: { | ||
children: "예시", | ||
as: "div", | ||
typo: "h1", | ||
color: "primary", | ||
}, | ||
}; |
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,53 @@ | ||
import { css } from "@styled-system/css"; | ||
import { styled } from "@styled-system/jsx"; | ||
import type { ColorToken } from "@styled-system/tokens"; | ||
import { clsx } from "clsx"; | ||
import type { CSSProperties, ElementType, PropsWithChildren } from "react"; | ||
import type { typography as typoType } from "wowds-tokens"; | ||
|
||
type ColorKey = ColorToken; | ||
type TypoKey = keyof typeof typoType; | ||
|
||
/** | ||
* @description Text 컴포넌트 | ||
* @param {ElementType} as - HTML 태그 이름입니다. 기본값은 "p" 입니다. | ||
* @param {TypoKey} typo - 텍스트 타이포입니다. 기본값은 "body1" 입니다. | ||
* @param {ColorKey} color - 텍스트 색상입니다. 기본값은 "textBlack" 입니다. | ||
* @param {CSSProperties} style - 커스터 할 수 있는 컴포넌트 스타일입니다. | ||
* @param {string} className - 커스텀 할 수 있는 컴포넌트 클래스 이름입니다. | ||
*/ | ||
interface TextProps<T extends ElementType = "p"> extends PropsWithChildren { | ||
as?: T; | ||
typo?: TypoKey; | ||
color?: ColorKey; | ||
style?: CSSProperties; | ||
className?: string; | ||
} | ||
|
||
const Text = <T extends ElementType = "p">({ | ||
as, | ||
typo = "body1", | ||
color = "textBlack", | ||
children, | ||
className, | ||
...rest | ||
}: TextProps<T>) => { | ||
const Component = styled(as || "p"); | ||
|
||
return ( | ||
<Component | ||
className={clsx( | ||
css({ | ||
textStyle: typo, | ||
color: color, | ||
}), | ||
className | ||
)} | ||
{...rest} | ||
> | ||
{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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as NavItem } from "./NavItem"; | ||
export { default as Text } from "./Text"; |
Oops, something went wrong.