Skip to content

Commit

Permalink
Merge pull request #1110 from VKCOM/qurle/feat/lego-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
SevereCloud authored Dec 11, 2024
2 parents 1133a87 + f426727 commit f8ee652
Show file tree
Hide file tree
Showing 14 changed files with 32,280 additions and 16 deletions.
30,738 changes: 30,738 additions & 0 deletions src/build/__snapshots__/snapthots.test.ts.snap

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/interfaces/themes/legoAndroid/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ThemeCssVars } from '@/interfaces/general';
import {
ColorDescription,
ColorsDescriptionStruct,
ColorWithStates,
} from '@/interfaces/general/colors';
import {
LocalVkontakteAndroidColorsDescriptionStruct,
ThemeVkontakteAndroid,
ThemeVkontakteAndroidDescription,
} from '@/interfaces/themes/vkontakteAndroid';

// Описание локальных цветов
export interface LocalLegoAndroidColorsDescriptionStruct {
colorStrokePrimary: ColorDescription;
}

// Резолв локальных цветов
export type LegoAndroidLocalColors = {
[key in keyof LocalLegoAndroidColorsDescriptionStruct]: ColorWithStates;
};

// Эскпорт интерфейсов описанной + наследованной темы
export interface ThemeLegoAndroid extends ThemeVkontakteAndroid, LegoAndroidLocalColors {}
export interface ThemeLegoAndroidDescription extends ThemeVkontakteAndroidDescription {
colors: LocalLegoAndroidColorsDescriptionStruct &
LocalVkontakteAndroidColorsDescriptionStruct &
ColorsDescriptionStruct;
}
export interface ThemeLegoAndroidCssVars extends ThemeCssVars<ThemeLegoAndroid> {}
6 changes: 6 additions & 0 deletions src/interfaces/themes/legoAndroidDark/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Реэкспорт интерфейсов, так как набор переменных в тёмной теме такой же
export {
ThemeLegoAndroid as ThemeLegoAndroidDark,
ThemeLegoAndroidCssVars as ThemeLegoAndroidDarkCssVars,
ThemeLegoAndroidDescription as ThemeLegoAndroidDarkDescription,
} from '@/interfaces/themes/legoAndroid';
24 changes: 24 additions & 0 deletions src/interfaces/themes/legoIOS/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ThemeCssVars } from '@/interfaces/general';
import {
ColorDescription,
ColorsDescriptionStruct,
ColorWithStates,
} from '@/interfaces/general/colors';
import { ThemeVkIOS, ThemeVkIOSDescription } from '@/interfaces/themes/vkIOS';

// Описание локальных цветов
export interface LocalLegoIOSColorsDescriptionStruct {
colorStrokePrimary: ColorDescription;
}

// Резолв локальных цветов
export type LegoIOSLocalColors = {
[key in keyof LocalLegoIOSColorsDescriptionStruct]: ColorWithStates;
};

// Эскпорт интерфейсов описанной + наследованной темы
export interface ThemeLegoIOS extends ThemeVkIOS, LegoIOSLocalColors {}
export interface ThemeLegoIOSDescription extends ThemeVkIOSDescription {
colors: LocalLegoIOSColorsDescriptionStruct & ColorsDescriptionStruct;
}
export interface ThemeLegoIOSCssVars extends ThemeCssVars<ThemeLegoIOS> {}
5 changes: 5 additions & 0 deletions src/interfaces/themes/legoIOSDark/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {
ThemeLegoIOS as ThemeLegoIOSDark,
ThemeLegoIOSCssVars as ThemeLegoIOSDarkCssVars,
ThemeLegoIOSDescription as ThemeLegoIOSDarkDescription,
} from '@/interfaces/themes/legoIOS';
12 changes: 4 additions & 8 deletions src/interfaces/themes/vkontakteIOS/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
ThemeVkontakteAndroid,
ThemeVkontakteAndroidCssVars,
ThemeVkontakteAndroidDescription,
export {
ThemeVkontakteAndroid as ThemeVkontakteIOS,
ThemeVkontakteAndroidCssVars as ThemeVkontakteIOSCssVars,
ThemeVkontakteAndroidDescription as ThemeVkontakteIOSDescription,
} from '@/interfaces/themes/vkontakteAndroid';

