Skip to content

Infra/ Move all colors and DesignTokens to public #1848

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

Merged
merged 3 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions generatedTypes/src/incubator/TextField/usePreset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
purple60?: boolean | undefined;
purple70?: boolean | undefined;
purple80?: boolean | undefined;
violet1?: boolean | undefined;
violet5?: boolean | undefined;
violet10?: boolean | undefined;
violet20?: boolean | undefined;
violet30?: boolean | undefined;
Expand All @@ -361,7 +363,9 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
violet60?: boolean | undefined;
violet70?: boolean | undefined;
violet80?: boolean | undefined;
dmBlack?: boolean | undefined;
$backgroundDefault?: boolean | undefined;
$backgroundElevated?: boolean | undefined;
$backgroundNeutralHeavy?: boolean | undefined;
$backgroundNeutralIdle?: boolean | undefined;
$backgroundNeutralMedium?: boolean | undefined;
Expand Down Expand Up @@ -759,6 +763,8 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
purple60?: boolean | undefined;
purple70?: boolean | undefined;
purple80?: boolean | undefined;
violet1?: boolean | undefined;
violet5?: boolean | undefined;
violet10?: boolean | undefined;
violet20?: boolean | undefined;
violet30?: boolean | undefined;
Expand All @@ -767,7 +773,9 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
violet60?: boolean | undefined;
violet70?: boolean | undefined;
violet80?: boolean | undefined;
dmBlack?: boolean | undefined;
$backgroundDefault?: boolean | undefined;
$backgroundElevated?: boolean | undefined;
$backgroundNeutralHeavy?: boolean | undefined;
$backgroundNeutralIdle?: boolean | undefined;
$backgroundNeutralMedium?: boolean | undefined;
Expand Down
22 changes: 18 additions & 4 deletions generatedTypes/src/style/colors.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export declare class Colors {
* scheme - color scheme e.g light/dark/default
*/
setScheme(scheme: SchemeType): void;
/**
* Support listening to Appearance changes
* and change the design tokens accordingly
*/
supportDarkMode(): void;
/**
* Add alpha to hex or rgb color
* arguments:
Expand Down Expand Up @@ -105,13 +110,14 @@ declare const colorObject: Colors & {
orange10: string;
orange20: string;
orange30: string;
orange40: string; /**
orange40: string;
orange50: string;
orange60: string;
/**
* Set color scheme for app
* arguments:
* scheme - color scheme e.g light/dark/default
*/
orange50: string;
orange60: string;
orange70: string;
orange80: string;
red1: string;
Expand All @@ -134,6 +140,8 @@ declare const colorObject: Colors & {
purple60: string;
purple70: string;
purple80: string;
violet1: string;
violet5: string;
violet10: string;
violet20: string;
violet30: string;
Expand All @@ -144,11 +152,13 @@ declare const colorObject: Colors & {
violet80: string;
white: string;
black: string;
dmBlack: string;
transparent: string;
} & {
primary: string;
} & {
$backgroundDefault: string;
$backgroundElevated: string;
$backgroundNeutralHeavy: string;
$backgroundNeutralIdle: string;
$backgroundNeutralMedium: string;
Expand All @@ -163,7 +173,11 @@ declare const colorObject: Colors & {
$backgroundSuccessHeavy: string;
$backgroundSuccess: string;
$backgroundWarningHeavy: string;
$backgroundWarning: string;
$backgroundWarning: string; /**
* Load set of schemes for light/dark mode
* arguments:
* schemes - two sets of map of colors e.g {light: {screen: 'white'}, dark: {screen: 'black'}}
*/
$backgroundMajor: string;
$backgroundDangerHeavy: string;
$backgroundDanger: string;
Expand Down
3 changes: 3 additions & 0 deletions generatedTypes/src/style/colorsPalette.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ declare const colorsPalette: {
purple60: string;
purple70: string;
purple80: string;
violet1: string;
violet5: string;
violet10: string;
violet20: string;
violet30: string;
Expand All @@ -87,6 +89,7 @@ declare const colorsPalette: {
violet80: string;
white: string;
black: string;
dmBlack: string;
transparent: string;
};
declare const extraFixColorsMap: {
Expand Down
1 change: 1 addition & 0 deletions generatedTypes/src/style/designTokens.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export declare const designTokens: {
$backgroundDefault: string;
$backgroundElevated: string;
$backgroundNeutralHeavy: string;
$backgroundNeutralIdle: string;
$backgroundNeutralMedium: string;
Expand Down
59 changes: 59 additions & 0 deletions generatedTypes/src/style/designTokensDM.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export declare const designTokensDM: {
$backgroundDefault: string;
$backgroundElevated: string;
$backgroundNeutralHeavy: string;
$backgroundNeutralIdle: string;
$backgroundNeutralMedium: string;
$backgroundNeutral: string;
$backgroundNeutralLight: string;
$backgroundPrimaryHeavy: string;
$backgroundPrimaryLight: string;
$backgroundPrimary: string;
$backgroundGeneralHeavy: string;
$backgroundGeneralLight: string;
$backgroundGeneral: string;
$backgroundSuccessHeavy: string;
$backgroundSuccess: string;
$backgroundWarningHeavy: string;
$backgroundWarning: string;
$backgroundMajor: string;
$backgroundDangerHeavy: string;
$backgroundDanger: string;
$backgroundDisabled: string;
$backgroundDark: string;
$textDisabled: string;
$textDefault: string;
$textNeutralHeavy: string;
$textNeutral: string;
$textNeutralLight: string;
$textDefaultLight: string;
$textPrimary: string;
$textGeneral: string;
$textSuccess: string;
$textMajor: string;
$textDanger: string;
$textDangerLight: string;
$iconDefault: string;
$iconNeutral: string;
$iconDefaultLight: string;
$iconPrimary: string;
$iconPrimaryLight: string;
$iconGeneral: string;
$iconGeneralLight: string;
$iconSuccess: string;
$iconSuccessLight: string;
$iconMajor: string;
$iconDanger: string;
$iconDangerLight: string;
$iconDisabled: string;
$outlineLight: string;
$outlineNeutral: string;
$outlineNeutralMedium: string;
$outlineDisabled: string;
$outlineDisabledHeavy: string;
$outlinePrimary: string;
$outlineGeneral: string;
$outlineWarning: string;
$outlineDanger: string;
$dividerDefault: string;
};
10 changes: 10 additions & 0 deletions src/style/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Color from 'color';
import tinycolor from 'tinycolor2';
import {colorsPalette, themeColors} from './colorsPalette';
import {designTokens} from './designTokens';
import {designTokensDM} from './designTokensDM';
//@ts-ignore
import ColorName from './colorName';
import Scheme, {Schemes, SchemeType} from './scheme';
Expand Down Expand Up @@ -55,6 +56,15 @@ export class Colors {
Scheme.setScheme(scheme);
}

/**
* Support listening to Appearance changes
* and change the design tokens accordingly
*/
supportDarkMode() {
const designTokensColors = Scheme.getSchemeType() === 'dark' ? designTokensDM : designTokens;
Object.assign(this, designTokensColors);
}

/**
* Add alpha to hex or rgb color
* arguments:
Expand Down
7 changes: 5 additions & 2 deletions src/style/colorsPalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const colorsPalette = {
blue30: '#116DFF',
blue40: '#3582FF',
blue50: '#60A1FF',
blue60: '#8BC1FF',
blue70: '#B8D9FF',
blue60: '#97C7FF',
blue70: '#C4DFFF',
blue80: '#E9F3FF',
// CYANS
cyan10: '#00AAAF',
Expand Down Expand Up @@ -86,6 +86,8 @@ const colorsPalette = {
purple70: '#f1daf7',
purple80: '#faebfd',
// VIOLETS
violet1: '#170E5C',
violet5: '#231690',
Comment on lines +89 to +90
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where are these from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alexey generated them :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I did not see them in the docs 🤷‍♂️

violet10: '#3220CD',
violet20: '#4633E9',
violet30: '#5A48F5',
Expand All @@ -97,6 +99,7 @@ const colorsPalette = {
// WHITE,
white: '#FFFFFF',
black: '#000000',
dmBlack: '#0A0E12',
transparent: 'transparent'
};

Expand Down
1 change: 1 addition & 0 deletions src/style/designTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {colorsPalette} from './colorsPalette';
export const designTokens = {
// BACKGROUND
$backgroundDefault: colorsPalette.white,
$backgroundElevated: colorsPalette.white,
$backgroundNeutralHeavy: colorsPalette.grey20,
$backgroundNeutralIdle: colorsPalette.grey40,
$backgroundNeutralMedium: colorsPalette.grey60,
Expand Down
70 changes: 70 additions & 0 deletions src/style/designTokensDM.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {colorsPalette} from './colorsPalette';

export const designTokensDM = {
// BACKGROUND
$backgroundDefault: colorsPalette.dmBlack,
$backgroundElevated: colorsPalette.grey10,
$backgroundNeutralHeavy: colorsPalette.grey50,
$backgroundNeutralIdle: colorsPalette.grey30,
$backgroundNeutralMedium: colorsPalette.grey10,
$backgroundNeutral: colorsPalette.grey5,
$backgroundNeutralLight: colorsPalette.grey1,
$backgroundPrimaryHeavy: colorsPalette.violet50,
$backgroundPrimaryLight: colorsPalette.violet5,
$backgroundPrimary: colorsPalette.violet1,
$backgroundGeneralHeavy: colorsPalette.blue50,
$backgroundGeneralLight: colorsPalette.blue5,
$backgroundGeneral: colorsPalette.blue1,
$backgroundSuccessHeavy: colorsPalette.green40,
$backgroundSuccess: colorsPalette.green1,
$backgroundWarningHeavy: colorsPalette.yellow40,
$backgroundWarning: colorsPalette.yellow5,
$backgroundMajor: colorsPalette.orange1,
$backgroundDangerHeavy: colorsPalette.red40,
$backgroundDanger: colorsPalette.red1,
$backgroundDisabled: colorsPalette.grey20,
$backgroundDark: colorsPalette.grey10,

// TEXT
$textDisabled: colorsPalette.grey20,
$textDefault: colorsPalette.grey60,
$textNeutralHeavy: colorsPalette.grey50,
$textNeutral: colorsPalette.grey40,
$textNeutralLight: colorsPalette.grey30,
$textDefaultLight: colorsPalette.black,
$textPrimary: colorsPalette.violet50,
$textGeneral: colorsPalette.blue50,
$textSuccess: colorsPalette.green60,
$textMajor: colorsPalette.orange60,
$textDanger: colorsPalette.red60,
$textDangerLight: colorsPalette.red40,

// ICON
$iconDefault: colorsPalette.grey60,
$iconNeutral: colorsPalette.grey50,
$iconDefaultLight: colorsPalette.black,
$iconPrimary: colorsPalette.violet50,
$iconPrimaryLight: colorsPalette.violet30,
$iconGeneral: colorsPalette.blue50,
$iconGeneralLight: colorsPalette.blue30,
$iconSuccess: colorsPalette.green60,
$iconSuccessLight: colorsPalette.green30,
$iconMajor: colorsPalette.orange60,
$iconDanger: colorsPalette.red60,
$iconDangerLight: colorsPalette.red30,
$iconDisabled: colorsPalette.grey20,

// OUTLINE
$outlineLight: colorsPalette.grey70,
$outlineNeutral: colorsPalette.grey10,
$outlineNeutralMedium: colorsPalette.grey20,
$outlineDisabled: colorsPalette.grey20,
$outlineDisabledHeavy: colorsPalette.grey40,
$outlinePrimary: colorsPalette.violet50,
$outlineGeneral: colorsPalette.blue50,
$outlineWarning: colorsPalette.yellow40,
$outlineDanger: colorsPalette.red40,

// DIVIDER
$dividerDefault: colorsPalette.grey10
};