@muonic/muon 0.0.2-experimental-194-283b2d1.0 → 0.0.2-experimental-196-35ea101.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-beta.15](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.14...v0.0.2-beta.15) (2023-05-24)
6
+
5
7
  ### [0.0.2-beta.14](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.13...v0.0.2-beta.14) (2023-05-23)
6
8
 
7
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-experimental-194-283b2d1.0",
3
+ "version": "0.0.2-experimental-196-35ea101.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,6 +6,7 @@ import path from 'path';
6
6
  import { fileURLToPath } from 'url';
7
7
  import esmock from 'esmock';
8
8
  import * as utilsLibrary from '../../../scripts/utils/index.mjs';
9
+ import colorTransform from '../../../tokens/utils/transforms/color.js';
9
10
 
10
11
  testRunner('filterPathToCustomElements default', async (t) => {
11
12
  const componentList = await utilsLibrary.filterPathToCustomElements('all');
@@ -324,3 +325,32 @@ testRunner('cleanup on serve', async (t) => {
324
325
  utilsLibrary.cleanup(destination);
325
326
  t.true(fs.existsSync(destination));
326
327
  });
328
+
329
+ testRunner('create color transform default', async (t) => {
330
+ const transform = colorTransform.transformer({
331
+ value: '#ff0000',
332
+ modify: [
333
+ {
334
+ type: 'brighten',
335
+ amount: 10
336
+ }
337
+ ]
338
+ });
339
+
340
+ t.is(transform, '#ffffff');
341
+ });
342
+
343
+ testRunner('create color transform mix', async (t) => {
344
+ const transform = colorTransform.transformer({
345
+ value: '#ff0000',
346
+ modify: [
347
+ {
348
+ type: 'mix',
349
+ amount: '#000000',
350
+ ratio: 0.2
351
+ }
352
+ ]
353
+ });
354
+
355
+ t.is(transform, '#e40000');
356
+ });
@@ -5,14 +5,20 @@ const colorTransform = (token) => {
5
5
  let color = chroma(value);
6
6
  // iterate over the modify array (see tokens/color.json)
7
7
  // and apply each modification in order
8
- modify.forEach(({ type, amount }) => {
8
+ modify.forEach(({ type, amount, ratio = 0.5 }) => {
9
9
  // modifier type must match a method name in chromajs
10
10
  // https://gka.github.io/chroma.js/
11
11
  // chroma methods can be chained, so each time we override the color variable
12
12
  // we can still call other chroma methods, similar to
13
13
  // chroma(value).brighten(1).darken(1).hex();
14
- color = color[type](amount);
15
14
 
15
+ // if the modifier type is 'mix', we need to pass in the color to mix with
16
+ // and the ratio to mix by
17
+ if (type === 'mix') {
18
+ color = color.mix(amount, ratio);
19
+ } else {
20
+ color = color[type](amount);
21
+ }
16
22
  });
17
23
 
18
24
  return color.hex();