@mirai/core 0.1.49 → 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.
@@ -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 SELECTORS = {
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
- Object.entries(SELECTORS).forEach(_ref2 => {
34
- let [selector, props] = _ref2;
35
- try {
36
- const query = document.querySelector(selector);
37
- Object.entries(props).forEach(_ref3 => {
38
- let [variable, legacy] = _ref3;
39
- const value = getComputedStyle(query)[legacy];
40
- if (!(legacy === 'font-family' && value === 'Times')) setVariable(variable, value);
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","SELECTORS","body","theme","processed","setVariable","key","value","includes","document","documentElement","style","setProperty","trim","push","Object","entries","forEach","variable","legacy","getComputedStyle","getPropertyValue","selector","props","query","querySelector","error","console"],"sources":["../../src/helpers/theme.js"],"sourcesContent":["const VARIABLES = {\n '--mirai-ui-accent': '--corporative-color',\n '--mirai-ui-border-radius': '--border-radius',\n};\n\nconst SELECTORS = {\n body: {\n '--mirai-ui-font': 'font-family',\n '--mirai-ui-font-bold': 'font-family',\n '--mirai-ui-input-font': 'font-family',\n },\n};\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 Object.entries(SELECTORS).forEach(([selector, props]) => {\n try {\n const query = document.querySelector(selector);\n Object.entries(props).forEach(([variable, legacy]) => {\n const value = getComputedStyle(query)[legacy];\n if (!(legacy === 'font-family' && value === 'Times')) setVariable(variable, value);\n });\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n }\n });\n};\n"],"mappings":";;;;;;AAAA,MAAMA,SAAS,GAAG;EAChB,mBAAmB,EAAE,qBAAqB;EAC1C,0BAA0B,EAAE;AAC9B,CAAC;AAED,MAAMC,SAAS,GAAG;EAChBC,IAAI,EAAE;IACJ,iBAAiB,EAAE,aAAa;IAChC,sBAAsB,EAAE,aAAa;IACrC,uBAAuB,EAAE;EAC3B;AACF,CAAC;AAEM,MAAMC,KAAK,GAAG,MAAM;EACzB,MAAMC,SAAS,GAAG,EAAE;EAEpB,MAAMC,WAAW,GAAG,CAACC,GAAG,EAAEC,KAAK,KAAK;IAClC,IAAI,CAACA,KAAK,IAAIH,SAAS,CAACI,QAAQ,CAACF,GAAG,CAAC,EAAE;IAEvCG,QAAQ,CAACC,eAAe,CAACC,KAAK,CAACC,WAAW,CAACN,GAAG,EAAEC,KAAK,CAACM,IAAI,EAAE,CAAC;IAC7DT,SAAS,CAACU,IAAI,CAACR,GAAG,CAAC;EACrB,CAAC;;EAED;EACAS,MAAM,CAACC,OAAO,CAAChB,SAAS,CAAC,CAACiB,OAAO,CAAC,QAAwB;IAAA,IAAvB,CAACC,QAAQ,EAAEC,MAAM,CAAC;IACnDd,WAAW,CAACa,QAAQ,EAAEE,gBAAgB,CAACX,QAAQ,CAACC,eAAe,CAAC,CAACW,gBAAgB,CAACF,MAAM,CAAC,CAAC;EAC5F,CAAC,CAAC;;EAEF;EACAJ,MAAM,CAACC,OAAO,CAACf,SAAS,CAAC,CAACgB,OAAO,CAAC,SAAuB;IAAA,IAAtB,CAACK,QAAQ,EAAEC,KAAK,CAAC;IAClD,IAAI;MACF,MAAMC,KAAK,GAAGf,QAAQ,CAACgB,aAAa,CAACH,QAAQ,CAAC;MAC9CP,MAAM,CAACC,OAAO,CAACO,KAAK,CAAC,CAACN,OAAO,CAAC,SAAwB;QAAA,IAAvB,CAACC,QAAQ,EAAEC,MAAM,CAAC;QAC/C,MAAMZ,KAAK,GAAGa,gBAAgB,CAACI,KAAK,CAAC,CAACL,MAAM,CAAC;QAC7C,IAAI,EAAEA,MAAM,KAAK,aAAa,IAAIZ,KAAK,KAAK,OAAO,CAAC,EAAEF,WAAW,CAACa,QAAQ,EAAEX,KAAK,CAAC;MACpF,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOmB,KAAK,EAAE;MACd;MACAC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;IACtB;EACF,CAAC,CAAC;AACJ,CAAC;AAAC"}
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,MAAM;EACzB,MAAMC,SAAS,GAAG,EAAE;EAEpB,MAAMC,WAAW,GAAG,CAACC,GAAG,EAAEC,KAAK,KAAK;IAClC,IAAI,CAACA,KAAK,IAAIH,SAAS,CAACI,QAAQ,CAACF,GAAG,CAAC,EAAE;IAEvCG,QAAQ,CAACC,eAAe,CAACC,KAAK,CAACC,WAAW,CAACN,GAAG,EAAEC,KAAK,CAACM,IAAI,EAAE,CAAC;IAC7DT,SAAS,CAACU,IAAI,CAACR,GAAG,CAAC;EACrB,CAAC;;EAED;EACAS,MAAM,CAACC,OAAO,CAACf,SAAS,CAAC,CAACgB,OAAO,CAAC,QAAwB;IAAA,IAAvB,CAACC,QAAQ,EAAEC,MAAM,CAAC;IACnDd,WAAW,CAACa,QAAQ,EAAEE,gBAAgB,CAACX,QAAQ,CAACC,eAAe,CAAC,CAACW,gBAAgB,CAACF,MAAM,CAAC,CAAC;EAC5F,CAAC,CAAC;;EAEF;EACA,SAASG,OAAO,GAAG;IACjB,IAAIC,IAAI;IAER,MAAMC,QAAQ,GAAGC,MAAM,CAACL,gBAAgB,CAACX,QAAQ,CAACiB,IAAI,CAAC,CAACL,gBAAgB,CAACnB,WAAW,CAAC;IACrF,IAAIsB,QAAQ,IAAIA,QAAQ,KAAK,mBAAmB,EAAE;MAChDD,IAAI,GAAGC,QAAQ;IACjB,CAAC,MAAM;MACL,MAAMG,IAAI,GAAGlB,QAAQ,CAACmB,aAAa,CAAC,QAAQ,CAAC;MAC7C,MAAMC,QAAQ,GAAGF,IAAI,GAAGF,MAAM,CAACL,gBAAgB,CAACO,IAAI,CAAC,CAACN,gBAAgB,CAACnB,WAAW,CAAC,GAAG4B,SAAS;MAC/F,IAAID,QAAQ,IAAIA,QAAQ,KAAK,mBAAmB,EAAEN,IAAI,GAAGM,QAAQ;IACnE;IAEA,OAAON,IAAI;EACb;EAEA,MAAMA,IAAI,GAAGD,OAAO,EAAE;EACtB,IAAIC,IAAI,EAAElB,WAAW,CAAC,iBAAiB,EAAEkB,IAAI,CAAC;AAChD,CAAC;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirai/core",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "source": "src/index.js",
5
5
  "repository": "https://gitlab.com/miraicorp/dev/frontend/core",
6
6
  "author": "JΛVI <hello@soyjavi.com>",