@bigbinary/neeto-themes-frontend 1.1.22 → 1.1.23

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/index.cjs.js CHANGED
@@ -617,6 +617,36 @@ var useCloneTheme = function useCloneTheme() {
617
617
  });
618
618
  };
619
619
 
620
+ var root = document.querySelector(":root");
621
+ var setVariable = function setVariable(name, value, variableNamesMap) {
622
+ var variableName = variableNamesMap[name];
623
+ if (!variableName) return;
624
+ root.style.setProperty(variableName, value);
625
+ };
626
+ var setTheme = function setTheme(theme, variableNamesMap, themeConfig) {
627
+ if (neetoCist.isNotPresent(theme === null || theme === void 0 ? void 0 : theme.properties)) return;
628
+ theme.properties.forEach(function (property) {
629
+ var attribute = neetoCist.snakeToCamelCase(property.key);
630
+ if (property.kind === "color") {
631
+ setVariable(attribute, hexToRgba(property.value), variableNamesMap);
632
+ } else if (property.kind === "overlay_opacity") {
633
+ var overlayOpacity = Number(property.value);
634
+ setVariable(neetoCist.snakeToCamelCase("".concat(property.key, "_overlay_opacity")), Math.abs(overlayOpacity / 100), variableNamesMap);
635
+ setVariable(neetoCist.snakeToCamelCase("".concat(property.key, "_overlay_color")), overlayOpacity < 0 ? BLACK : WHITE, variableNamesMap);
636
+ } else {
637
+ setVariable(attribute, property.value, variableNamesMap);
638
+ }
639
+ });
640
+ neetoCist.filterBy({
641
+ kind: "image"
642
+ }, themeConfig).forEach(function (_ref) {
643
+ var _theme$attribute;
644
+ var key = _ref.key;
645
+ var attribute = neetoCist.snakeToCamelCase(key);
646
+ setVariable(attribute, "url(".concat((_theme$attribute = theme[attribute]) === null || _theme$attribute === void 0 ? void 0 : _theme$attribute.url, ")"), variableNamesMap);
647
+ });
648
+ };
649
+
620
650
  var list = function list() {
621
651
  return axios__default["default"].get("".concat(BASE_URL, "/api/v1/theme/configs"));
622
652
  };
@@ -665,38 +695,15 @@ var useThemeUtils = function useThemeUtils() {
665
695
  isFetchingConfig: isFetchingConfig
666
696
  });
667
697
  }, [isFetchingConfig]);
668
- var root = document.querySelector(":root");
669
- var setVariable = function setVariable(name, value) {
670
- var variableName = variableNamesMap[name];
671
- if (!variableName) return;
672
- root.style.setProperty(variableName, value);
698
+ var setVariable$1 = function setVariable$1(name, value) {
699
+ return setVariable(name, value, variableNamesMap);
673
700
  };
674
- var setTheme = function setTheme(theme) {
675
- if (neetoCist.isNotPresent(theme === null || theme === void 0 ? void 0 : theme.properties)) return;
676
- theme.properties.forEach(function (property) {
677
- var attribute = neetoCist.snakeToCamelCase(property.key);
678
- if (property.kind === "color") {
679
- setVariable(attribute, hexToRgba(property.value));
680
- } else if (property.kind === "overlay_opacity") {
681
- var overlayOpacity = Number(property.value);
682
- setVariable(neetoCist.snakeToCamelCase("".concat(property.key, "_overlay_opacity")), Math.abs(overlayOpacity / 100));
683
- setVariable(neetoCist.snakeToCamelCase("".concat(property.key, "_overlay_color")), overlayOpacity < 0 ? BLACK : WHITE);
684
- } else {
685
- setVariable(attribute, property.value);
686
- }
687
- });
688
- neetoCist.filterBy({
689
- kind: "image"
690
- }, themeConfig).forEach(function (_ref2) {
691
- var _theme$attribute;
692
- var key = _ref2.key;
693
- var attribute = neetoCist.snakeToCamelCase(key);
694
- setVariable(attribute, "url(".concat((_theme$attribute = theme[attribute]) === null || _theme$attribute === void 0 ? void 0 : _theme$attribute.url, ")"));
695
- });
701
+ var setTheme$1 = function setTheme$1(theme) {
702
+ return setTheme(theme, variableNamesMap, themeConfig);
696
703
  };
697
704
  return {
698
- setTheme: setTheme,
699
- setVariable: setVariable,
705
+ setTheme: setTheme$1,
706
+ setVariable: setVariable$1,
700
707
  previewingTheme: previewingTheme,
701
708
  currentTheme: currentTheme,
702
709
  isFetchingConfig: isFetchingConfig
@@ -24269,5 +24276,6 @@ var css = ".neeto-themes__wrapper{display:flex;width:100%}.neeto-themes__wrapper
24269
24276
  n(css,{});
24270
24277
 
24271
24278
  exports.NeetoThemes = index;
24279
+ exports.setTheme = setTheme;
24272
24280
  exports.useThemeUtils = useThemeUtils;
24273
24281
  //# sourceMappingURL=index.cjs.js.map