@codecademy/variance 0.20.0 → 0.20.1-alpha.32ef98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/core.js +183 -245
  3. package/dist/createTheme/createTheme.js +58 -132
  4. package/dist/createTheme/createTheme.test.js +159 -184
  5. package/dist/createTheme/index.js +2 -1
  6. package/dist/createTheme/types.js +2 -0
  7. package/dist/index.js +2 -1
  8. package/dist/scales/createScale.js +2 -3
  9. package/dist/scales/createScaleLookup.js +13 -23
  10. package/dist/src/core.d.ts +10 -0
  11. package/dist/src/core.js +189 -0
  12. package/dist/src/core.js.map +1 -0
  13. package/dist/src/createTheme/createTheme.test.d.ts +1 -0
  14. package/dist/src/createTheme/createTheme.test.js +167 -0
  15. package/dist/src/createTheme/createTheme.test.js.map +1 -0
  16. package/dist/src/index.d.ts +5 -0
  17. package/dist/src/index.js +6 -0
  18. package/dist/src/index.js.map +1 -0
  19. package/dist/src/utils/__fixtures__/testConfig.d.ts +153 -0
  20. package/dist/src/utils/__fixtures__/testConfig.js +94 -0
  21. package/dist/src/utils/__fixtures__/testConfig.js.map +1 -0
  22. package/dist/transforms/index.js +2 -1
  23. package/dist/transforms/transformSize.js +24 -45
  24. package/dist/types/config.js +2 -0
  25. package/dist/types/properties.js +2 -0
  26. package/dist/types/props.js +2 -0
  27. package/dist/types/theme.js +2 -0
  28. package/dist/types/utils.js +2 -0
  29. package/dist/utils/__fixtures__/testConfig.js +94 -153
  30. package/dist/utils/flattenScale.js +16 -22
  31. package/dist/utils/getStaticProperties.js +2 -5
  32. package/dist/utils/propNames.js +57 -43
  33. package/dist/utils/responsive.js +57 -86
  34. package/dist/utils/serializeTokens.js +30 -39
  35. package/package.json +3 -3
@@ -1,79 +1,41 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6
-
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8
-
9
- function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
10
-
11
- var id = 0;
12
-
13
- function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
14
-
15
1
  import { mapValues, merge } from 'lodash';
16
2
  import { flattenScale } from '../utils/flattenScale';
17
3
  import { serializeTokens } from '../utils/serializeTokens';
