@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,42 +1,33 @@
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 _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
-
5
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
-
7
1
  import { isObject, merge } from 'lodash';
8
-
9
- var templateBreakpoints = function templateBreakpoints(value, alias, theme) {
10
- if (isObject(value)) {
11
- var _ = value._,
12
- base = value.base,
13
- rest = _objectWithoutProperties(value, ["_", "base"]);
14
-
15
- var css = _defineProperty({}, alias, _ !== null && _ !== void 0 ? _ : base);
16
-
17
- if (theme) {
18
- var breakpoints = theme.breakpoints;
19
- Object.keys(breakpoints).forEach(function (key) {
20
- css[breakpoints[key]] = _defineProperty({}, alias, rest[key]);
21
- });
2
+ const templateBreakpoints = (value, alias, theme) => {
3
+ if (isObject(value)) {
4
+ const { _, base, ...rest } = value;
5
+ const css = {
6
+ [alias]: _ ?? base,
7
+ };
8
+ if (theme) {
9
+ const { breakpoints } = theme;
10
+ Object.keys(breakpoints).forEach((key) => {
11
+ css[breakpoints[key]] = {
12
+ [alias]: rest[key],
13
+ };
14
+ });
15
+ }
16
+ return css;
22
17
  }
23
-
24
- return css;
25
- }
26
-
27
- return _defineProperty({}, alias, value);
18
+ return { [alias]: value };
28
19
  };
29
-
30
- export var serializeTokens = function serializeTokens(tokens, prefix, theme) {
31
- var tokenReferences = {};
32
- var tokenVariables = {};
33
- Object.keys(tokens).forEach(function (key) {
34
- var varName = "--".concat(prefix, "-").concat(key);
35
- tokenReferences[key] = "var(".concat(varName, ")");
36
- merge(tokenVariables, templateBreakpoints(tokens[key], varName, theme));
37
- });
38
- return {
39
- tokens: tokenReferences,
40
- variables: tokenVariables
41
- };
42
- };
20
+ export const serializeTokens = (tokens, prefix, theme) => {
21
+ const tokenReferences = {};
22
+ const tokenVariables = {};
23
+ Object.keys(tokens).forEach((key) => {
24
+ const varName = `--${prefix}-${key}`;
25
+ tokenReferences[key] = `var(${varName})`;
26
+ merge(tokenVariables, templateBreakpoints(tokens[key], varName, theme));
27
+ });
28
+ return {
29
+ tokens: tokenReferences,
30
+ variables: tokenVariables,
31
+ };
32
+ };
33
+ //# sourceMappingURL=serializeTokens.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codecademy/variance",
3
3
  "description": "Constraint based CSS in JS for building scalable design systems",
4
- "version": "0.20.0",
4
+ "version": "0.20.1-alpha.32ef98.0",
5
5
  "keywords": [
6
6
  "emotion",
7
7
  "css",
@@ -25,7 +25,7 @@
25
25
  "build:clean": "rm -rf ./dist",
26
26
  "build:compile": "tsc -b",
27
27
  "build:transpile": "babel ./src --out-dir ./dist --copy-files --extensions \".ts,.tsx\"",
28
- "build": "yarn build:clean && yarn build:compile && yarn build:transpile",
28
+ "build": "yarn build:clean && yarn build:transpile && yarn build:compile",
29
29
  "lernaBuildTask": "yarn build"
30
30
  },
31
31
  "peerDependencies": {
@@ -43,5 +43,5 @@
43
43
  "react": "17.0.2",
44
44
  "react-test-renderer": "17.0.2"
45
45
  },
46
- "gitHead": "c165b0b46bb25c859d51e541761858a39a2d2a26"
46
+ "gitHead": "41ecfd1a802aeef93606fce7547726d00f00051d"
47
47
  }