Remove all styled(Component) patterns in favor of parent wrappers and props (#18430)

## Summary

Eliminates all ~350 `styled(Component)` usages across `twenty-front` and
`twenty-ui` (212 files changed). Each was replaced following these
rules:

- **Margin/layout CSS** (margin, padding, flex, align-self, width) →
wrapped in a `styled.div`/`styled.span` parent container
- **Third-party components** (Link, TextareaAutosize,
ReactPhoneNumberInput, Handle, etc.) → parent container with child CSS
selectors (`> a`, `> textarea`, `> input`, etc.)
- **Intrinsic behavior via existing props** (TableRow
`gridTemplateColumns`, TableCell `color`/`align`) → replaced
`styled(TableRow)` / `styled(TableCell)` with direct prop usage
- **Other visual overrides on twenty-ui components** (Card, Section,
TabList, Button, MenuItem, ScrollWrapper, etc.) → parent wrappers with
`> div` / `> *` child selectors
- **Extending styled.div/span** → merged all CSS into a single
`styled.div`/`styled.span`

Also adds `overflow: hidden` to parent containers wrapping
`ScrollWrapper` so scroll activates correctly with the new wrapper
structure.

### Migration patterns

| Before | After |
|--------|-------|
| `styled(Avatar)` with `margin-right` | `<StyledAvatarContainer><Avatar
/></StyledAvatarContainer>` |
| `styled(Link)` with `text-decoration: none` |
`<StyledLinkContainer><Link /></StyledLinkContainer>` with `> a { ... }`
|
| `styled(TableRow)` with `grid-template-columns` | `<TableRow
gridTemplateColumns="..." />` |
| `styled(TableCell)` with `color` / `align` | `<TableCell color={...}
align="right" />` |
| `styled(Card)` with `margin-top` | `<StyledCardContainer><Card
/></StyledCardContainer>` |
| `styled(TabList)` with `background` |
`<StyledTabListContainer><TabList /></StyledTabListContainer>` with `>
div { ... }` |
| `styled(StyledBase)` extending a `styled.div` | Single merged
`styled.div` with all styles inlined |
This commit is contained in:
Charles Bochet
2026-03-05 18:16:25 +01:00
committed by GitHub
parent e5e3132ddd
commit c53a13417e
224 changed files with 4765 additions and 3837 deletions
@@ -55,7 +55,8 @@ const StyledDialogMessage = styled.span`
text-align: center;
`;
const StyledDialogButton = styled(Button)`
const StyledDialogButtonContainer = styled.div`
display: flex;
justify-content: center;
margin-bottom: ${themeCssVariables.spacing[2]};
`;
@@ -157,16 +158,18 @@ export const Dialog = ({
{message && <StyledDialogMessage>{message}</StyledDialogMessage>}
{children}
{buttons.map(({ accent, onClick, role, title: key, variant }) => (
<StyledDialogButton
onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
onClose?.();
onClick?.(event);
}}
fullWidth={true}
variant={variant ?? 'secondary'}
title={key}
{...{ accent, key, role }}
/>
<StyledDialogButtonContainer key={key}>
<Button
onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
onClose?.();
onClick?.(event);
}}
fullWidth={true}
variant={variant ?? 'secondary'}
title={key}
{...{ accent, role }}
/>
</StyledDialogButtonContainer>
))}
</StyledDialogContainer>
</StyledDialogOverlay>
@@ -68,7 +68,7 @@ const StyledContainer = styled.div`
}
`;
const StyledProgressBar = styled(ProgressBar)`
const StyledProgressBarContainer = styled.div`
bottom: 0;
height: auto;
left: 0;
@@ -112,17 +112,19 @@ const StyledDescription = styled.div`
width: 200px;
`;
const StyledLink = styled(Link)`
display: block;
color: ${themeCssVariables.font.color.tertiary};
font-size: ${themeCssVariables.font.size.sm};
padding-left: ${themeCssVariables.spacing[6]};
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
max-width: 200px;
&:hover {
color: ${themeCssVariables.font.color.secondary};
const StyledLinkContainer = styled.div`
> a {
display: block;
color: ${themeCssVariables.font.color.tertiary};
font-size: ${themeCssVariables.font.size.sm};
padding-left: ${themeCssVariables.spacing[6]};
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
max-width: 200px;
&:hover {
color: ${themeCssVariables.font.color.secondary};
}
}
`;
@@ -229,10 +231,12 @@ export const SnackBar = ({
role={role}
data-globally-prevent-click-outside
>
<StyledProgressBar
barColor={theme.snackBar[variant].backgroundColor}
value={progressValue}
/>
<StyledProgressBarContainer>
<ProgressBar
barColor={theme.snackBar[variant].backgroundColor}
value={progressValue}
/>
</StyledProgressBarContainer>
<StyledHeader>
<StyledIcon>{icon}</StyledIcon>
<StyledMessage>{sanitizedMessage ?? ''}</StyledMessage>
@@ -248,7 +252,9 @@ export const SnackBar = ({
<StyledDescription>{sanitizedDetailedMessage}</StyledDescription>
)}
{actionText && actionTo && (
<StyledLink to={actionTo}>{actionText}</StyledLink>
<StyledLinkContainer>
<Link to={actionTo}>{actionText}</Link>
</StyledLinkContainer>
)}
{actionText && actionOnClick && !actionTo && (
<StyledActionButton>