Skip to content

Commit

Permalink
Fix warning of props being forwarded to the DOM (#3083)
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Fichtner <markus.fichtner@vivid-planet.com>
  • Loading branch information
fichtnerma and Markus Fichtner authored Jan 13, 2025
1 parent 5583c9c commit 856297f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions demo/site/src/common/components/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,15 @@ const variantToElementMap: Record<TypographyVariant, "h1" | "h2" | "h3" | "h4" |
p200: "p",
};

export const Typography = styled.div.attrs<{
as?: unknown;
variant?: TypographyVariant;
bottomSpacing?: boolean;
}>((props) => ({ as: props.as ?? variantToElementMap[props.variant ?? "p300"] }))`
export const Typography = styled.div
.withConfig({
shouldForwardProp: (prop) => !["variant", "bottomSpacing"].includes(prop),
})
.attrs<{
as?: unknown;
variant?: TypographyVariant;
bottomSpacing?: boolean;
}>((props) => ({ as: props.as ?? variantToElementMap[props.variant ?? "p300"] }))`
font-family: ${({ theme }) => theme.fontFamily};
${({ variant = "p300" }) => typographyVariantStyle[variant]};
margin-top: 0;
Expand Down

0 comments on commit 856297f

Please sign in to comment.