@mirai/ui 1.0.17 → 1.0.18
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/build/theme/default.theme.css +0 -6
- package/build/theme/helpers/colorShade.js +34 -0
- package/build/theme/helpers/colorShade.js.map +1 -0
- package/build/theme/helpers/index.js +13 -0
- package/build/theme/helpers/index.js.map +1 -1
- package/build/theme/theme.js +14 -0
- package/build/theme/theme.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,14 +22,8 @@
|
|
|
22
22
|
/* !TODO ------------------------------------------------------------------ */
|
|
23
23
|
|
|
24
24
|
--mirai-ui-accent: #3978c5;
|
|
25
|
-
--mirai-ui-accent-400: #609ae0;
|
|
26
|
-
--mirai-ui-accent-300: #b7d3f9;
|
|
27
|
-
--mirai-ui-accent-200: #e5eefa;
|
|
28
|
-
|
|
29
25
|
--mirai-ui-error: #e04646;
|
|
30
|
-
--mirai-ui-error-400: #eccccc;
|
|
31
26
|
--mirai-ui-success: #5fb560;
|
|
32
|
-
--mirai-ui-success-400: #c6e7c6;
|
|
33
27
|
|
|
34
28
|
/* spacing */
|
|
35
29
|
--mirai-ui-space-XS: 8px;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.colorShade = void 0;
|
|
7
|
+
var R = 0;
|
|
8
|
+
var G = 8;
|
|
9
|
+
var B = 16;
|
|
10
|
+
var SCALE = {
|
|
11
|
+
400: 40,
|
|
12
|
+
300: 80,
|
|
13
|
+
200: 180
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var colorShade = function colorShade() {
|
|
17
|
+
var hexColor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#000000';
|
|
18
|
+
var magnitude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
19
|
+
if (!hexColor.charAt(0) === '#' || hexColor.length !== 7) return hexColor;
|
|
20
|
+
var decimalColor = parseInt(hexColor.slice(1), 16);
|
|
21
|
+
|
|
22
|
+
var range = function range(value) {
|
|
23
|
+
return value < 0 ? 0 : value > 255 ? 255 : value;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return '#' + [R, G, B].map(function (item) {
|
|
27
|
+
return range((decimalColor >> item & 0xff) + (SCALE[magnitude] || 0)) << item;
|
|
28
|
+
}).reduce(function (previous, current) {
|
|
29
|
+
return previous + current;
|
|
30
|
+
}, 0).toString(16).padStart(6, '0');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.colorShade = colorShade;
|
|
34
|
+
//# sourceMappingURL=colorShade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorShade.js","names":["R","G","B","SCALE","colorShade","hexColor","magnitude","charAt","length","decimalColor","parseInt","slice","range","value","map","item","reduce","previous","current","toString","padStart"],"sources":["../../../src/theme/helpers/colorShade.js"],"sourcesContent":["const R = 0;\nconst G = 8;\nconst B = 16;\n\nconst SCALE = {\n 400: 40,\n 300: 80,\n 200: 180,\n};\n\nexport const colorShade = (hexColor = '#000000', magnitude = 0) => {\n if (!hexColor.charAt(0) === '#' || hexColor.length !== 7) return hexColor;\n\n const decimalColor = parseInt(hexColor.slice(1), 16);\n const range = (value) => (value < 0 ? 0 : value > 255 ? 255 : value);\n\n return (\n '#' +\n [R, G, B]\n .map((item) => range(((decimalColor >> item) & 0xff) + (SCALE[magnitude] || 0)) << item)\n .reduce((previous, current) => previous + current, 0)\n .toString(16)\n .padStart(6, '0')\n );\n};\n"],"mappings":";;;;;;AAAA,IAAMA,CAAC,GAAG,CAAV;AACA,IAAMC,CAAC,GAAG,CAAV;AACA,IAAMC,CAAC,GAAG,EAAV;AAEA,IAAMC,KAAK,GAAG;EACZ,KAAK,EADO;EAEZ,KAAK,EAFO;EAGZ,KAAK;AAHO,CAAd;;AAMO,IAAMC,UAAU,GAAG,SAAbA,UAAa,GAAyC;EAAA,IAAxCC,QAAwC,uEAA7B,SAA6B;EAAA,IAAlBC,SAAkB,uEAAN,CAAM;EACjE,IAAI,CAACD,QAAQ,CAACE,MAAT,CAAgB,CAAhB,CAAD,KAAwB,GAAxB,IAA+BF,QAAQ,CAACG,MAAT,KAAoB,CAAvD,EAA0D,OAAOH,QAAP;EAE1D,IAAMI,YAAY,GAAGC,QAAQ,CAACL,QAAQ,CAACM,KAAT,CAAe,CAAf,CAAD,EAAoB,EAApB,CAA7B;;EACA,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAACC,KAAD;IAAA,OAAYA,KAAK,GAAG,CAAR,GAAY,CAAZ,GAAgBA,KAAK,GAAG,GAAR,GAAc,GAAd,GAAoBA,KAAhD;EAAA,CAAd;;EAEA,OACE,MACA,CAACb,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EACGY,GADH,CACO,UAACC,IAAD;IAAA,OAAUH,KAAK,CAAC,CAAEH,YAAY,IAAIM,IAAjB,GAAyB,IAA1B,KAAmCZ,KAAK,CAACG,SAAD,CAAL,IAAoB,CAAvD,CAAD,CAAL,IAAoES,IAA9E;EAAA,CADP,EAEGC,MAFH,CAEU,UAACC,QAAD,EAAWC,OAAX;IAAA,OAAuBD,QAAQ,GAAGC,OAAlC;EAAA,CAFV,EAEqD,CAFrD,EAGGC,QAHH,CAGY,EAHZ,EAIGC,QAJH,CAIY,CAJZ,EAIe,GAJf,CAFF;AAQD,CAdM"}
|
|
@@ -16,4 +16,17 @@ Object.keys(_camelcase).forEach(function (key) {
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
+
|
|
20
|
+
var _colorShade = require("./colorShade");
|
|
21
|
+
|
|
22
|
+
Object.keys(_colorShade).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _colorShade[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _colorShade[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
19
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/theme/helpers/index.js"],"sourcesContent":["export * from './camelcase';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/theme/helpers/index.js"],"sourcesContent":["export * from './camelcase';\nexport * from './colorShade';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/build/theme/theme.js
CHANGED
|
@@ -20,6 +20,8 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
20
20
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
21
21
|
|
|
22
22
|
var VAR_DOMAIN = '--mirai-ui-';
|
|
23
|
+
var COLORS = ['accent', 'error', 'success'];
|
|
24
|
+
var MAGNITUDES = [400, 300, 200];
|
|
23
25
|
var Theme = {
|
|
24
26
|
get: function get() {
|
|
25
27
|
var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : VAR_DOMAIN;
|
|
@@ -47,7 +49,19 @@ var Theme = {
|
|
|
47
49
|
style = _document$querySelect.style;
|
|
48
50
|
|
|
49
51
|
style.setProperty("".concat(domain).concat(variable), value);
|
|
52
|
+
Theme.shadeColors();
|
|
53
|
+
},
|
|
54
|
+
shadeColors: function shadeColors() {
|
|
55
|
+
var theme = Theme.get();
|
|
56
|
+
COLORS.filter(function (color) {
|
|
57
|
+
return theme[color] !== undefined;
|
|
58
|
+
}).forEach(function (color) {
|
|
59
|
+
return MAGNITUDES.forEach(function (magnitude) {
|
|
60
|
+
return Theme.setVariable("".concat(color, "-").concat(magnitude), (0, _helpers.colorShade)(theme[color], magnitude));
|
|
61
|
+
});
|
|
62
|
+
});
|
|
50
63
|
}
|
|
51
64
|
};
|
|
52
65
|
exports.Theme = Theme;
|
|
66
|
+
Theme.shadeColors();
|
|
53
67
|
//# sourceMappingURL=theme.js.map
|
package/build/theme/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":["VAR_DOMAIN","Theme","get","domain","style","getComputedStyle","document","querySelector","variables","styleSheets","forEach","stylesheet","cssRules","filter","rule","type","name","includes","replace","getPropertyValue","trim","setVariable","variable","value","setProperty"],"sources":["../../src/theme/theme.js"],"sourcesContent":["const VAR_DOMAIN = '--mirai-ui-';\n\nimport { camelcase } from './helpers';\n\nexport const Theme = {\n get: (domain = VAR_DOMAIN) => {\n const style = getComputedStyle(document.querySelector(':root'));\n\n const variables = {};\n [...document.styleSheets].forEach((stylesheet) => {\n [...stylesheet.cssRules]\n .filter((rule) => rule.type === 1)\n .forEach((rule) => {\n [...rule.style]\n .filter((name) => name.includes(domain))\n .forEach((name) => (variables[camelcase(name.replace(domain, ''))] = style.getPropertyValue(name).trim()));\n });\n });\n\n return variables;\n },\n\n setVariable: (variable, value, domain = VAR_DOMAIN) => {\n const { style } = document.querySelector(':root');\n\n style.setProperty(`${domain}${variable}`, value);\n },\n};\n"],"mappings":";;;;;;;AAEA;;;;;;;;;;;;;;AAFA,IAAMA,UAAU,GAAG,aAAnB;
|
|
1
|
+
{"version":3,"file":"theme.js","names":["VAR_DOMAIN","COLORS","MAGNITUDES","Theme","get","domain","style","getComputedStyle","document","querySelector","variables","styleSheets","forEach","stylesheet","cssRules","filter","rule","type","name","includes","replace","getPropertyValue","trim","setVariable","variable","value","setProperty","shadeColors","theme","color","undefined","magnitude"],"sources":["../../src/theme/theme.js"],"sourcesContent":["const VAR_DOMAIN = '--mirai-ui-';\n\nimport { camelcase, colorShade } from './helpers';\n\nconst COLORS = ['accent', 'error', 'success'];\nconst MAGNITUDES = [400, 300, 200];\n\nexport const Theme = {\n get: (domain = VAR_DOMAIN) => {\n const style = getComputedStyle(document.querySelector(':root'));\n\n const variables = {};\n [...document.styleSheets].forEach((stylesheet) => {\n [...stylesheet.cssRules]\n .filter((rule) => rule.type === 1)\n .forEach((rule) => {\n [...rule.style]\n .filter((name) => name.includes(domain))\n .forEach((name) => (variables[camelcase(name.replace(domain, ''))] = style.getPropertyValue(name).trim()));\n });\n });\n\n return variables;\n },\n\n setVariable: (variable, value, domain = VAR_DOMAIN) => {\n const { style } = document.querySelector(':root');\n\n style.setProperty(`${domain}${variable}`, value);\n\n Theme.shadeColors();\n },\n\n shadeColors: () => {\n const theme = Theme.get();\n\n COLORS.filter((color) => theme[color] !== undefined).forEach((color) =>\n MAGNITUDES.forEach((magnitude) =>\n Theme.setVariable(`${color}-${magnitude}`, colorShade(theme[color], magnitude)),\n ),\n );\n },\n};\n\nTheme.shadeColors();\n"],"mappings":";;;;;;;AAEA;;;;;;;;;;;;;;AAFA,IAAMA,UAAU,GAAG,aAAnB;AAIA,IAAMC,MAAM,GAAG,CAAC,QAAD,EAAW,OAAX,EAAoB,SAApB,CAAf;AACA,IAAMC,UAAU,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAnB;AAEO,IAAMC,KAAK,GAAG;EACnBC,GAAG,EAAE,eAAyB;IAAA,IAAxBC,MAAwB,uEAAfL,UAAe;IAC5B,IAAMM,KAAK,GAAGC,gBAAgB,CAACC,QAAQ,CAACC,aAAT,CAAuB,OAAvB,CAAD,CAA9B;IAEA,IAAMC,SAAS,GAAG,EAAlB;;IACA,mBAAIF,QAAQ,CAACG,WAAb,EAA0BC,OAA1B,CAAkC,UAACC,UAAD,EAAgB;M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