647c32ff3e
## Summary
- **Eliminate `ICON_SIZES` / `ICON_STROKES` constants**: all icon
dimensions are now resolved at runtime via
`resolveThemeVariableAsNumber(themeCssVariables.icon.size.X)`, ensuring
values always come from computed CSS variables
- **No more consumer imports from `twenty-ui/theme`**: moved
`ColorSchemeContext`, `ColorSchemeProvider`, `ThemeColor`,
`MAIN_COLOR_NAMES`, `getNextThemeColor`, `AnimationDuration` to
`twenty-ui/theme-constants`
- **Remove `ThemeContext` / `ThemeContextProvider` / `ThemeProvider` /
`ThemeType`**: replaced across ~300 files with `themeCssVariables` (for
CSS contexts) or `resolveThemeVariable` / `resolveThemeVariableAsNumber`
(for JS runtime values)
- **Simplify provider chain**: only `ColorSchemeProvider` remains — it
toggles `light`/`dark` class on `document.documentElement` and provides
`colorScheme` via React context
- **Fix pre-existing test failures**: `useIcons.test.ts`
(non-configurable ES module spy) and
`turnRecordFilterGroupIntoGqlOperationFilter.test.ts`
(`Omit<RecordFilter, 'id'>` type mismatch)
### Theme access pattern (before → after)
| Context | Before | After |
|---------|--------|-------|
| CSS (Linaria) | `${({ theme }) => theme.font.color.primary}` |
`${themeCssVariables.font.color.primary}` |
| JS runtime (icon size, animation) | `theme.icon.size.md` /
`ICON_SIZES.md` |
`resolveThemeVariableAsNumber(themeCssVariables.icon.size.md)` |
| Color scheme check | `theme.name === 'dark'` |
`useContext(ColorSchemeContext).colorScheme === 'dark'` |
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import { styled } from '@linaria/react';
|
|
import { isDefined } from 'twenty-shared/utils';
|
|
import { themeCssVariables } from '@ui/theme-constants';
|
|
|
|
const StyledLayout = styled.div<{
|
|
width?: number;
|
|
backgroundColor?: string | undefined;
|
|
height: number | 'fit-content';
|
|
}>`
|
|
background: ${({ backgroundColor }) =>
|
|
backgroundColor ?? themeCssVariables.background.primary};
|
|
border: 1px solid ${themeCssVariables.border.color.light};
|
|
border-radius: 5px;
|
|
|
|
display: flex;
|
|
flex-direction: row;
|
|
|
|
height: ${({ height }) =>
|
|
height === 'fit-content'
|
|
? 'fit-content'
|
|
: `
|
|
${height}px
|
|
`};
|
|
max-width: calc(100% - 40px);
|
|
min-width: ${({ width }) => (width ? 'unset' : '300px')};
|
|
padding: 20px;
|
|
width: ${({ width }) => (width ? width + 'px' : 'fit-content')};
|
|
`;
|
|
|
|
type ComponentStorybookLayoutProps = {
|
|
width?: number;
|
|
backgroundColor?: string | undefined;
|
|
height?: number;
|
|
children: JSX.Element;
|
|
};
|
|
|
|
export const ComponentStorybookLayout = ({
|
|
width,
|
|
backgroundColor,
|
|
height,
|
|
children,
|
|
}: ComponentStorybookLayoutProps) => {
|
|
return (
|
|
<StyledLayout
|
|
width={width}
|
|
backgroundColor={backgroundColor}
|
|
height={isDefined(height) ? height : 'fit-content'}
|
|
>
|
|
{children}
|
|
</StyledLayout>
|
|
);
|
|
};
|