@ikas/storefront 0.0.167-alpha.5 → 0.0.167-alpha.7

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/index.es.js CHANGED
@@ -41470,18 +41470,14 @@ var IkasPage = observer(function (_a) {
41470
41470
  IkasStorefrontConfig.initWithJson(configJson);
41471
41471
  var store = IkasStorefrontConfig.store;
41472
41472
  var router = useRouter();
41473
- var _b = useState(false); _b[0]; var setMounted = _b[1];
41474
- var _c = useState(false), isBrowser = _c[0], setIsBrowser = _c[1];
41473
+ var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
41475
41474
  var settings = useState(new IkasThemeSettings(JSON.parse(settingsStr)))[0];
41476
- var _d = useState(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr)), propValues = _d[0], setPropValues = _d[1];
41475
+ var _c = useState(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr)), propValues = _c[0], setPropValues = _c[1];
41477
41476
  store.currentPageType = pageType;
41478
41477
  useEffect(function () {
41479
- //@ts-ignore
41480
- store.setSettings(settingsStr);
41481
41478
  //@ts-ignore
41482
41479
  store.cartStore.getCart();
41483
41480
  store.checkLocalization();
41484
- setMounted(true);
41485
41481
  }, []);
41486
41482
  useEffect(function () {
41487
41483
  if (reInitOnBrowser)
@@ -41495,7 +41491,6 @@ var IkasPage = observer(function (_a) {
41495
41491
  var footerComponentPropValue = propValues.find(function (pv) { return pv.component.isFooter; });
41496
41492
  var others = propValues.filter(function (pv) { return !pv.component.isHeader && !pv.component.isFooter; }) || [];
41497
41493
  var pageStyle = {
41498
- visibility: "visible",
41499
41494
  position: "relative",
41500
41495
  minHeight: "100vh",
41501
41496
  display: "flex",
@@ -70130,7 +70125,7 @@ var SettingsHelper = /** @class */ (function () {
70130
70125
  SettingsHelper.getSettings = function (locale) {
70131
70126
  var _this = this;
70132
70127
  return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
70133
- var isLocal, storefrontResponse, storefront, localTheme, settings, storefront_1, salesChannel_1, localizationMap, storefrontJSScripts_1, domain_1, themeLocalizationPath, routing_1;
70128
+ var isLocal, storefrontResponse, storefront, localTheme, colorScript, settings, storefront_1, salesChannel_1, localizationMap, storefrontJSScripts_1, domain_1, themeLocalizationPath, routing_1;
70134
70129
  return __generator(this, function (_a) {
70135
70130
  switch (_a.label) {
70136
70131
  case 0:
@@ -70149,6 +70144,7 @@ var SettingsHelper = /** @class */ (function () {
70149
70144
  return [4 /*yield*/, SettingsHelper.readLocalTheme()];
70150
70145
  case 2:
70151
70146
  localTheme = _a.sent();
70147
+ colorScript = SettingsHelper.createColorScript(localTheme.settings);
70152
70148
  resolve({
70153
70149
  storefront: storefront,
70154
70150
  themeLocalization: new IkasStorefrontThemeLocalization({
@@ -70163,7 +70159,7 @@ var SettingsHelper = /** @class */ (function () {
70163
70159
  : new IkasStorefrontRouting({}),
70164
70160
  favicon: localTheme.settings.favicon,
70165
70161
  stockPreference: localTheme.settings.stockPreference,
70166
- storefrontJSScripts: [],
70162
+ storefrontJSScripts: colorScript ? [colorScript] : [],
70167
70163
  domain: "",
70168
70164
  });
70169
70165
  return [3 /*break*/, 5];
@@ -70195,6 +70191,11 @@ var SettingsHelper = /** @class */ (function () {
70195
70191
  var themeLocalization = new IkasStorefrontThemeLocalization(result);
70196
70192
  var favicon = themeLocalization.themeJson.settings.favicon;
70197
70193
  var stockPreference = themeLocalization.themeJson.settings.stockPreference;
70194
+ if (themeLocalization.themeJson.settings) {
70195
+ var colorScript = SettingsHelper.createColorScript(themeLocalization.themeJson.settings);
70196
+ if (colorScript)
70197
+ storefrontJSScripts_1.push(colorScript);
70198
+ }
70198
70199
  resolve({
70199
70200
  storefront: storefront_1,
70200
70201
  themeLocalization: themeLocalization,
@@ -70355,6 +70356,15 @@ var SettingsHelper = /** @class */ (function () {
70355
70356
  });
70356
70357
  });
70357
70358
  };
70359
+ SettingsHelper.createColorScript = function (settings) {
70360
+ if (!settings.colors)
70361
+ return;
70362
+ return "<script>" + settings.colors
70363
+ .map(function (sc) {
70364
+ return "document.documentElement.style.setProperty(\"" + sc.key + "\",\"" + sc.color + "\");";
70365
+ })
70366
+ .join("\r\n") + "</script> \n ";
70367
+ };
70358
70368
  return SettingsHelper;
70359
70369
  }());
70360
70370
 
package/build/index.js CHANGED
@@ -41450,18 +41450,14 @@ var IkasPage = mobxReactLite.observer(function (_a) {
41450
41450
  IkasStorefrontConfig.initWithJson(configJson);
41451
41451
  var store = IkasStorefrontConfig.store;
41452
41452
  var router$1 = router.useRouter();
41453
- var _b = React.useState(false); _b[0]; var setMounted = _b[1];
41454
- var _c = React.useState(false), isBrowser = _c[0], setIsBrowser = _c[1];
41453
+ var _b = React.useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
41455
41454
  var settings = React.useState(new IkasThemeSettings(JSON.parse(settingsStr)))[0];
41456
- var _d = React.useState(IkasPageDataProvider.initPropValues(propValuesStr, router$1, settingsStr)), propValues = _d[0], setPropValues = _d[1];
41455
+ var _c = React.useState(IkasPageDataProvider.initPropValues(propValuesStr, router$1, settingsStr)), propValues = _c[0], setPropValues = _c[1];
41457
41456
  store.currentPageType = pageType;
41458
41457
  React.useEffect(function () {
41459
- //@ts-ignore
41460
- store.setSettings(settingsStr);
41461
41458
  //@ts-ignore
41462
41459
  store.cartStore.getCart();
41463
41460
  store.checkLocalization();
41464
- setMounted(true);
41465
41461
  }, []);
41466
41462
  React.useEffect(function () {
41467
41463
  if (reInitOnBrowser)
@@ -41475,7 +41471,6 @@ var IkasPage = mobxReactLite.observer(function (_a) {
41475
41471
  var footerComponentPropValue = propValues.find(function (pv) { return pv.component.isFooter; });
41476
41472
  var others = propValues.filter(function (pv) { return !pv.component.isHeader && !pv.component.isFooter; }) || [];
41477
41473
  var pageStyle = {
41478
- visibility: "visible",
41479
41474
  position: "relative",
41480
41475
  minHeight: "100vh",
41481
41476
  display: "flex",
@@ -70109,7 +70104,7 @@ var SettingsHelper = /** @class */ (function () {
70109
70104
  SettingsHelper.getSettings = function (locale) {
70110
70105
  var _this = this;
70111
70106
  return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
70112
- var isLocal, storefrontResponse, storefront, localTheme, settings, storefront_1, salesChannel_1, localizationMap, storefrontJSScripts_1, domain_1, themeLocalizationPath, routing_1;
70107
+ var isLocal, storefrontResponse, storefront, localTheme, colorScript, settings, storefront_1, salesChannel_1, localizationMap, storefrontJSScripts_1, domain_1, themeLocalizationPath, routing_1;
70113
70108
  return __generator(this, function (_a) {
70114
70109
  switch (_a.label) {
70115
70110
  case 0:
@@ -70128,6 +70123,7 @@ var SettingsHelper = /** @class */ (function () {
70128
70123
  return [4 /*yield*/, SettingsHelper.readLocalTheme()];
70129
70124
  case 2:
70130
70125
  localTheme = _a.sent();
70126
+ colorScript = SettingsHelper.createColorScript(localTheme.settings);
70131
70127
  resolve({
70132
70128
  storefront: storefront,
70133
70129
  themeLocalization: new IkasStorefrontThemeLocalization({
@@ -70142,7 +70138,7 @@ var SettingsHelper = /** @class */ (function () {
70142
70138
  : new IkasStorefrontRouting({}),
70143
70139
  favicon: localTheme.settings.favicon,
70144
70140
  stockPreference: localTheme.settings.stockPreference,
70145
- storefrontJSScripts: [],
70141
+ storefrontJSScripts: colorScript ? [colorScript] : [],
70146
70142
  domain: "",
70147
70143
  });
70148
70144
  return [3 /*break*/, 5];
@@ -70174,6 +70170,11 @@ var SettingsHelper = /** @class */ (function () {
70174
70170
  var themeLocalization = new IkasStorefrontThemeLocalization(result);
70175
70171
  var favicon = themeLocalization.themeJson.settings.favicon;
70176
70172
  var stockPreference = themeLocalization.themeJson.settings.stockPreference;
70173
+ if (themeLocalization.themeJson.settings) {
70174
+ var colorScript = SettingsHelper.createColorScript(themeLocalization.themeJson.settings);
70175
+ if (colorScript)
70176
+ storefrontJSScripts_1.push(colorScript);
70177
+ }
70177
70178
  resolve({
70178
70179
  storefront: storefront_1,
70179
70180
  themeLocalization: themeLocalization,
@@ -70334,6 +70335,15 @@ var SettingsHelper = /** @class */ (function () {
70334
70335
  });
70335
70336
  });
70336
70337
  };
70338
+ SettingsHelper.createColorScript = function (settings) {
70339
+ if (!settings.colors)
70340
+ return;
70341
+ return "<script>" + settings.colors
70342
+ .map(function (sc) {
70343
+ return "document.documentElement.style.setProperty(\"" + sc.key + "\",\"" + sc.color + "\");";
70344
+ })
70345
+ .join("\r\n") + "</script> \n ";
70346
+ };
70337
70347
  return SettingsHelper;
70338
70348
  }());
70339
70349
 
@@ -7,7 +7,7 @@ import { IkasSalesChannel } from "../models/data/sales-channel/index";
7
7
  import { IkasStorefrontRouting } from "../models/data/storefront/routing/index";
8
8
  import { IkasStorefrontThemeLocalization } from "../models/data/storefront/theme-localization/index";
9
9
  import { IkasThemeFavicon } from "../models/theme/settings/prop/favicon/index";
10
- import { IkasThemeStockPreference } from "../models/theme/settings/index";
10
+ import { IkasThemeSettings, IkasThemeStockPreference } from "../models/theme/settings/index";
11
11
  export declare class SettingsHelper {
12
12
  static readLocalTheme(): Promise<IkasTheme>;
13
13
  static readSettingsFile(): Promise<any>;
@@ -213,6 +213,7 @@ export declare class SettingsHelper {
213
213
  notFound?: undefined;
214
214
  revalidate?: undefined;
215
215
  }>;
216
+ static createColorScript(settings: IkasThemeSettings): string | undefined;
216
217
  }
217
218
  export declare type SettingsData = {
218
219
  storefront: IkasStorefront;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.167-alpha.5",
3
+ "version": "0.0.167-alpha.7",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",