Skip to content

Commit 3bab586

Browse files
committed
export DesignTokens and DesignTokensDM (#1931)
1 parent 67cc904 commit 3bab586

File tree

10 files changed

+25
-26
lines changed

10 files changed

+25
-26
lines changed

generatedTypes/src/commons/modifiers.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import _ from 'lodash';
2+
import { DesignTokens } from '../style';
23
import { BorderRadiusesLiterals } from '../style/borderRadiuses';
34
import TypographyPresets from '../style/typographyPresets';
45
import { colorsPalette } from '../style/colorsPalette';
5-
import { designTokens } from '../style/designTokens';
66
export declare const FLEX_KEY_PATTERN: RegExp;
77
export declare const PADDING_KEY_PATTERN: RegExp;
88
export declare const MARGIN_KEY_PATTERN: RegExp;
@@ -56,7 +56,7 @@ export declare type MarginLiterals = keyof typeof MARGIN_VARIATIONS;
5656
export declare type NativeMarginModifierKeyType = typeof MARGIN_VARIATIONS[MarginLiterals];
5757
export declare type FlexLiterals = keyof typeof STYLE_KEY_CONVERTERS;
5858
export declare type NativeFlexModifierKeyType = typeof STYLE_KEY_CONVERTERS[FlexLiterals];
59-
export declare type ColorLiterals = keyof (typeof colorsPalette & typeof designTokens);
59+
export declare type ColorLiterals = keyof (typeof colorsPalette & typeof DesignTokens);
6060
export declare type TypographyLiterals = keyof typeof TypographyPresets;
6161
export declare type BorderRadiusLiterals = keyof typeof BorderRadiusesLiterals;
6262
export declare type AlignmentLiterals = 'row' | 'spread' | 'center' | 'centerH' | 'centerV' | 'left' | 'right' | 'top' | 'bottom';

generatedTypes/src/style/colors.d.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ declare const colorObject: Colors & {
117117
orange50: string;
118118
orange60: string;
119119
orange70: string;
120-
orange80: string; /**
121-
* Set color scheme for app
122-
* arguments:
123-
* scheme - color scheme e.g light/dark/default
124-
*/
120+
orange80: string;
125121
red1: string;
126122
red5: string;
127123
red10: string;
@@ -130,6 +126,10 @@ declare const colorObject: Colors & {
130126
red40: string;
131127
red50: string;
132128
red60: string;
129+
/**
130+
* Support listening to Appearance changes
131+
* and change the design tokens accordingly
132+
*/
133133
red70: string;
134134
red80: string;
135135
purple1: string;
@@ -142,8 +142,7 @@ declare const colorObject: Colors & {
142142
purple60: string;
143143
purple70: string;
144144
purple80: string;
145-
violet1: string;
146-
/**
145+
violet1: string; /**
147146
* Add alpha to hex or rgb color
148147
* arguments:
149148
* p1 - hex color / R part of RGB
@@ -195,11 +194,6 @@ declare const colorObject: Colors & {
195194
$textDisabled: string;
196195
$textDefault: string;
197196
$textNeutralHeavy: string;
198-
/**
199-
* Set color scheme for app
200-
* arguments:
201-
* scheme - color scheme e.g light/dark/default
202-
*/
203197
$textNeutral: string;
204198
$textNeutralLight: string;
205199
$textDefaultLight: string;

generatedTypes/src/style/designTokens.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export declare const designTokens: {
1+
declare const _default: {
22
$backgroundDefault: string;
33
$backgroundElevated: string;
44
$backgroundNeutralHeavy: string;
@@ -60,3 +60,4 @@ export declare const designTokens: {
6060
$outlineDanger: string;
6161
$dividerDefault: string;
6262
};
63+
export default _default;

generatedTypes/src/style/designTokensDM.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export declare const designTokensDM: {
1+
declare const _default: {
22
$backgroundDefault: string;
33
$backgroundElevated: string;
44
$backgroundNeutralHeavy: string;
@@ -60,3 +60,4 @@ export declare const designTokensDM: {
6060
$outlineDanger: string;
6161
$dividerDefault: string;
6262
};
63+
export default _default;

generatedTypes/src/style/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export { default as Colors } from './colors';
2+
export { default as DesignTokens } from './designTokens';
3+
export { default as DesignTokensDM } from './designTokensDM';
24
export { default as Scheme, SchemeType, Schemes, SchemeChangeListener } from './scheme';
35
export { default as Typography } from './typography';
46
export { default as BorderRadiuses } from './borderRadiuses';

src/commons/modifiers.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import _ from 'lodash';
22
import {StyleSheet} from 'react-native';
3-
import {Typography, Colors, Scheme, BorderRadiuses, Spacings, ThemeManager} from '../style';
3+
import {Typography, Colors, Scheme, DesignTokens, BorderRadiuses, Spacings, ThemeManager} from '../style';
44
import {BorderRadiusesLiterals} from '../style/borderRadiuses';
55
import TypographyPresets from '../style/typographyPresets';
66
import {SpacingLiterals} from '../style/spacings';
77
import {colorsPalette} from '../style/colorsPalette';
8-
import {designTokens} from '../style/designTokens';
98
export const FLEX_KEY_PATTERN = /^flex(G|S)?(-\d*)?$/;
109
export const PADDING_KEY_PATTERN = new RegExp(`padding[LTRBHV]?-([0-9]*|${Spacings.getKeysPattern()})`);
1110
export const MARGIN_KEY_PATTERN = new RegExp(`margin[LTRBHV]?-([0-9]*|${Spacings.getKeysPattern()})`);
@@ -65,7 +64,7 @@ export type MarginLiterals = keyof typeof MARGIN_VARIATIONS;
6564
export type NativeMarginModifierKeyType = typeof MARGIN_VARIATIONS[MarginLiterals];
6665
export type FlexLiterals = keyof typeof STYLE_KEY_CONVERTERS;
6766
export type NativeFlexModifierKeyType = typeof STYLE_KEY_CONVERTERS[FlexLiterals];
68-
export type ColorLiterals = keyof (typeof colorsPalette & typeof designTokens);
67+
export type ColorLiterals = keyof (typeof colorsPalette & typeof DesignTokens);
6968
export type TypographyLiterals = keyof typeof TypographyPresets;
7069
export type BorderRadiusLiterals = keyof typeof BorderRadiusesLiterals;
7170
export type AlignmentLiterals =

src/style/colors.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import _ from 'lodash';
33
import Color from 'color';
44
import tinycolor from 'tinycolor2';
55
import {colorsPalette, themeColors} from './colorsPalette';
6-
import {designTokens} from './designTokens';
7-
import {designTokensDM} from './designTokensDM';
6+
import DesignTokens from './designTokens';
7+
import DesignTokensDM from './designTokensDM';
88
//@ts-ignore
99
import ColorName from './colorName';
1010
import Scheme, {Schemes, SchemeType} from './scheme';
@@ -14,7 +14,7 @@ export class Colors {
1414
private shouldSupportDarkMode = false;
1515

1616
constructor() {
17-
const colors = Object.assign(colorsPalette, designTokens, themeColors);
17+
const colors = Object.assign(colorsPalette, DesignTokens, themeColors);
1818
Object.assign(this, colors);
1919

2020
Scheme.addChangeListener(() => {
@@ -62,7 +62,7 @@ export class Colors {
6262
* and change the design tokens accordingly
6363
*/
6464
supportDarkMode() {
65-
const designTokensColors = Scheme.getSchemeType() === 'dark' ? designTokensDM : designTokens;
65+
const designTokensColors = Scheme.getSchemeType() === 'dark' ? DesignTokensDM : DesignTokens;
6666
this.shouldSupportDarkMode = true;
6767
Object.assign(this, designTokensColors);
6868
}
@@ -274,7 +274,7 @@ function threeDigitHexToSix(value: string) {
274274

275275
const TypedColors = Colors as ExtendTypeWith<
276276
typeof Colors,
277-
typeof colorsPalette & typeof themeColors & typeof designTokens
277+
typeof colorsPalette & typeof themeColors & typeof DesignTokens
278278
>;
279279
const colorObject = new TypedColors();
280280
colorObject.loadColors(colorsPalette);

src/style/designTokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {colorsPalette} from './colorsPalette';
22

3-
export const designTokens = {
3+
export default {
44
// BACKGROUND
55
$backgroundDefault: colorsPalette.white,
66
$backgroundElevated: colorsPalette.white,

src/style/designTokensDM.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {colorsPalette} from './colorsPalette';
22

3-
export const designTokensDM = {
3+
export default {
44
// BACKGROUND
55
$backgroundDefault: colorsPalette.dmBlack,
66
$backgroundElevated: colorsPalette.grey10,

src/style/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export {default as Colors} from './colors';
2+
export {default as DesignTokens} from './designTokens';
3+
export {default as DesignTokensDM} from './designTokensDM';
24
export {default as Scheme, SchemeType, Schemes, SchemeChangeListener} from './scheme';
35
export {default as Typography} from './typography';
46
export {default as BorderRadiuses} from './borderRadiuses';

0 commit comments

Comments
 (0)