From 3fe06d4ed948f06c0783795d915cbdcd0f759113 Mon Sep 17 00:00:00 2001 From: Lidor Dafna Date: Wed, 15 Feb 2023 12:36:07 +0200 Subject: [PATCH 1/3] remove Colors.primary --- src/style/colorsPalette.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/style/colorsPalette.ts b/src/style/colorsPalette.ts index 726b7591c7..4ae7766499 100644 --- a/src/style/colorsPalette.ts +++ b/src/style/colorsPalette.ts @@ -111,8 +111,4 @@ const extraFixColorsMap = { '#fff': 'white' }; -const themeColors = { - primary: colorsPalette.violet30 -}; - -export {colorsPalette, themeColors, extraFixColorsMap}; +export {colorsPalette, extraFixColorsMap}; From abc43cfe77c2df5d1a1705bf19d45bbf20d53813 Mon Sep 17 00:00:00 2001 From: Lidor Dafna Date: Wed, 15 Feb 2023 12:44:39 +0200 Subject: [PATCH 2/3] remove themeColors --- src/style/colors.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/style/colors.ts b/src/style/colors.ts index 0bbf05f4fd..e6b0f47efc 100644 --- a/src/style/colors.ts +++ b/src/style/colors.ts @@ -3,7 +3,7 @@ import _ from 'lodash'; import Color from 'color'; import {OpaqueColorValue} from 'react-native'; import tinycolor from 'tinycolor2'; -import {colorsPalette, themeColors} from './colorsPalette'; +import {colorsPalette} from './colorsPalette'; import DesignTokens from './designTokens'; import DesignTokensDM from './designTokensDM'; //@ts-ignore @@ -20,7 +20,7 @@ export class Colors { private shouldSupportDarkMode = false; constructor() { - const colors = Object.assign(colorsPalette, themeColors); + const colors = Object.assign(colorsPalette); Object.assign(this, colors); this.loadSchemes({light: DesignTokens, dark: DesignTokensDM}); @@ -185,7 +185,7 @@ export class Colors { const shouldReverseOnDark = !options?.avoidReverseOnDark && this.shouldSupportDarkMode && Scheme.getSchemeType() === 'dark'; const key = shouldReverseOnDark ? colorKeys[colorKeys.length - 1 - keyIndex] : tintKey; - + const requiredColorKey = `${colorKey.slice(0, -2)}${key}`; const requiredColorKey1 = `${colorKey.slice(0, -1)}${key}`; const requiredColor = this[requiredColorKey] || this[requiredColorKey1]; @@ -355,10 +355,7 @@ function threeDigitHexToSix(value: string) { return value.replace(/./g, '$&$&'); } -const TypedColors = Colors as ExtendTypeWith< - typeof Colors, - typeof colorsPalette & typeof themeColors & typeof DesignTokens ->; +const TypedColors = Colors as ExtendTypeWith; const colorObject = new TypedColors(); colorObject.loadColors(colorsPalette); export default colorObject; From 9a4dde549d7a919ed53102e21e53e29ca1d5d7aa Mon Sep 17 00:00:00 2001 From: Lidor Dafna Date: Wed, 15 Feb 2023 12:55:56 +0200 Subject: [PATCH 3/3] update test --- src/style/__tests__/colors.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/style/__tests__/colors.spec.js b/src/style/__tests__/colors.spec.js index 4038b3adc2..4804afafa8 100644 --- a/src/style/__tests__/colors.spec.js +++ b/src/style/__tests__/colors.spec.js @@ -212,9 +212,10 @@ describe('style/Colors', () => { }); it('should return undefined for color that does not exist in our colors palette.', () => { + uut.anotherViolet = '#5A48F5'; expect(uut.getSystemColorByHex('#5A48F5')).toEqual('violet30'); expect(uut.getSystemColorByHex('#5A48F5', GetColorsByHexOptions)).toEqual(undefined); - expect(uut.getSystemColorByHex('#5A48F5', {validColors: [...SYSTEM_COLORS, 'primary']})).toEqual('primary'); + expect(uut.getSystemColorByHex('#5A48F5', {validColors: [...SYSTEM_COLORS, 'anotherViolet']})).toEqual('anotherViolet'); }); }); });