18
-
19
- var _theme = _classPrivateFieldLooseKey("theme");
20
-
21
- var ThemeBuilder = /*#__PURE__*/function () {
22
- function ThemeBuilder(baseTheme) {
23
- _classCallCheck(this, ThemeBuilder);
24
-
25
- Object.defineProperty(this, _theme, {
26
- writable: true,
27
- value: {}
28
- });
29
- _classPrivateFieldLooseBase(this, _theme)[_theme] = baseTheme;
30
- }
31
- /**
32
- *
33
- * @param key A key of the current theme to transform into CSS Variables and Variable References
34
- * @example .createScaleVariables('fontSize')
35
- */
36
-
37
-
38
- _createClass(ThemeBuilder, [{
39
- key: "createScaleVariables",
40
- value: function createScaleVariables(key) {
41
- var _merge;
42
-
43
- var _serializeTokens = serializeTokens(_classPrivateFieldLooseBase(this, _theme)[_theme][key], key, _classPrivateFieldLooseBase(this, _theme)[_theme]),
44
- variables = _serializeTokens.variables,
45
- tokens = _serializeTokens.tokens;
46
-
47
- _classPrivateFieldLooseBase(this, _theme)[_theme] = merge({}, _classPrivateFieldLooseBase(this, _theme)[_theme], (_merge = {}, _defineProperty(_merge, key, tokens), _defineProperty(_merge, "_variables", {
48
- root: variables
49
- }), _defineProperty(_merge, "_tokens", _defineProperty({}, key, _classPrivateFieldLooseBase(this, _theme)[_theme][key])), _merge));
50
- return this;
4
+ class ThemeBuilder {
5
+ #theme = {};
6
+ constructor(baseTheme) {
7
+ this.#theme = baseTheme;
8
+ }
9
+ /**
10
+ *
11
+ * @param key A key of the current theme to transform into CSS Variables and Variable References
12
+ * @example .createScaleVariables('fontSize')
13
+ */
14
+ createScaleVariables(key) {
15
+ const { variables, tokens } = serializeTokens(this.#theme[key], key, this.#theme);
16
+ this.#theme = merge({}, this.#theme, {
17
+ [key]: tokens,
18
+ _variables: { root: variables },
19
+ _tokens: {
20
+ [key]: this.#theme[key],
21
+ },
22
+ });
23
+ return this;
51
24
  }
52
25
  /**
53
26
  *
54
27
  * @param colors A map of color tokens to add to the theme. These tokens are immediately converted to CSS Variables `--color-${key}`.
55
28
  * @example .addColors({ navy: 'navy', hyper: 'purple' })
56
29
  */
57
-
58
- }, {
59
- key: "addColors",
60
- value: function addColors(colors) {
61
- var flatColors = flattenScale(colors);
62
-
63
- var _serializeTokens2 = serializeTokens(flatColors, 'color', _classPrivateFieldLooseBase(this, _theme)[_theme]),
64
- variables = _serializeTokens2.variables,
65
- tokens = _serializeTokens2.tokens;
66
-
67
- _classPrivateFieldLooseBase(this, _theme)[_theme] = merge({}, _classPrivateFieldLooseBase(this, _theme)[_theme], {
68
- colors: tokens,
69
- _variables: {
70
- root: variables
71
- },
72
- _tokens: {
73
- colors: flatColors
74
- }
75
- });
76
- return this;
30
+ addColors(colors) {
31
+ const flatColors = flattenScale(colors);
32
+ const { variables, tokens } = serializeTokens(flatColors, 'color', this.#theme);
33
+ this.#theme = merge({}, this.#theme, {
34
+ colors: tokens,
35
+ _variables: { root: variables },
36
+ _tokens: { colors: flatColors },
37
+ });
38
+ return this;
77
39
  }
78
40
  /**
79
41
  *
@@ -81,44 +43,21 @@ var ThemeBuilder = /*#__PURE__*/function () {
81
43
  * @param modes A map of color modes with keys of each possible mode with a value of alias to color keys. This must be called after `addColors`
82
44
  * @example .addColorModes('light', { light: { primary: 'hyper' }, { dark: { primary: 'navy' } } })
83
45
  */
84
-
85
- }, {
86
- key: "addColorModes",
87
- value: function addColorModes(initialMode, modeConfig) {
88
- var _classPrivateFieldLoo,
89
- _this = this;
90
-
91
- var modes = mapValues(modeConfig, function (mode) {
92
- return flattenScale(mode);
93
- });
94
-
95
- var _serializeTokens3 = serializeTokens(mapValues(merge({}, (_classPrivateFieldLoo = _classPrivateFieldLooseBase(this, _theme)[_theme].modes) === null || _classPrivateFieldLoo === void 0 ? void 0 : _classPrivateFieldLoo[initialMode], modes[initialMode]), function (color) {
96
- return _classPrivateFieldLooseBase(_this, _theme)[_theme].colors[color];
97
- }), 'color', _classPrivateFieldLooseBase(this, _theme)[_theme]),
98
- colors = _serializeTokens3.tokens,
99
- variables = _serializeTokens3.variables;
100
-
101
- var getColorValue = function getColorValue(color) {
102
- var _classPrivateFieldLoo2, _classPrivateFieldLoo3;
103
-
104
- return (_classPrivateFieldLoo2 = _classPrivateFieldLooseBase(_this, _theme)[_theme]._tokens) === null || _classPrivateFieldLoo2 === void 0 ? void 0 : (_classPrivateFieldLoo3 = _classPrivateFieldLoo2.colors) === null || _classPrivateFieldLoo3 === void 0 ? void 0 : _classPrivateFieldLoo3[color];
105
- };
106
-
107
- _classPrivateFieldLooseBase(this, _theme)[_theme] = merge({}, _classPrivateFieldLooseBase(this, _theme)[_theme], {
108
- colors: colors,
109
- modes: modes,
110
- mode: initialMode,
111
- _getColorValue: getColorValue,
112
- _variables: {
113
- mode: variables
114
- },
115
- _tokens: {
116
- modes: mapValues(modes, function (mode) {
117
- return mapValues(mode, getColorValue);
118
- })
119
- }
120
- });
121
- return this;
46
+ addColorModes(initialMode, modeConfig) {
47
+ const modes = mapValues(modeConfig, (mode) => flattenScale(mode));
48
+ const { tokens: colors, variables } = serializeTokens(mapValues(merge({}, this.#theme.modes?.[initialMode], modes[initialMode]), (color) => this.#theme.colors[color]), 'color', this.#theme);
49
+ const getColorValue = (color) => this.#theme._tokens?.colors?.[color];
50
+ this.#theme = merge({}, this.#theme, {
51
+ colors,
52
+ modes,
53
+ mode: initialMode,
54
+ _getColorValue: getColorValue,
55
+ _variables: { mode: variables },
56
+ _tokens: {
57
+ modes: mapValues(modes, (mode) => mapValues(mode, getColorValue)),
58
+ },
59
+ });
60
+ return this;
122
61
  }
123
62
  /**
124
63
  *
@@ -126,12 +65,11 @@ var ThemeBuilder = /*#__PURE__*/function () {
126
65
  * @param createScale A function that accepts the current theme and returns a new object of scale values.
127
66
  * @example .addScale('fonts', () => ({ basic: 'Gotham', cool: 'Wingdings' }))
128
67
  */
129
-
130
- }, {
131
- key: "addScale",
132
- value: function addScale(key, createScale) {
133
- _classPrivateFieldLooseBase(this, _theme)[_theme] = merge({}, _classPrivateFieldLooseBase(this, _theme)[_theme], _defineProperty({}, key, flattenScale(createScale(_classPrivateFieldLooseBase(this, _theme)[_theme]))));
134
- return this;
68
+ addScale(key, createScale) {
69
+ this.#theme = merge({}, this.#theme, {
70
+ [key]: flattenScale(createScale(this.#theme)),
71
+ });
72
+ return this;
135
73
  }
136
74
  /**
137
75
  *
@@ -139,30 +77,18 @@ var ThemeBuilder = /*#__PURE__*/function () {
139
77
  * @param updateFn A function that accepts an argument of the current values at the specified keys an returns a map of new values to merge.
140
78
  * @example .updateScale('fonts', ({ basic }) => ({ basicFallback: `{basic}, Montserrat` }))
141
79
  */
142
-
143
- }, {
144
- key: "updateScale",
145
- value: function updateScale(key, updateFn) {
146
- _classPrivateFieldLooseBase(this, _theme)[_theme] = merge({}, _classPrivateFieldLooseBase(this, _theme)[_theme], _defineProperty({}, key, updateFn(_classPrivateFieldLooseBase(this, _theme)[_theme][key])));
147
- return this;
80
+ updateScale(key, updateFn) {
81
+ this.#theme = merge({}, this.#theme, { [key]: updateFn(this.#theme[key]) });
82
+ return this;
148
83
  }
149
84
  /**
150
85
  * This finalizes the theme build and returns the final theme and variables to be provided.
151
86
  */
152
-
153
- }, {
154
- key: "build",
155
- value: function build() {
156
- return merge({}, _classPrivateFieldLooseBase(this, _theme)[_theme], {
157
- _variables: {},
158
- _tokens: {}
159
- });
87
+ build() {
88
+ return merge({}, this.#theme, { _variables: {}, _tokens: {} });
160
89
  }
161
- }]);
162
-
163
- return ThemeBuilder;
164
- }();
165
-
90
+ }
166
91
  export function createTheme(base) {
167
- return new ThemeBuilder(base);
168
- }
92
+ return new ThemeBuilder(base);
93
+ }
94
+ //# sourceMappingURL=createTheme.js.map
@@ -1,192 +1,167 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
1
  import { mapValues } from 'lodash';
8
2
  import { createTheme } from './createTheme';
9
- describe('createTheme', function () {
10
- var base = {
11
- breakpoints: {
12
- xs: '1',
13
- sm: '2',
14
- md: '3',
15
- lg: '4',
16
- xl: '5'
17
- }
18
- };
19
- it('works', function () {
20
- expect(createTheme(base).build()).toEqual(_objectSpread(_objectSpread({}, base), {}, {
21
- _variables: {},
22
- _tokens: {}
23
- }));
24
- });
25
- it('adds a scale', function () {
26
- var theme = createTheme(base).addScale('test', function () {
27
- return {
28
- test: 1,
29
- test2: 2
30
- };
31
- }).build();
32
- expect(theme.test).toEqual({
33
- test: 1,
34
- test2: 2
35
- });
36
- });
37
- it('updates a scale', function () {
38
- var builder = createTheme(base).addScale('test', function () {
39
- return {
40
- test: 1,
41
- test2: 2
42
- };
43
- });
44
- expect(builder.build().test).toEqual({
45
- test: 1,
46
- test2: 2
47
- });
48
- builder.updateScale('test', function () {
49
- return {
50
- test3: 3
51
- };
52
- });
53
- expect(builder.build().test).toEqual({
54
- test: 1,
55
- test2: 2,
56
- test3: 3
57
- });
58
- });
59
- it('serializes variables', function () {
60
- var theme = createTheme(base).addScale('test', function () {
61
- return {
62
- test: 1,
63
- test2: 2
64
- };
65
- }).createScaleVariables('test').build();
66
- expect(theme.test).toEqual({
67
- test: 'var(--test-test)',
68
- test2: 'var(--test-test2)'
69
- });
70
- expect(theme._variables.root).toEqual({
71
- '--test-test': 1,
72
- '--test-test2': 2
73
- });
74
- });
75
- describe('colors', function () {
76
- var staticColors = {
77
- white: 'white',
78
- black: 'black',
79
- blue: 'blue',
80
- green: 'green',
81
- red: 'red'
3
+ describe('createTheme', () => {
4
+ const base = {
5
+ breakpoints: { xs: '1', sm: '2', md: '3', lg: '4', xl: '5' },
82
6
  };
83
- var cssVariableReferences = mapValues(staticColors, function (val) {
84
- return "var(--color-".concat(val, ")");
85
- });
86
- var builder = createTheme(base);
87
- it('creates color variables', function () {
88
- var theme = builder.addColors(staticColors).build();
89
- expect(theme.colors).toEqual(cssVariableReferences);
90
- });
91
- it('adds colorModes', function () {
92
- var theme = builder.addColors(staticColors).addColorModes('light', {
93
- light: {
94
- primary: 'red'
95
- },
96
- dark: {
97
- primary: 'blue'
98
- }
99
- }).build();
100
- expect(theme.colors).toEqual(_objectSpread(_objectSpread({}, mapValues(staticColors, function (val) {
101
- return "var(--color-".concat(val, ")");
102
- })), {}, {
103
- primary: 'var(--color-primary)'
104
- }));
105
- expect(theme._variables.mode).toEqual({
106
- '--color-primary': 'var(--color-red)'
107
- });
7
+ it('works', () => {
8
+ expect(createTheme(base).build()).toEqual({
9
+ ...base,
10
+ _variables: {},
11
+ _tokens: {},
12
+ });
108
13
  });
109
- it('returns value checker for colors', function () {
110
- var theme = builder.addColors({
111
- black: '#000000',
112
- white: '#FFFFFF'
113
- }).addColorModes('light', {
114
- light: {
115
- primary: 'black'
116
- },
117
- dark: {
118
- primary: 'white'
119
- }
120
- }).build();
121
- expect(theme._getColorValue('white')).toEqual('#FFFFFF');
122
- expect(theme._getColorValue(theme.modes.light.primary)).toEqual('#000000');
14
+ it('adds a scale', () => {
15
+ const theme = createTheme(base)
16
+ .addScale('test', () => ({
17
+ test: 1,
18
+ test2: 2,
19
+ }))
20
+ .build();
21
+ expect(theme.test).toEqual({ test: 1, test2: 2 });
123
22
  });
124
- it('returns value checker for colors with deep values', function () {
125
- var theme = builder.addColors({
126
- black: '#000000',
127
- white: '#FFFFFF',
128
- gray: {
129
- 200: '#eeeeee',
130
- 300: '#666666'
131
- }
132
- }).addColorModes('light', {
133
- light: {
134
- primary: {
135
- "default": 'gray-200',
136
- cool: {
137
- _: 'gray-300',
138
- town: 'black'
139
- }
140
- }
141
- }
142
- }).build();
143
- expect(theme._getColorValue('gray-300')).toEqual('#666666');
144
- expect(theme._getColorValue(theme.modes.light['primary-default'])).toEqual('#eeeeee');
23
+ it('updates a scale', () => {
24
+ const builder = createTheme(base).addScale('test', () => ({
25
+ test: 1,
26
+ test2: 2,
27
+ }));
28
+ expect(builder.build().test).toEqual({ test: 1, test2: 2 });
29
+ builder.updateScale('test', () => ({ test3: 3 }));
30
+ expect(builder.build().test).toEqual({ test: 1, test2: 2, test3: 3 });
145
31
  });
146
- it('merges color mode configurations when overriden', function () {
147
- var theme = builder.addColors({
148
- black: '#000000',
149
- white: '#FFFFFF'
150
- }).addColorModes('light', {
151
- light: {
152
- primary: {
153
- _: 'black',
154
- hover: 'white'
155
- }
156
- }
157
- }).build();
158
- var override = createTheme(theme).addColorModes('light', {
159
- light: {
160
- primary: {
161
- _: 'white',
162
- hover: 'black'
163
- }
164
- }
165
- }).build();
166
- expect(override.modes.light.primary).toEqual('white');
32
+ it('serializes variables', () => {
33
+ const theme = createTheme(base)
34
+ .addScale('test', () => ({
35
+ test: 1,
36
+ test2: 2,
37
+ }))
38
+ .createScaleVariables('test')
39
+ .build();
40
+ expect(theme.test).toEqual({
41
+ test: 'var(--test-test)',
42
+ test2: 'var(--test-test2)',
43
+ });
44
+ expect(theme._variables.root).toEqual({
45
+ '--test-test': 1,
46
+ '--test-test2': 2,
47
+ });
167
48
  });
168
- it('returns the raw values of color mode colors on the tokens object', function () {
169
- var theme = createTheme(base).addColors({
170
- black: '#000000',
171
- gray: {
172
- 300: '#666666'
173
- }
174
- }).addColorModes('light', {
175
- light: {
176
- primary: {
177
- cool: {
178
- _: 'gray-300',
179
- town: 'black'
180
- }
181
- }
182
- }
183
- }).build();
184
- expect(theme._tokens.modes).toEqual({
185
- light: {
186
- 'primary-cool': '#666666',
187
- 'primary-cool-town': '#000000'
188
- }
189
- });
49
+ describe('colors', () => {
50
+ const staticColors = {
51
+ white: 'white',
52
+ black: 'black',
53
+ blue: 'blue',
54
+ green: 'green',
55
+ red: 'red',
56
+ };
57
+ const cssVariableReferences = mapValues(staticColors, (val) => `var(--color-${val})`);
58
+ const builder = createTheme(base);
59
+ it('creates color variables', () => {
60
+ const theme = builder.addColors(staticColors).build();
61
+ expect(theme.colors).toEqual(cssVariableReferences);
62
+ });
63
+ it('adds colorModes', () => {
64
+ const theme = builder
65
+ .addColors(staticColors)
66
+ .addColorModes('light', {
67
+ light: {
68
+ primary: 'red',
69
+ },
70
+ dark: {
71
+ primary: 'blue',
72
+ },
73
+ })
74
+ .build();
75
+ expect(theme.colors).toEqual({
76
+ ...mapValues(staticColors, (val) => `var(--color-${val})`),
77
+ primary: 'var(--color-primary)',
78
+ });
79
+ expect(theme._variables.mode).toEqual({
80
+ '--color-primary': 'var(--color-red)',
81
+ });
82
+ });
83
+ it('returns value checker for colors', () => {
84
+ const theme = builder
85
+ .addColors({
86
+ black: '#000000',
87
+ white: '#FFFFFF',
88
+ })
89
+ .addColorModes('light', {
90
+ light: {
91
+ primary: 'black',
92
+ },
93
+ dark: {
94
+ primary: 'white',
95
+ },
96
+ })
97
+ .build();
98
+ expect(theme._getColorValue('white')).toEqual('#FFFFFF');
99
+ expect(theme._getColorValue(theme.modes.light.primary)).toEqual('#000000');
100
+ });
101
+ it('returns value checker for colors with deep values', () => {
102
+ const theme = builder
103
+ .addColors({
104
+ black: '#000000',
105
+ white: '#FFFFFF',
106
+ gray: { 200: '#eeeeee', 300: '#666666' },
107
+ })
108
+ .addColorModes('light', {
109
+ light: {
110
+ primary: {
111
+ default: 'gray-200',
112
+ cool: { _: 'gray-300', town: 'black' },
113
+ },
114
+ },
115
+ })
116
+ .build();
117
+ expect(theme._getColorValue('gray-300')).toEqual('#666666');
118
+ expect(theme._getColorValue(theme.modes.light['primary-default'])).toEqual('#eeeeee');
119
+ });
120
+ it('merges color mode configurations when overriden', () => {
121
+ const theme = builder
122
+ .addColors({
123
+ black: '#000000',
124
+ white: '#FFFFFF',
125
+ })
126
+ .addColorModes('light', {
127
+ light: {
128
+ primary: {
129
+ _: 'black',
130
+ hover: 'white',
131
+ },
132
+ },
133
+ })
134
+ .build();
135
+ const override = createTheme(theme)
136
+ .addColorModes('light', {
137
+ light: {
138
+ primary: {
139
+ _: 'white',
140
+ hover: 'black',
141
+ },
142
+ },
143
+ })
144
+ .build();
145
+ expect(override.modes.light.primary).toEqual('white');
146
+ });
147
+ it('returns the raw values of color mode colors on the tokens object', () => {
148
+ const theme = createTheme(base)
149
+ .addColors({
150
+ black: '#000000',
151
+ gray: { 300: '#666666' },
152
+ })
153
+ .addColorModes('light', {
154
+ light: {
155
+ primary: {
156
+ cool: { _: 'gray-300', town: 'black' },
157
+ },
158
+ },
159
+ })
160
+ .build();
161
+ expect(theme._tokens.modes).toEqual({
162
+ light: { 'primary-cool': '#666666', 'primary-cool-town': '#000000' },
163
+ });
164
+ });
190
165
  });
191
- });
192
- });
166
+ });
167
+ //# sourceMappingURL=createTheme.test.js.map
@@ -1,3 +1,4 @@
1
1
  export * from './createTheme';
2
2
  export * from '../utils/serializeTokens';
3
- export * from '../utils/flattenScale';
3
+ export * from '../utils/flattenScale';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@ export { variance } from './core';
2
2
  export * from './createTheme';
3
3
  export * from './types/props';
4
4
  export * from './transforms';
5
- export * from './scales/createScale';
5
+ export * from './scales/createScale';
6
+ //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
- export var createScale = function createScale() {
2
- return [];
3
- };
1
+ export const createScale = () => [];
2
+ //# sourceMappingURL=createScale.js.map
@@ -1,24 +1,14 @@
1
1
  import { get, isArray, isObject, isString } from 'lodash';
2
- export var createScaleLookup = function createScaleLookup(scale) {
3
- if (isString(scale)) {
4
- return function (val, props) {
5
- return get(props, ['theme', scale, val]);
6
- };
7
- }
8
-
9
- if (isArray(scale)) {
10
- return function (val) {
11
- return val;
12
- };
13
- }
14
-
15
- if (isObject(scale)) {
16
- return function (val) {
17
- return get(scale, val);
18
- };
19
- }
20
-
21
- return function () {
22
- return undefined;
23
- };
24
- };
2
+ export const createScaleLookup = (scale) => {
3
+ if (isString(scale)) {
4
+ return (val, props) => get(props, ['theme', scale, val]);
5
+ }
6
+ if (isArray(scale)) {
7
+ return (val) => val;
8
+ }
9
+ if (isObject(scale)) {
10
+ return (val) => get(scale, val);
11
+ }
12
+ return () => undefined;
13
+ };
14
+ //# sourceMappingURL=createScaleLookup.js.map
@@ -0,0 +1,10 @@
1
+ import { AbstractParser, AbstractPropTransformer, Compose, CSS, Parser, Prop, PropTransformer, States, TransformerMap, Variant } from './types/config';
2
+ export declare const variance: {
3
+ createParser<Config extends Record<string, AbstractPropTransformer>>(config: Config): Parser<Config>;
4
+ createTransform<P extends string, Config_1 extends Prop>(prop: P, config: Config_1): PropTransformer<P, Config_1>;
5
+ compose<Args extends AbstractParser[]>(...parsers: Args): Parser<Compose<Args>>;
6
+ createCss<Config_2 extends Record<string, Prop>, P_1 extends Parser<TransformerMap<Config_2>>>(config: Config_2): CSS<P_1>;
7
+ createVariant<Config_3 extends Record<string, Prop>, P_2 extends Parser<TransformerMap<Config_3>>>(config: Config_3): Variant<P_2>;
8
+ createStates<Config_4 extends Record<string, Prop>, P_3 extends Parser<TransformerMap<Config_4>>>(config: Config_4): States<P_3>;
9
+ create<Config_5 extends Record<string, Prop>>(config: Config_5): Parser<TransformerMap<Config_5>>;
10
+ };