export type ThemeVkontakteIOS = ThemeVkontakteAndroid;
export type ThemeVkontakteIOSDescription = ThemeVkontakteAndroidDescription;
export type ThemeVkontakteIOSCssVars = ThemeVkontakteAndroidCssVars;
12 changes: 4 additions & 8 deletions src/interfaces/themes/vkontakteIOSDark/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
ThemeVkontakteIOS,
ThemeVkontakteIOSCssVars,
ThemeVkontakteIOSDescription,
export {
ThemeVkontakteIOS as ThemeVkontakteIOSDark,
ThemeVkontakteIOSCssVars as ThemeVkontakteIOSDarkCssVars,
ThemeVkontakteIOSDescription as ThemeVkontakteIOSDarkDescription,
} from '@/interfaces/themes/vkontakteIOS';

export type ThemeVkontakteIOSDark = ThemeVkontakteIOS;
export type ThemeVkontakteIOSDarkDescription = ThemeVkontakteIOSDescription;
export type ThemeVkontakteIOSDarkCssVars = ThemeVkontakteIOSCssVars;
76 changes: 76 additions & 0 deletions src/lint/__snapshots__/lint.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,82 @@

exports[`lint snapshot 1`] = `
[
"legoAndroid: colors.colorBackgroundAccentThemedAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorBackgroundSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorBackgroundTertiaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorBackgroundContrastSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorTextPrimaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorTextSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorIconMediumAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorIconSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorIconTertiaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorSeparatorPrimaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorImageBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorFieldBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorOverlayPrimary error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorOverlaySecondary error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorAvatarOverlay error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorAvatarOverlayInverseAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorImagePlaceholderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorWriteBarInputBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroid: colors.colorTransparent error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorBackgroundAccentThemedAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorBackgroundSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorBackgroundTertiaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorBackgroundContrastSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorTextPrimaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorTextSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorIconMediumAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorIconSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorIconTertiaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorSeparatorPrimaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorImageBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorFieldBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorOverlayPrimary error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorOverlaySecondary error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorAvatarOverlay error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorAvatarOverlayInverseAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorImagePlaceholderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorWriteBarInputBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoAndroidDark: colors.colorTransparent error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorBackgroundAccentThemedAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorBackgroundSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorBackgroundTertiaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorBackgroundContrastSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorTextPrimaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorTextSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorIconMediumAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorIconSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorIconTertiaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorSeparatorPrimaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorImageBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorFieldBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorOverlayPrimary error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorOverlaySecondary error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorAvatarOverlay error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorAvatarOverlayInverseAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorImagePlaceholderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorWriteBarInputBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOS: colors.colorTransparent error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorBackgroundAccentThemedAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorBackgroundSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorBackgroundTertiaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorBackgroundContrastSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorTextPrimaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorTextSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorIconMediumAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorIconSecondaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorIconTertiaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorSeparatorPrimaryAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorImageBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorFieldBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorOverlayPrimary error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorOverlaySecondary error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorAvatarOverlay error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorAvatarOverlayInverseAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorImagePlaceholderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorWriteBarInputBorderAlpha error: Color token type mismatch: alpha token name but opaque value",
"legoIOSDark: colors.colorTransparent error: Color token type mismatch: alpha token name but opaque value",
"cloud: colors.cloudColorIconTransportThemed error: Color token type mismatch: opaque token name but alpha value",
"cloud: colors.cloudColorIconFinanceThemed error: Color token type mismatch: opaque token name but alpha value",
"cloudDark: colors.cloudColorIconTransportThemed error: Color token type mismatch: opaque token name but alpha value",
Expand Down
6 changes: 6 additions & 0 deletions src/themeDescriptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { callsTheme } from '@/themeDescriptions/themes/calls';
import { cloudDarkTheme, cloudTheme } from '@/themeDescriptions/themes/cloud';
import { dobroDarkTheme, dobroTheme } from '@/themeDescriptions/themes/dobro';
import { homeDarkTheme, homeTheme } from '@/themeDescriptions/themes/home';
import { legoAndroidTheme, legoAndroidThemeDark } from '@/themeDescriptions/themes/lego/android';
import { legoIOSTheme, legoIOSThemeDark } from '@/themeDescriptions/themes/lego/ios';
import { mediaDarkTheme, mediaTheme } from '@/themeDescriptions/themes/media';
import { mycomTheme } from '@/themeDescriptions/themes/mycom';
import {
Expand Down Expand Up @@ -80,6 +82,10 @@ export const themes = [
vkIdOkIOSThemeDark,
tutoriaTheme,
tutoriaDarkTheme,
legoAndroidTheme,
legoAndroidThemeDark,
legoIOSTheme,
legoIOSThemeDark,

// ==== Темы, наследуемые от базовой темы Paradigm ====
// Темы, наследуемые от Octavius
Expand Down
58 changes: 58 additions & 0 deletions src/themeDescriptions/themes/lego/android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { ThemeLegoAndroidDescription } from '@/interfaces/themes/legoAndroid';
import { ThemeLegoAndroidDarkDescription } from '@/interfaces/themes/legoAndroidDark';
import {
vkontakteAndroidTheme,
vkontakteAndroidThemeDark,
} from '@/themeDescriptions/themes/vkontakteAndroid';

import figma from './figma.json';
import { overwriteFromFigmaJSON } from './helpers/overwriteFromFigmaJSON';

export const legoAndroidTheme: ThemeLegoAndroidDescription = {
...vkontakteAndroidTheme, // импорт светлой базовой темы

themeName: 'legoAndroid', // название текущей темы
themeNameBase: 'legoAndroid', // название светлой (базовой) темы
themeInheritsFrom: 'vkontakteAndroid', // название родительской темы

colors: {
// Импорт изначальных токенов
...vkontakteAndroidTheme.colors,
// Переопределение токенов, которые есть в figma.json
...overwriteFromFigmaJSON(vkontakteAndroidTheme.colors, 'appearance', 'light', figma),
// Здесь нужно прописать другие цвета с особыми различиями нейминга
// А также локальные цвета, используемые только в этой теме
// Или цвета, которые не выгружаются из фигмы, но переопределяются в этой теме
colorStrokePrimary: figma.appearance.strokePrimary.light,
},
// Изменённые не-цвета
sizeBasePaddingHorizontal: {
regular: figma.tokens.sizeBasePaddingHorizontal.android,
},
// Фигма использует целые проценты, а не сотые единицы
// Поэтому здесь нужно поделить на 100
// Округление пока не стал писать
opacityDisable: figma.tokens.opacityDisabled.android / 100,
opacityDisableAccessibility: figma.tokens.opacityDisabled.android / 100,
};

export const legoAndroidThemeDark: ThemeLegoAndroidDarkDescription = {
...legoAndroidTheme, // Импорт светлой версии текущей темы,
...vkontakteAndroidThemeDark, // Импорт тёмной базовой темы

themeName: 'legoAndroidDark', // название текущей темы
themeNameBase: 'legoAndroid', // название светлой (базовой) темы
themeInheritsFrom: 'vkontakteAndroidDark', // название родительской темы
colorsScheme: 'dark', // название схемы (светлая — по умолчанию)

colors: {
...vkontakteAndroidThemeDark.colors,
// Переопределение токенов, которые есть в figma.json
// То же самое, что в светлой теме, но ссылаемся на figmaToken.dark вместо light
...overwriteFromFigmaJSON(vkontakteAndroidTheme.colors, 'appearance', 'dark', figma),
// Здесь нужно прописать другие цвета с особыми различиями нейминга
// А также локальные цвета, используемые только в этой теме
// Или цвета, которые не выгружаются из фигмы, но переопределяются в этой теме
colorStrokePrimary: figma.appearance.strokePrimary.dark,
},
};
Loading

0 comments on commit f8ee652

Please sign in to comment.