Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Text Component #61

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/Text/Text.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
font-size: var(--font-size);
line-height: var(--leading);
color: var(--color);
font-weight: normal;
}

:where(.text) {
Expand Down
17 changes: 5 additions & 12 deletions src/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ type BaseProps = {
*/
children: ReactNode;
/**
* CSSのクラス
* HTMLのid属性
*/
className?: string;
id?: string;
};

type BodyFontSize = 'sm' | 'md' | 'lg';
Expand Down Expand Up @@ -125,19 +125,12 @@ export const Text: FC<TextProps> = ({
bold = false,
color = 'main',
children,
className,
id,
}) => {
return (
<TextComponent
className={clsx(
className,
styles.text,
bold && styles.bold,
styles[size],
styles[type],
styles[leading],
styles[color],
)}
id={id}
className={clsx(styles.text, bold && styles.bold, styles[size], styles[type], styles[leading], styles[color])}
>
{children}
</TextComponent>
Expand Down
8 changes: 8 additions & 0 deletions src/stories/Text.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,11 @@ export const Tag: Story = {
},
args: defaultArgs,
};

export const WithId: Story = {
render: () => (
<Text id="text-id" type="heading" size="xl" as="h2" color="primary" bold>
Dummy Text
</Text>
),
};