Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plasma-theme-builder): Actualize default tokens #1127

Merged
merged 9 commits into from
Mar 21, 2024
Merged
71 changes: 61 additions & 10 deletions utils/plasma-tokens-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ export interface ThemeConfig {
light: Grayscale;
dark: Grayscale;
};
opacity: {
textIcons: boolean;
surfaces: boolean;
};
}

export type TextIconsTokenName =
Expand All @@ -165,11 +161,17 @@ export type TextIconsTokenName =
| 'textPositive'
| 'textWarning'
| 'textNegative'
| 'textTransparentAccent'
| 'textTransparentAccentGradient'
| 'textTransparentPositive'
| 'textTransparentWarning'
| 'textTransparentNegative';
| 'textAccentMinor'
| 'textAccentMinorGradient'
| 'textPromo'
| 'textPromoGradient'
| 'textPromoMinor'
| 'textPromoMinorGradient'
| 'textInfo'
| 'textPositiveMinor'
| 'textWarningMinor'
| 'textNegativeMinor'
| 'textInfoMinor';

export type ControlsSurfacesName =
| 'surfaceSolidDefault'
Expand All @@ -192,7 +194,53 @@ export type ControlsSurfacesName =
| 'surfaceTransparentAccentGradient'
| 'surfaceTransparentPositive'
| 'surfaceTransparentWarning'
| 'surfaceTransparentNegative';
| 'surfaceTransparentNegative'
| 'surfaceAccentMinor'
| 'surfaceAccentMinorGradient'
| 'surfacePromo'
| 'surfacePromoGradient'
| 'surfacePromoMinor'
| 'surfacePromoMinorGradient'
| 'surfaceTransparentPromo'
| 'surfaceTransparentPromoGradient'
| 'surfaceInfo'
| 'surfacePositiveMinor'
| 'surfaceWarningMinor'
| 'surfaceNegativeMinor'
| 'surfaceInfoMinor'
| 'surfaceTransparentInfo';

export type OutlineName =
| 'outlineSolidPrimary'
| 'outlineSolidSecondary'
| 'outlineSolidTertiary'
| 'outlineTransparentDefault'
| 'outlineTransparentPrimary'
| 'outlineTransparentSecondary'
| 'outlineTransparentTertiary'
| 'outlineAccent'
| 'outlineAccentGradient'
| 'outlinePositive'
| 'outlineWarning'
| 'outlineNegative'
| 'outlineClear'
| 'outlineTransparentAccent'
| 'outlineTransparentAccentGradient'
| 'outlineTransparentPositive'
| 'outlineTransparentWarning'
| 'outlineTransparentNegative'
| 'outlineAccentMinor'
| 'outlineAccentMinorGradient'
| 'outlinePromo'
| 'outlinePromoGradient'
| 'outlinePromoMinor'
| 'outlinePromoMinorGradient'
| 'outlineInfo'
| 'outlinePositiveMinor'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

интересный нейминиг
то primary / secondary
то _ / minor

=/

| 'outlineWarningMinor'
| 'outlineNegativeMinor'
| 'outlineInfoMinor'
| 'outlineTransparentInfo';

export type BackgroundName = 'backgroundPrimary' | 'backgroundSecondary' | 'backgroundTertiary';

Expand Down Expand Up @@ -277,12 +325,14 @@ export interface Theme {
controlsSurfaces: TokensByType<ControlsSurfacesName>;
backgrounds: TokensBackgroundByType<BackgroundName>;
overlay: TokensByType<OverlayName>;
outline: TokensByType<OutlineName>;
};
light: {
textIcons: TokensByType<TextIconsTokenName>;
controlsSurfaces: TokensByType<ControlsSurfacesName>;
backgrounds: TokensBackgroundByType<BackgroundName>;
overlay: TokensByType<OverlayName>;
outline: TokensByType<OutlineName>;
};
shadow?: Record<string, string>;
borderRadius?: Record<string, string>;
Expand Down Expand Up @@ -313,6 +363,7 @@ export type ActualTokenNames =
| ControlsSurfacesName
| BackgroundName
| OverlayName
| OutlineName
| 'white'
| 'black'
| 'clear'
Expand Down
13 changes: 8 additions & 5 deletions website/plasma-theme-builder/src/builder/createTheme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
OutlineName,
ThemeConfig,
ThemeMode,
TokensBackgroundByType,
Expand All @@ -7,10 +8,11 @@ import type {
} from '@salutejs/plasma-tokens-utils';

