Skip to content

Commit

Permalink
refactor(Text): replace defaultProps property
Browse files Browse the repository at this point in the history
  • Loading branch information
silvioprog committed Sep 30, 2024
1 parent 992033c commit fbebad9
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,35 +104,27 @@ const variants = {
[TextVariants.context]: contextVariant,
};

const Text = styled.span.attrs<{ variant: keyof typeof TextVariants }>(
(props) => ({
...props,
className: cls(CLX_TYPOGRAPHY, props?.className),
}),
)<TextProps>`
const Text = styled.span.attrs<TextProps>((props) => ({
...props,
className: cls(CLX_TYPOGRAPHY, props?.className),
size: props.size ?? TextSizes.md,
variant: props.variant ?? TextVariants.primary,
isBold: props.isBold ?? false,
}))<TextProps>`
font-family: inherit;
font-weight: ${({ isBold }) =>
isBold ? 'var(--sscds-font-weight-body-strong)' : 'inherit'};
${({ size }) => sizes[size]};
${({ variant }) => variants[variant]};
`;

Text.defaultProps = {
size: TextSizes.md,
variant: TextVariants.primary,
isBold: false,
};

export default Text;

export const Strong = styled(Text).attrs<StrongProps>(() => ({
as: 'strong',
isBold: true,
}))``;

Strong.defaultProps = {
size: TextSizes.inherit,
};
}))``;

export const Code = styled(Text).attrs<CodeProps>(() => ({
variant: TextVariants.monospace,
Expand Down

0 comments on commit fbebad9

Please sign in to comment.