Skip to content

Commit

Permalink
♻️ refactor: 分割代入時に大文字始まりの変数とし、不要な代入を削除する
Browse files Browse the repository at this point in the history
  • Loading branch information
takashi0602 committed Mar 23, 2024
1 parent c664c72 commit 88195fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/components/base/Heading/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ type BaseProps<T extends TagName> = {
type Props<T extends TagName> = BaseProps<T> &
Omit<ComponentPropsWithoutRef<T>, keyof BaseProps<T>>;

const Heading: FC<Props<TagName>> = ({ tag = 'h1', children, className, ...rest }) => {
const Component = tag;
const Heading: FC<Props<TagName>> = ({ tag: Tag = 'h1', children, className, ...rest }) => {
return (
<Component className={clsx(styles.common, styles[tag], className)} {...rest}>
<Tag className={clsx(styles.common, styles[Tag], className)} {...rest}>
{children}
</Component>
</Tag>
);
};

Expand Down
9 changes: 4 additions & 5 deletions src/components/base/Text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Props<T extends TagName> = BaseProps<T> &
Omit<ComponentPropsWithoutRef<T>, keyof BaseProps<T>>;

const Text: FC<Props<TagName>> = ({
tag = 'span',
tag: Tag = 'span',
fontWeight = 'normal',
fontStyle = 'normal',
color = 'white',
Expand All @@ -44,15 +44,14 @@ const Text: FC<Props<TagName>> = ({
const style = styles({
color,
fontWeight,
display: tag === 'span' ? 'inlineBlock' : 'block',
display: Tag === 'span' ? 'inlineBlock' : 'block',
fontStyle,
});
const Component = tag;

return (
<Component className={clsx(style, className)} {...rest}>
<Tag className={clsx(style, className)} {...rest}>
{children}
</Component>
</Tag>
);
};

Expand Down

0 comments on commit 88195fb

Please sign in to comment.