Skip to content

Add transient props to Box, Flex and Typography #1701

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

Closed
wants to merge 1 commit into from
Closed
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
52 changes: 49 additions & 3 deletions packages/strapi-design-system/src/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,57 @@ const transientProps: Partial<Record<keyof BoxProps, boolean>> = {
cursor: true,
height: true,
width: true,
borderColor: true,
hiddenS: true,
hiddenXS: true,
margin: true,
marginLeft: true,
marginBottom: true,
marginRight: true,
marginTop: true,
padding: true,
paddingLeft: true,
paddingRight: true,
paddingTop: true,
paddingBottom: true,
shadow: true,
zIndex: true,
overflow: true,
transition: true,
transform: true,
animation: true,
pointerEvents: true,
display: true,
position: true,
top: true,
left: true,
bottom: true,
right: true,
hasRadius: true,
borderStyle: true,
borderWidth: true,
shrink: true,
grow: true,
basis: true,
flex: true,
textAlign: true,
textTransform: true,
lineHeight: true,
_hover: true,
background: true,
fontSize: true,
maxWidth: true,
minWidth: true,
maxHeight: true,
minHeight: true,
borderRadius: true,
as: true,
forwardedAs: true,
};

export const Box = styled.div.withConfig<BoxProps>({
shouldForwardProp: (prop, defPropValFN) => !transientProps[prop as keyof BoxProps] && defPropValFN(prop),
})`
export const Box = styled.div.withConfig({
shouldForwardProp: (prop) => !transientProps[prop as keyof BoxProps],
})<BoxProps>`
// Font
font-size: ${({ fontSize, theme }) => extractStyleFromTheme(theme.fontSizes, fontSize, fontSize)};

Expand Down
11 changes: 8 additions & 3 deletions packages/strapi-design-system/src/Flex/Flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import handleResponsiveValues, { ResponsiveValue } from '../helpers/handleRespon
*/
const transientProps: Partial<Record<keyof FlexProps, boolean>> = {
direction: true,
gap: true,
inline: true,
alignItems: true,
justifyContent: true,
wrap: true,
};

export type FlexProps<TElement extends keyof JSX.IntrinsicElements = 'div'> = BoxProps<TElement> & {
Expand All @@ -22,9 +27,9 @@ export type FlexProps<TElement extends keyof JSX.IntrinsicElements = 'div'> = Bo
wrap?: CSSProperties['flexWrap'];
};

export const Flex = styled(Box).withConfig<FlexProps>({
shouldForwardProp: (prop, defPropValFN) => !transientProps[prop as keyof FlexProps] && defPropValFN(prop),
})`
export const Flex = styled(Box).withConfig({
shouldForwardProp: (prop) => !transientProps[prop as keyof FlexProps],
})<FlexProps>`
align-items: ${({ alignItems = 'center' }) => alignItems};
display: ${({ display = 'flex', inline }) => (inline ? 'inline-flex' : display)};
flex-direction: ${({ direction = 'row' }) => direction};
Expand Down
6 changes: 3 additions & 3 deletions packages/strapi-design-system/src/Pagination/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const transientProps = {
active: true,
};

const LinkWrapper = styled(BaseLink).withConfig<PaginationLinkProps>({
shouldForwardProp: (prop, defPropValFN) => !transientProps[prop] && defPropValFN(prop),
})`
const LinkWrapper = styled(BaseLink).withConfig({
shouldForwardProp: (prop) => !transientProps[prop],
})<PaginationLinkProps>`
padding: ${({ theme }) => theme.spaces[3]};
border-radius: ${({ theme }) => theme.borderRadius};
box-shadow: ${({ active, theme }) => (active ? theme.shadows.filterShadow : undefined)};
Expand Down
13 changes: 10 additions & 3 deletions packages/strapi-design-system/src/Typography/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import { DefaultThemeOrCSSProp } from '../types';
const transientProps: Partial<Record<keyof TypographyProps, boolean>> = {
fontSize: true,
fontWeight: true,
lineHeight: true,
textAlign: true,
textColor: true,
textDecoration: true,
textTransform: true,
ellipsis: true,
variant: true,
};

export type TypographyProps<TElement extends keyof JSX.IntrinsicElements = 'span'> =
Expand All @@ -28,9 +35,9 @@ export type TypographyProps<TElement extends keyof JSX.IntrinsicElements = 'span
variant?: (typeof TEXT_VARIANTS)[number];
};

export const Typography = styled.span.withConfig<TypographyProps>({
shouldForwardProp: (prop, defPropValFN) => !transientProps[prop as keyof TypographyProps] && defPropValFN(prop),
})`
export const Typography = styled.span.withConfig({
shouldForwardProp: (prop) => !transientProps[prop],
})<TypographyProps>`
${variantStyle}
${ellipsisStyle}

Expand Down