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'` |
This commit is contained in:
+2
-3
@@ -14,7 +14,7 @@ import { formatToShortNumber } from 'twenty-shared/utils';
|
||||
import { H2Title, HorizontalSeparator } from 'twenty-ui/display';
|
||||
import { ProgressBar } from 'twenty-ui/feedback';
|
||||
import { Section } from 'twenty-ui/layout';
|
||||
import { ThemeContext } from 'twenty-ui/theme';
|
||||
import { ThemeContext } from 'twenty-ui/theme-constants';
|
||||
import { SubscriptionStatus } from '~/generated-metadata/graphql';
|
||||
|
||||
export const SettingsBillingCreditsSection = ({
|
||||
@@ -24,6 +24,7 @@ export const SettingsBillingCreditsSection = ({
|
||||
CurrentWorkspace['currentBillingSubscription']
|
||||
>;
|
||||
}) => {
|
||||
const { theme } = useContext(ThemeContext);
|
||||
const subscriptionStatus = useSubscriptionStatus();
|
||||
const { formatNumber } = useNumberFormat();
|
||||
|
||||
@@ -60,8 +61,6 @@ export const SettingsBillingCreditsSection = ({
|
||||
currentBillingSubscription.interval,
|
||||
);
|
||||
|
||||
const { theme } = useContext(ThemeContext);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Section>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { styled } from '@linaria/react';
|
||||
import React, { useContext } from 'react';
|
||||
import { IconCheck } from 'twenty-ui/display';
|
||||
import { ThemeContext } from 'twenty-ui/theme';
|
||||
import { themeCssVariables } from 'twenty-ui/theme-constants';
|
||||
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
|
||||
|
||||
const StyledBenefitContainer = styled.div`
|
||||
color: ${themeCssVariables.font.color.secondary};
|
||||
@@ -25,6 +24,7 @@ type SubscriptionBenefitProps = {
|
||||
};
|
||||
export const SubscriptionBenefit = ({ children }: SubscriptionBenefitProps) => {
|
||||
const { theme } = useContext(ThemeContext);
|
||||
|
||||
return (
|
||||
<StyledBenefitContainer>
|
||||
<StyledCheckContainer>
|
||||
|
||||
+2
-2
@@ -2,8 +2,7 @@ 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 } from 'twenty-ui/theme';
|
||||
import { themeCssVariables } from 'twenty-ui/theme-constants';
|
||||
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
|
||||
|
||||
type SubscriptionInfoRowContainerProps = {
|
||||
Icon: IconComponent;
|
||||
@@ -56,6 +55,7 @@ export const SubscriptionInfoRowContainer = ({
|
||||
nextValue,
|
||||
}: SubscriptionInfoRowContainerProps) => {
|
||||
const { theme } = useContext(ThemeContext);
|
||||
|
||||
return (
|
||||
<StyledContainer>
|
||||
<StyledIconLabelContainer>
|
||||
|
||||
Reference in New Issue
Block a user