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:
+14
-10
@@ -18,9 +18,12 @@ import { getSettingsPath } from 'twenty-shared/utils';
|
||||
import { IconKey } from 'twenty-ui/display';
|
||||
import { useGetSsoIdentityProvidersQuery } from '~/generated-metadata/graphql';
|
||||
|
||||
const StyledLink = styled(Link)<{ isDisabled: boolean }>`
|
||||
const StyledLinkContainer = styled.div<{ isDisabled: boolean }>`
|
||||
pointer-events: ${({ isDisabled }) => (isDisabled ? 'none' : 'auto')};
|
||||
text-decoration: none;
|
||||
|
||||
> a {
|
||||
text-decoration: none;
|
||||
}
|
||||
`;
|
||||
|
||||
export const SettingsSSOIdentitiesProvidersListCard = () => {
|
||||
@@ -48,16 +51,17 @@ export const SettingsSSOIdentitiesProvidersListCard = () => {
|
||||
});
|
||||
|
||||
return loading || !SSOIdentitiesProviders.length ? (
|
||||
<StyledLink
|
||||
to={getSettingsPath(SettingsPath.NewSSOIdentityProvider)}
|
||||
<StyledLinkContainer
|
||||
isDisabled={currentWorkspace?.hasValidEnterpriseKey !== true}
|
||||
>
|
||||
<SettingsCard
|
||||
title={t`Add SSO Identity Provider`}
|
||||
disabled={currentWorkspace?.hasValidEnterpriseKey !== true}
|
||||
Icon={<IconKey />}
|
||||
/>
|
||||
</StyledLink>
|
||||
<Link to={getSettingsPath(SettingsPath.NewSSOIdentityProvider)}>
|
||||
<SettingsCard
|
||||
title={t`Add SSO Identity Provider`}
|
||||
disabled={currentWorkspace?.hasValidEnterpriseKey !== true}
|
||||
Icon={<IconKey />}
|
||||
/>
|
||||
</Link>
|
||||
</StyledLinkContainer>
|
||||
) : (
|
||||
<SettingsSSOIdentitiesProvidersListCardWrapper />
|
||||
);
|
||||
|
||||
+12
-8
@@ -19,8 +19,10 @@ import { useGetApprovedAccessDomainsQuery } from '~/generated-metadata/graphql';
|
||||
import { dateLocaleState } from '~/localization/states/dateLocaleState';
|
||||
import { beautifyPastDateRelativeToNow } from '~/utils/date-utils';
|
||||
|
||||
const StyledLink = styled(Link)`
|
||||
text-decoration: none;
|
||||
const StyledLinkContainer = styled.div`
|
||||
> a {
|
||||
text-decoration: none;
|
||||
}
|
||||
`;
|
||||
|
||||
export const SettingsApprovedAccessDomainsListCard = () => {
|
||||
@@ -54,12 +56,14 @@ export const SettingsApprovedAccessDomainsListCard = () => {
|
||||
};
|
||||
|
||||
return loading || !approvedAccessDomains.length ? (
|
||||
<StyledLink to={getSettingsPath(SettingsPath.NewApprovedAccessDomain)}>
|
||||
<SettingsCard
|
||||
title={t`Add Approved Access Domain`}
|
||||
Icon={<IconMailCog />}
|
||||
/>
|
||||
</StyledLink>
|
||||
<StyledLinkContainer>
|
||||
<Link to={getSettingsPath(SettingsPath.NewApprovedAccessDomain)}>
|
||||
<SettingsCard
|
||||
title={t`Add Approved Access Domain`}
|
||||
Icon={<IconMailCog />}
|
||||
/>
|
||||
</Link>
|
||||
</StyledLinkContainer>
|
||||
) : (
|
||||
<>
|
||||
<SettingsSecurityApprovedAccessDomainValidationEffect />
|
||||
|
||||
Reference in New Issue
Block a user