@mirai/core 0.1.48 → 0.1.50
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/helpers/theme.js +14 -20
- package/build/helpers/theme.js.map +1 -1
- package/package.json +1 -1
package/build/helpers/theme.js
CHANGED
|
@@ -8,13 +8,7 @@ const VARIABLES = {
|
|
|
8
8
|
'--mirai-ui-accent': '--corporative-color',
|
|
9
9
|
'--mirai-ui-border-radius': '--border-radius'
|
|
10
10
|
};
|
|
11
|
-
const
|
|
12
|
-
body: {
|
|
13
|
-
'--mirai-ui-font': 'font-family',
|
|
14
|
-
'--mirai-ui-font-bold': 'font-family',
|
|
15
|
-
'--mirai-ui-input-font': 'font-family'
|
|
16
|
-
}
|
|
17
|
-
};
|
|
11
|
+
const FONT_FAMILY = 'font-family';
|
|
18
12
|
const theme = () => {
|
|
19
13
|
const processed = [];
|
|
20
14
|
const setVariable = (key, value) => {
|
|
@@ -30,20 +24,20 @@ const theme = () => {
|
|
|
30
24
|
});
|
|
31
25
|
|
|
32
26
|
// CSS Selectors
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} catch (error) {
|
|
43
|
-
// eslint-disable-next-line no-console
|
|
44
|
-
console.error(error);
|
|
27
|
+
function getFont() {
|
|
28
|
+
let font;
|
|
29
|
+
const bodyFont = window.getComputedStyle(document.body).getPropertyValue(FONT_FAMILY);
|
|
30
|
+
if (bodyFont && bodyFont !== '"Times New Roman"') {
|
|
31
|
+
font = bodyFont;
|
|
32
|
+
} else {
|
|
33
|
+
const miBe = document.querySelector('.mi-be');
|
|
34
|
+
const miBeFont = miBe ? window.getComputedStyle(miBe).getPropertyValue(FONT_FAMILY) : undefined;
|
|
35
|
+
if (miBeFont && miBeFont !== '"Times New Roman"') font = miBeFont;
|
|
45
36
|
}
|
|
46
|
-
|
|
37
|
+
return font;
|
|
38
|
+
}
|
|
39
|
+
const font = getFont();
|
|
40
|
+
if (font) setVariable('--mirai-ui-font', font);
|
|
47
41
|
};
|
|
48
42
|
exports.theme = theme;
|
|
49
43
|
//# sourceMappingURL=theme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":["VARIABLES","
|
|
1
|
+
{"version":3,"file":"theme.js","names":["VARIABLES","FONT_FAMILY","theme","processed","setVariable","key","value","includes","document","documentElement","style","setProperty","trim","push","Object","entries","forEach","variable","legacy","getComputedStyle","getPropertyValue","getFont","font","bodyFont","window","body","miBe","querySelector","miBeFont","undefined"],"sources":["../../src/helpers/theme.js"],"sourcesContent":["const VARIABLES = {\n '--mirai-ui-accent': '--corporative-color',\n '--mirai-ui-border-radius': '--border-radius',\n};\n\nconst FONT_FAMILY = 'font-family';\n\nexport const theme = () => {\n const processed = [];\n\n const setVariable = (key, value) => {\n if (!value || processed.includes(key)) return;\n\n document.documentElement.style.setProperty(key, value.trim());\n processed.push(key);\n };\n\n // CSS variables\n Object.entries(VARIABLES).forEach(([variable, legacy]) => {\n setVariable(variable, getComputedStyle(document.documentElement).getPropertyValue(legacy));\n });\n\n // CSS Selectors\n function getFont() {\n let font;\n\n const bodyFont = window.getComputedStyle(document.body).getPropertyValue(FONT_FAMILY);\n if (bodyFont && bodyFont !== '\"Times New Roman\"') {\n font = bodyFont;\n } else {\n const miBe = document.querySelector('.mi-be');\n const miBeFont = miBe ? window.getComputedStyle(miBe).getPropertyValue(FONT_FAMILY) : undefined;\n if (miBeFont && miBeFont !== '\"Times New Roman\"') font = miBeFont;\n }\n\n return font;\n }\n\n const font = getFont();\n if (font) setVariable('--mirai-ui-font', font);\n};\n"],"mappings":";;;;;;AAAA,MAAMA,SAAS,GAAG;EAChB,mBAAmB,EAAE,qBAAqB;EAC1C,0BAA0B,EAAE;AAC9B,CAAC;AAED,MAAMC,WAAW,GAAG,aAAa;AAE1B,MAAMC,KAAK,GAAG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