From 2890b8eaf9047e51e18824c0f5f585301e414ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Arag=C3=A3o?= Date: Sat, 21 May 2022 23:26:32 -0300 Subject: [PATCH] Fix false usage of themeMap --- src/internals/constants.js | 24 ++++++++++++------------ src/internals/index.js | 2 ++ src/internals/utils.js | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/internals/constants.js b/src/internals/constants.js index d2e4e92..d32c737 100644 --- a/src/internals/constants.js +++ b/src/internals/constants.js @@ -102,18 +102,18 @@ export const BORDER_STYLE_PROPERTIES = { }; export const DEFAULT_THEME_MAP = { - borderStyles: BORDER_STYLE_PROPERTIES, - borderWidths: BORDER_WIDTH_PROPERTIES, - colors: COLOR_PROPERTIES, - fonts: FONT_PROPERTIES, - fontSizes: FONT_SIZE_PROPERTIES, - fontWeights: FONT_WEIGHT_PROPERTIES, - letterSpacings: LETTER_SPACING_PROPERTIES, - lineHeights: LINE_HEIGHT_PROPERTIES, - radii: RADII_PROPERTIES, - sizes: SIZE_PROPERTIES, - space: SPACE_PROPERTIES, - zIndices: Z_INDEX_PROPERTIES, + ...BORDER_STYLE_PROPERTIES, + ...BORDER_WIDTH_PROPERTIES, + ...COLOR_PROPERTIES, + ...FONT_PROPERTIES, + ...FONT_SIZE_PROPERTIES, + ...FONT_WEIGHT_PROPERTIES, + ...LETTER_SPACING_PROPERTIES, + ...LINE_HEIGHT_PROPERTIES, + ...RADII_PROPERTIES, + ...SIZE_PROPERTIES, + ...SPACE_PROPERTIES, + ...Z_INDEX_PROPERTIES, }; const THEME_VALUES = { diff --git a/src/internals/index.js b/src/internals/index.js index 6326af0..5abbde5 100644 --- a/src/internals/index.js +++ b/src/internals/index.js @@ -21,6 +21,8 @@ const ReactNative = require('react-native'); /** @type {CreateStitches} */ export function createStitches(config = {}) { const themes = []; + + config.themeMap = utils.processThemeMap(config.themeMap || constants.DEFAULT_THEME_MAP); if (config.theme) { const processedTheme = utils.processTheme(config.theme); diff --git a/src/internals/utils.js b/src/internals/utils.js index b3402f0..a876946 100644 --- a/src/internals/utils.js +++ b/src/internals/utils.js @@ -58,6 +58,20 @@ export function resolveMediaRangeQuery(query, windowWidth) { return result; } +export function processThemeMap(themeMap) { + const definition = {}; + + Object.keys(themeMap).forEach(token => { + const scale = themeMap[token]; + + if (!definition[scale]) definition[scale] = {}; + + definition[scale][token] = scale; + }); + + return definition; +} + export function processTheme(theme) { const definition = {}; const values = {};