@moda/tokens 6.2.126 → 6.2.127

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.
package/dist/helpers.d.ts CHANGED
@@ -62,6 +62,6 @@ export declare const text: (name: TextTreatment, font?: Font) => {
62
62
  "text-transform": string;
63
63
  };
64
64
  export declare const remToUnitlessPx: (value: string) => number;
65
- export declare const color: (name: Color, alpha?: number) => string;
65
+ export declare const color: (name: Color, alpha?: number) => string | null;
66
66
  export declare const colorInHex: (name: Color, alpha?: number) => string;
67
67
  export declare const spacing: (topY: number | string, rightX?: number | string, bottom?: number | string, left?: number | string) => string | number | undefined;
package/dist/helpers.js CHANGED
@@ -10,18 +10,9 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
13
  Object.defineProperty(exports, "__esModule", { value: true });
23
14
  exports.spacing = exports.colorInHex = exports.color = exports.remToUnitlessPx = exports.text = void 0;
24
- var colorString = require("color-string");
15
+ var color_string_1 = require("color-string");
25
16
  var colors_1 = require("./colors");
26
17
  var space_1 = require("./space");
27
18
  var typography_1 = require("./typography");
@@ -38,14 +29,14 @@ exports.remToUnitlessPx = remToUnitlessPx;
38
29
  var color = function (name, alpha) {
39
30
  var _a;
40
31
  var color = colors_1.colors.all[name];
41
- return alpha != null
42
- ? // eslint-disable-next-line @typescript-eslint/no-magic-numbers
43
- colorString.to.rgb(__spreadArray(__spreadArray([], (((_a = colorString.get.rgb(color)) === null || _a === void 0 ? void 0 : _a.slice(0, 3)) || []), true), [alpha], false))
44
- : color;
32
+ var _b = (_a = color_string_1.default.get.rgb(color)) !== null && _a !== void 0 ? _a : [], red = _b[0], green = _b[1], blue = _b[2];
33
+ return alpha != null ? color_string_1.default.to.rgb(red, green, blue, alpha) : color;
45
34
  };
46
35
  exports.color = color;
47
36
  var colorInHex = function (name, alpha) {
48
- return colorString.to.hex(colorString.get.rgb((0, exports.color)(name, alpha)));
37
+ var _a, _b, _c;
38
+ var _d = (_b = color_string_1.default.get.rgb((_a = (0, exports.color)(name, alpha)) !== null && _a !== void 0 ? _a : '')) !== null && _b !== void 0 ? _b : [], red = _d[0], green = _d[1], blue = _d[2];
39
+ return (_c = color_string_1.default.to.hex(red, green, blue, alpha)) !== null && _c !== void 0 ? _c : '';
49
40
  };
50
41
  exports.colorInHex = colorInHex;
51
42
  var spacing = function (topY, rightX, bottom, left) {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4C;AAC5C,mCAAkC;AAClC,iCAAgC;AAChC,2CAA0C;AAMnC,IAAM,IAAI,GAAG,UAAC,IAAmB,EAAE,IAAqB;IAArB,qBAAA,EAAA,OAAO,MAAc;IAC7D,IAAM,SAAS,GAAG,uBAAU,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAC;IACtD,6BACK,SAAS,KACZ,aAAa,EAAE,uBAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC/C,aAAa,EAAE,UAAG,SAAS,CAAC,aAAa,CAAC,CAAE,IAC5C;AACJ,CAAC,CAAC;AAPW,QAAA,IAAI,QAOf;AAEK,IAAM,eAAe,GAAG,UAAC,KAAa;IAC3C,OAAA,UAAU,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,uBAAU,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC;AAA9D,CAA8D,CAAC;AADpD,QAAA,eAAe,mBACqC;AAE1D,IAAM,KAAK,GAAG,U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E,EAAvE,GAAG,QAAA,EAAE,KAAK,QAAA,EAAE,IAAI,QAAuD,CAAC;IAE/E,OAAO,MAAA,sBAAW,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,mCAAI,EAAE,CAAC;AAC3D,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB;AAEK,IAAM,OAAO,GAAG,UACrB,IAAqB,EACrB,MAAwB,EACxB,MAAwB,EACxB,IAAsB;IAEtB,OAAA,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,KAAK;;QAC7C,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,GAAG,CAAC;QACpC,OAAO,CAAC,GAAG,EAAE,MAAA,aAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,mCAAI,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9D,CAAC,EAAE,EAAE,CAAC;AAHN,CAGM,CAAC;AATI,QAAA,OAAO,WASX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moda/tokens",
3
- "version": "6.2.126",
3
+ "version": "6.2.127",
4
4
  "description": "Constant values for modaoperandi.com",
5
5
  "repository": "git@github.com:ModaOperandi/tokens.git",
6
6
  "author": "Moda Operandi",
@@ -67,6 +67,6 @@
67
67
  "access": "public"
68
68
  },
69
69
  "dependencies": {
70
- "color-string": "^1.9.1"
70
+ "color-string": "^2.0.1"
71
71
  }
72
72
  }
package/src/helpers.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as colorString from 'color-string';
1
+ import colorString from 'color-string';
2
2
  import { colors } from './colors';
3
3
  import { space } from './space';
4
4
  import { typography } from './typography';
@@ -21,14 +21,16 @@ export const remToUnitlessPx = (value: string) =>
21
21
 
22
22
  export const color = (name: Color, alpha?: number) => {
23
23
  const color = colors.all[name];
24
- return alpha != null
25
- ? // eslint-disable-next-line @typescript-eslint/no-magic-numbers
26
- colorString.to.rgb([...(colorString.get.rgb(color)?.slice(0, 3) || []), alpha])
27
- : color;
24
+ const [red, green, blue] = colorString.get.rgb(color) ?? [];
25
+
26
+ return alpha != null ? colorString.to.rgb(red, green, blue, alpha) : color;
28
27
  };
29
28
 
30
- export const colorInHex = (name: Color, alpha?: number): string =>
31
- colorString.to.hex(colorString.get.rgb(color(name, alpha)));
29
+ export const colorInHex = (name: Color, alpha?: number): string => {
30
+ const [red, green, blue] = colorString.get.rgb(color(name, alpha) ?? '') ?? [];
31
+
32
+ return colorString.to.hex(red, green, blue, alpha) ?? '';
33
+ };
32
34
 
33
35
  export const spacing = (
34
36
  topY: number | string,