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:
+25
-21
@@ -5,7 +5,7 @@ import DataGrid, { type DataGridProps } from 'react-data-grid';
|
||||
import { useSpreadsheetImportInternal } from '@/spreadsheet-import/hooks/useSpreadsheetImportInternal';
|
||||
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
|
||||
|
||||
const StyledDataGrid = styled(DataGrid)`
|
||||
const StyledDataGridContainer = styled.div<{ headerRowHeight?: number }>`
|
||||
--rdg-background-color: ${themeCssVariables.background.primary};
|
||||
--rdg-border-color: ${themeCssVariables.border.color.medium};
|
||||
--rdg-color: ${themeCssVariables.font.color.primary};
|
||||
@@ -25,9 +25,11 @@ const StyledDataGrid = styled(DataGrid)`
|
||||
--row-selected-hover-background-color: ${themeCssVariables.background
|
||||
.secondary};
|
||||
|
||||
border: none;
|
||||
block-size: 100%;
|
||||
width: 100%;
|
||||
> * {
|
||||
border: none;
|
||||
block-size: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.rdg-header-row .rdg-cell {
|
||||
box-shadow: none;
|
||||
@@ -99,7 +101,7 @@ const StyledDataGrid = styled(DataGrid)`
|
||||
display: flex;
|
||||
line-height: none;
|
||||
}
|
||||
` as typeof DataGrid;
|
||||
`;
|
||||
|
||||
type SpreadsheetImportTableProps<Data> = Pick<
|
||||
DataGridProps<Data>,
|
||||
@@ -138,21 +140,23 @@ export const SpreadsheetImportTable = <Data,>({
|
||||
if (!rows?.length || !columns?.length) return null;
|
||||
|
||||
return (
|
||||
<StyledDataGrid
|
||||
direction={rtl ? 'rtl' : 'ltr'}
|
||||
rowHeight={40}
|
||||
{...{
|
||||
className: `${className || ''} ${themeClassName}`,
|
||||
columns,
|
||||
headerRowHeight,
|
||||
rowKeyGetter,
|
||||
onRowsChange,
|
||||
rows,
|
||||
components,
|
||||
onRowClick,
|
||||
onSelectedRowsChange,
|
||||
selectedRows,
|
||||
}}
|
||||
/>
|
||||
<StyledDataGridContainer headerRowHeight={headerRowHeight}>
|
||||
<DataGrid
|
||||
direction={rtl ? 'rtl' : 'ltr'}
|
||||
rowHeight={40}
|
||||
{...{
|
||||
className: `${className || ''} ${themeClassName}`,
|
||||
columns,
|
||||
headerRowHeight,
|
||||
rowKeyGetter,
|
||||
onRowsChange,
|
||||
rows,
|
||||
components,
|
||||
onRowClick,
|
||||
onSelectedRowsChange,
|
||||
selectedRows,
|
||||
}}
|
||||
/>
|
||||
</StyledDataGridContainer>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user