Files
twenty/packages/twenty-front/src/modules/billing/components/internal/SubscriptionInfoRowContainer.tsx
T
Charles Bochet 647c32ff3e Deprecate runtime theme objects in favor of CSS variables (#18402)
## 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'` |
2026-03-05 14:39:01 +01:00

70 lines
1.8 KiB
TypeScript

import { type IconComponent } from 'twenty-ui/display';
import React, { useContext } from 'react';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
type SubscriptionInfoRowContainerProps = {
Icon: IconComponent;
label: string;
currentValue: React.ReactNode;
nextValue?: React.ReactNode;
};
const StyledContainer = styled.div`
align-items: center;
gap: ${themeCssVariables.spacing[1]};
color: ${themeCssVariables.font.color.primary};
display: grid;
grid-template-columns: repeat(3, 1fr);
`;
const StyledIconLabelContainer = styled.div`
align-items: center;
gap: ${themeCssVariables.spacing[1]};
color: ${themeCssVariables.font.color.tertiary};
display: flex;
`;
const StyledLabelContainer = styled.div`
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
`;
const StyledHeaderText = styled.div`
color: ${themeCssVariables.font.color.tertiary};
font-size: ${themeCssVariables.font.size.sm};
`;
export const SubscriptionInfoHeaderRow = ({ show }: { show: boolean }) => {
if (!show) return null;
return (
<StyledContainer>
<div />
<StyledHeaderText>{t`Current`}</StyledHeaderText>
<StyledHeaderText>{t`Next`}</StyledHeaderText>
</StyledContainer>
);
};
export const SubscriptionInfoRowContainer = ({
Icon,
label,
currentValue,
nextValue,
}: SubscriptionInfoRowContainerProps) => {
const { theme } = useContext(ThemeContext);
return (
<StyledContainer>
<StyledIconLabelContainer>
<Icon size={theme.icon.size.md} />
<StyledLabelContainer>{label}</StyledLabelContainer>
</StyledIconLabelContainer>
{currentValue}
<div>{nextValue ?? ''}</div>
</StyledContainer>
);
};