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 |
103 lines
3.5 KiB
TypeScript
103 lines
3.5 KiB
TypeScript
import { styled } from '@linaria/react';
|
|
|
|
import { EventRowActivity } from '@/activities/timeline-activities/rows/activity/components/EventRowActivity';
|
|
import { EventRowCalendarEvent } from '@/activities/timeline-activities/rows/calendar/components/EventRowCalendarEvent';
|
|
import { EventRowMainObject } from '@/activities/timeline-activities/rows/main-object/components/EventRowMainObject';
|
|
import { EventRowMessage } from '@/activities/timeline-activities/rows/message/components/EventRowMessage';
|
|
import { type TimelineActivity } from '@/activities/timeline-activities/types/TimelineActivity';
|
|
import { CoreObjectNameSingular } from 'twenty-shared/types';
|
|
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
|
import { themeCssVariables } from 'twenty-ui/theme-constants';
|
|
|
|
export interface EventRowDynamicComponentProps {
|
|
labelIdentifierValue: string;
|
|
event: TimelineActivity;
|
|
mainObjectMetadataItem: ObjectMetadataItem;
|
|
linkedObjectMetadataItem: ObjectMetadataItem | null;
|
|
authorFullName: string;
|
|
createdAt?: string;
|
|
}
|
|
|
|
export const StyledEventRowItemColumn = styled.div`
|
|
align-items: center;
|
|
color: ${themeCssVariables.font.color.primary};
|
|
display: flex;
|
|
flex-direction: row;
|
|
gap: ${themeCssVariables.spacing[1]};
|
|
`;
|
|
|
|
export const StyledEventRowItemAction = styled.div`
|
|
align-items: center;
|
|
color: ${themeCssVariables.font.color.secondary};
|
|
display: flex;
|
|
flex-direction: row;
|
|
gap: ${themeCssVariables.spacing[1]};
|
|
`;
|
|
|
|
export const EventRowDynamicComponent = ({
|
|
labelIdentifierValue,
|
|
event,
|
|
mainObjectMetadataItem,
|
|
linkedObjectMetadataItem,
|
|
authorFullName,
|
|
createdAt,
|
|
}: EventRowDynamicComponentProps) => {
|
|
switch (linkedObjectMetadataItem?.nameSingular) {
|
|
case 'calendarEvent':
|
|
return (
|
|
<EventRowCalendarEvent
|
|
labelIdentifierValue={labelIdentifierValue}
|
|
event={event}
|
|
mainObjectMetadataItem={mainObjectMetadataItem}
|
|
linkedObjectMetadataItem={linkedObjectMetadataItem}
|
|
authorFullName={authorFullName}
|
|
/>
|
|
);
|
|
case 'message':
|
|
return (
|
|
<EventRowMessage
|
|
labelIdentifierValue={labelIdentifierValue}
|
|
event={event}
|
|
mainObjectMetadataItem={mainObjectMetadataItem}
|
|
linkedObjectMetadataItem={linkedObjectMetadataItem}
|
|
authorFullName={authorFullName}
|
|
/>
|
|
);
|
|
case 'task':
|
|
return (
|
|
<EventRowActivity
|
|
labelIdentifierValue={labelIdentifierValue}
|
|
event={event}
|
|
mainObjectMetadataItem={mainObjectMetadataItem}
|
|
linkedObjectMetadataItem={linkedObjectMetadataItem}
|
|
authorFullName={authorFullName}
|
|
objectNameSingular={CoreObjectNameSingular.Task}
|
|
createdAt={createdAt}
|
|
/>
|
|
);
|
|
case 'note':
|
|
return (
|
|
<EventRowActivity
|
|
labelIdentifierValue={labelIdentifierValue}
|
|
event={event}
|
|
mainObjectMetadataItem={mainObjectMetadataItem}
|
|
linkedObjectMetadataItem={linkedObjectMetadataItem}
|
|
authorFullName={authorFullName}
|
|
objectNameSingular={CoreObjectNameSingular.Note}
|
|
createdAt={createdAt}
|
|
/>
|
|
);
|
|
default:
|
|
return (
|
|
<EventRowMainObject
|
|
labelIdentifierValue={labelIdentifierValue}
|
|
event={event}
|
|
mainObjectMetadataItem={mainObjectMetadataItem}
|
|
linkedObjectMetadataItem={linkedObjectMetadataItem}
|
|
authorFullName={authorFullName}
|
|
createdAt={createdAt}
|
|
/>
|
|
);
|
|
}
|
|
};
|