Skip to content

Commit

Permalink
Fix false usage of themeMap
Browse files Browse the repository at this point in the history
  • Loading branch information
alexaragao committed May 22, 2022
1 parent f555d71 commit 2890b8e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/internals/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions src/internals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions src/internals/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down

0 comments on commit 2890b8e

Please sign in to comment.