c53a13417e
## 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 |
106 lines
3.1 KiB
TypeScript
106 lines
3.1 KiB
TypeScript
import { type ReactNode, useContext } from 'react';
|
|
import { styled } from '@linaria/react';
|
|
import { useLingui } from '@lingui/react/macro';
|
|
|
|
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
|
import { isHiddenSystemField } from '@/object-metadata/utils/isHiddenSystemField';
|
|
import { SettingsItemTypeTag } from '@/settings/components/SettingsItemTypeTag';
|
|
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
|
import {
|
|
SETTINGS_OBJECT_TABLE_ROW_GRID_TEMPLATE_COLUMNS,
|
|
StyledActionTableCell,
|
|
StyledNameTableCell,
|
|
} from '@/settings/data-model/object-details/components/SettingsObjectItemTableRowStyledComponents';
|
|
import { TableCell } from '@/ui/layout/table/components/TableCell';
|
|
import { useIcons } from 'twenty-ui/display';
|
|
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
|
|
|
|
export type SettingsObjectMetadataItemTableRowProps = {
|
|
action: ReactNode;
|
|
objectMetadataItem: ObjectMetadataItem;
|
|
link?: string;
|
|
totalObjectCount: number;
|
|
};
|
|
|
|
const StyledNameContainer = styled.div`
|
|
display: flex;
|
|
align-items: center;
|
|
flex: 1;
|
|
min-width: 0;
|
|
gap: ${themeCssVariables.spacing[1]};
|
|
`;
|
|
|
|
const StyledNameLabel = styled.div`
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
`;
|
|
|
|
const StyledInactiveLabel = styled.span`
|
|
color: ${themeCssVariables.font.color.extraLight};
|
|
font-size: ${themeCssVariables.font.size.sm};
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
flex: 0 999 auto;
|
|
min-width: 48px;
|
|
|
|
&::before {
|
|
content: '·';
|
|
margin-right: ${themeCssVariables.spacing[1]};
|
|
}
|
|
`;
|
|
|
|
export const SettingsObjectMetadataItemTableRow = ({
|
|
action,
|
|
objectMetadataItem,
|
|
link,
|
|
totalObjectCount,
|
|
}: SettingsObjectMetadataItemTableRowProps) => {
|
|
const { theme } = useContext(ThemeContext);
|
|
const { t } = useLingui();
|
|
|
|
const { getIcon } = useIcons();
|
|
const Icon = getIcon(objectMetadataItem.icon);
|
|
|
|
return (
|
|
<TableRow
|
|
gridTemplateColumns={SETTINGS_OBJECT_TABLE_ROW_GRID_TEMPLATE_COLUMNS}
|
|
key={objectMetadataItem.namePlural}
|
|
to={link}
|
|
>
|
|
<StyledNameTableCell>
|
|
{!!Icon && (
|
|
<Icon
|
|
style={{
|
|
minWidth: theme.icon.size.md,
|
|
}}
|
|
size={theme.icon.size.md}
|
|
stroke={theme.icon.stroke.sm}
|
|
/>
|
|
)}
|
|
<StyledNameContainer>
|
|
<StyledNameLabel title={objectMetadataItem.labelPlural}>
|
|
{objectMetadataItem.labelPlural}
|
|
</StyledNameLabel>
|
|
{!objectMetadataItem.isActive && (
|
|
<StyledInactiveLabel>{t`Deactivated`}</StyledInactiveLabel>
|
|
)}
|
|
</StyledNameContainer>
|
|
</StyledNameTableCell>
|
|
<TableCell>
|
|
<SettingsItemTypeTag item={objectMetadataItem} />
|
|
</TableCell>
|
|
<TableCell align="right">
|
|
{
|
|
objectMetadataItem.fields.filter(
|
|
(field) => !isHiddenSystemField(field),
|
|
).length
|
|
}
|
|
</TableCell>
|
|
<TableCell align="right">{totalObjectCount}</TableCell>
|
|
<StyledActionTableCell>{action}</StyledActionTableCell>
|
|
</TableRow>
|
|
);
|
|
};
|