import {
textIconsTokenGetters,
controlsSurfacesTokenGetters,
textTokenGetters,
surfaceTokenGetters,
backgroundTokenGetters,
overlayTokenGetters,
outlineTokenGetters,
} from './themeTokenGetters';

import type { TextIconsTokenName, ControlsSurfacesName, BackgroundName, OverlayName } from './themeTokenGetters';
Expand Down Expand Up @@ -92,10 +94,11 @@ const getTokensBackgroundByGroups = <T extends string>(

const getThemeModeTokens = <T extends ThemeMode>(config: ThemeConfig, mode: T): Theme[T] => {
return {
textIcons: getTokensByGroups<TextIconsTokenName>(textIconsTokenGetters, config, mode),
controlsSurfaces: getTokensByGroups<ControlsSurfacesName>(controlsSurfacesTokenGetters, config, mode),
backgrounds: getTokensBackgroundByGroups<BackgroundName>(backgroundTokenGetters, config, mode),
text: getTokensByGroups<TextIconsTokenName>(textTokenGetters, config, mode),
surface: getTokensByGroups<ControlsSurfacesName>(surfaceTokenGetters, config, mode),
background: getTokensBackgroundByGroups<BackgroundName>(backgroundTokenGetters, config, mode),
overlay: getTokensByGroups<OverlayName>(overlayTokenGetters, config, mode),
outline: getTokensByGroups<OutlineName>(outlineTokenGetters, config, mode),
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { ThemeConfig, TokensByType } from '@salutejs/plasma-tokens-utils';
import { getGreyTokenData, tokensCreator } from '../../../utils';

export const getBackgroundPrimaryTokens = (config: ThemeConfig) => {
const { grayscale } = config;

const darkValue = getGreyTokenData({
saturation: 1000,
grayscale: grayscale.dark,
});
const lightValue = getGreyTokenData({
saturation: 50,
grayscale: grayscale.light,
});

const comment: Record<keyof TokensByType, string> = {
default: 'Основной фон',
onDark: 'Основной фон на темном фоне',
onLight: 'Основной фон на светлом фоне',
inverse: 'Инвертированный основной фон',
};

return tokensCreator({ darkValue, lightValue, darkSubGroup: 'dark', lightSubGroup: 'light', comment });
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { TokensByType } from '@salutejs/plasma-tokens-utils';

import { baseColors } from '../../../types';
import { tokensCreator } from '../../../utils';

export const getBackgroundSecondaryTokens = () => {
const darkValue = baseColors.white.value;
const lightValue = baseColors.white.value;

const comment: Record<keyof TokensByType, string> = {
default: 'Вторичный фон',
onDark: 'Вторичный фон на темном фоне',
onLight: 'Вторичный фон на светлом фоне',
inverse: 'Инвертированный вторичный фон',
};

return tokensCreator({
darkValue,
lightValue,
darkSubGroup: 'dark',
lightSubGroup: 'light',
comment,
enabledAll: false,
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { TokensByType } from '@salutejs/plasma-tokens-utils';

import { baseColors } from '../../../types';
import { tokensCreator } from '../../../utils';

export const getBackgroundTertiaryTokens = () => {
const darkValue = baseColors.white.value;
const lightValue = baseColors.white.value;

const comment: Record<keyof TokensByType, string> = {
default: 'Третичный фон',
onDark: 'Третичный фон на темном фоне',
onLight: 'Третичный фон на светлом фоне',
inverse: 'Инвертированный третичный фон',
};

return tokensCreator({
darkValue,
lightValue,
darkSubGroup: 'dark',
lightSubGroup: 'light',
comment,
enabledAll: false,
});
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading