@designcrowd/library.brand-page 5.8.6 → 5.8.8

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.
Files changed (26) hide show
  1. package/lib/src/brand-page/components/media/Shape.mixin.js +3 -0
  2. package/lib/src/brand-page/constants/misc.constants.d.ts +0 -22
  3. package/lib/src/brand-page/constants/misc.constants.js +0 -22
  4. package/lib/src/brand-page/utils/color.util.d.ts +2 -0
  5. package/lib/src/brand-page/utils/color.util.js +13 -0
  6. package/lib/src/brand-page/utils/style.util.d.ts +6 -2
  7. package/lib/src/brand-page/utils/style.util.js +43 -27
  8. package/lib/src/brand-page-maker/components/admin-background-settings/AdminBackgroundSettings.mixin.d.ts +0 -22
  9. package/lib/src/brand-page-maker/stores/event-manager/event-manager-store.js +6 -0
  10. package/lib/src/index.mjs +14681 -13726
  11. package/lib/src/shared/content-settings/components/color-field/ColorField.mixin.d.ts +8 -26
  12. package/lib/src/shared/content-settings/components/color-field/ColorField.mixin.js +3 -2
  13. package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +0 -22
  14. package/package.json +2 -1
  15. package/src/brand-page/components/media/Shape.mixin.ts +4 -0
  16. package/src/brand-page/constants/misc.constants.ts +0 -22
  17. package/src/brand-page/utils/color.util.test.ts +47 -0
  18. package/src/brand-page/utils/color.util.ts +18 -0
  19. package/src/brand-page/utils/style.util.test.ts +1 -0
  20. package/src/brand-page/utils/style.util.ts +94 -27
  21. package/src/brand-page-maker/stores/event-manager/event-manager-store.ts +7 -0
  22. package/src/shared/content-settings/components/color-field/ColorField.mixin.ts +3 -2
  23. package/src/shared/content-settings/components/color-replacements-field/ColorReplacementsField.vue +126 -37
  24. package/lib/src/shared/content-settings/components/color-replacements-field/ColorReplacementsField.mixin.d.ts +0 -112
  25. package/lib/src/shared/content-settings/components/color-replacements-field/ColorReplacementsField.mixin.js +0 -104
  26. package/src/shared/content-settings/components/color-replacements-field/ColorReplacementsField.mixin.ts +0 -118
@@ -75,6 +75,9 @@ export default defineComponent({
75
75
  },
76
76
  methods: {
77
77
  async rerender() {
78
+ if (!this.originalSvgData) {
79
+ return;
80
+ }
78
81
  this.svgData = applyColorReplacementsToSvgString(this.originalSvgData, this.colorReplacements);
79
82
  this.svgData = this.svgData.replace('<svg ', `<svg ${this.svgAttributes} `);
80
83
  },
@@ -41,28 +41,6 @@ export declare const HEADER_CSRF_TOKEN = "csrf-token";
41
41
  export declare const STYLE_THEME_KEYS: Readonly<{
42
42
  LogoTextColor: "logo-text-color";
43
43
  LogoBackgroundColor: "logo-background-color";
44
- LogoTextColor50: "logo-text-color-50";
45
- LogoTextColor100: "logo-text-color-100";
46
- LogoTextColor200: "logo-text-color-200";
47
- LogoTextColor300: "logo-text-color-300";
48
- LogoTextColor400: "logo-text-color-400";
49
- LogoTextColor500: "logo-text-color-500";
50
- LogoTextColor600: "logo-text-color-600";
51
- LogoTextColor700: "logo-text-color-700";
52
- LogoTextColor800: "logo-text-color-800";
53
- LogoTextColor900: "logo-text-color-900";
54
- LogoTextColor950: "logo-text-color-950";
55
- LogoBackgroundColor50: "logo-background-color-50";
56
- LogoBackgroundColor100: "logo-background-color-100";
57
- LogoBackgroundColor200: "logo-background-color-200";
58
- LogoBackgroundColor300: "logo-background-color-300";
59
- LogoBackgroundColor400: "logo-background-color-400";
60
- LogoBackgroundColor500: "logo-background-color-500";
61
- LogoBackgroundColor600: "logo-background-color-600";
62
- LogoBackgroundColor700: "logo-background-color-700";
63
- LogoBackgroundColor800: "logo-background-color-800";
64
- LogoBackgroundColor900: "logo-background-color-900";
65
- LogoBackgroundColor950: "logo-background-color-950";
66
44
  }>;
67
45
  export declare const BoxShadowSpread = 0.5;
68
46
  export declare const ButtonBoxShadowSize = "3px 3px 0px 0px";
@@ -50,28 +50,6 @@ export const HEADER_CSRF_TOKEN = 'csrf-token';
50
50
  export const STYLE_THEME_KEYS = Object.freeze({
51
51
  LogoTextColor: 'logo-text-color',
52
52
  LogoBackgroundColor: 'logo-background-color',
53
- LogoTextColor50: 'logo-text-color-50',
54
- LogoTextColor100: 'logo-text-color-100',
55
- LogoTextColor200: 'logo-text-color-200',
56
- LogoTextColor300: 'logo-text-color-300',
57
- LogoTextColor400: 'logo-text-color-400',
58
- LogoTextColor500: 'logo-text-color-500',
59
- LogoTextColor600: 'logo-text-color-600',
60
- LogoTextColor700: 'logo-text-color-700',
61
- LogoTextColor800: 'logo-text-color-800',
62
- LogoTextColor900: 'logo-text-color-900',
63
- LogoTextColor950: 'logo-text-color-950',
64
- LogoBackgroundColor50: 'logo-background-color-50',
65
- LogoBackgroundColor100: 'logo-background-color-100',
66
- LogoBackgroundColor200: 'logo-background-color-200',
67
- LogoBackgroundColor300: 'logo-background-color-300',
68
- LogoBackgroundColor400: 'logo-background-color-400',
69
- LogoBackgroundColor500: 'logo-background-color-500',
70
- LogoBackgroundColor600: 'logo-background-color-600',
71
- LogoBackgroundColor700: 'logo-background-color-700',
72
- LogoBackgroundColor800: 'logo-background-color-800',
73
- LogoBackgroundColor900: 'logo-background-color-900',
74
- LogoBackgroundColor950: 'logo-background-color-950',
75
53
  });
76
54
  export const BoxShadowSpread = 0.5;
77
55
  export const ButtonBoxShadowSize = '3px 3px 0px 0px';
@@ -1,4 +1,5 @@
1
1
  import type { LogoTheme, Theme } from '../models';
2
+ import { type ColorInstance } from 'color';
2
3
  export declare const luminance: (r: number, g: number, b: number) => number;
3
4
  export declare const calculateLuminanceRatio: (color1: string, color2: string) => number;
4
5
  export declare const isHexTransparent: (hex: string) => boolean;
@@ -7,3 +8,4 @@ export declare const addTransparentAlphaChannelToHex: (hex: string) => string;
7
8
  export declare const addOpacityToHex: (hex: string, opacity: number) => string;
8
9
  export declare const setRgbAlpha: (rgb: string, alpha: number) => string;
9
10
  export declare const getThemeByTextStyleAndLogoTheme: (textStyle: BrandPageCssStyle, logoTheme: LogoTheme) => Theme;
11
+ export declare const getNewColorBasedOnTargetColorTheme: (originalColor: string, targetColor: string) => ColorInstance | undefined;
@@ -1,5 +1,6 @@
1
1
  import isHexColor from 'validator/lib/isHexColor';
2
2
  import { hexToRGBA, isColor } from '../../utils/helpers';
3
+ import Color, {} from 'color';
3
4
  // function from https://stackoverflow.com/a/9733420/3695983
4
5
  export const luminance = (r, g, b) => {
5
6
  const a = [r, g, b].map(function (v) {
@@ -62,3 +63,15 @@ export const getThemeByTextStyleAndLogoTheme = (textStyle, logoTheme) => {
62
63
  secondaryColor,
63
64
  };
64
65
  };
66
+ export const getNewColorBasedOnTargetColorTheme = (originalColor, targetColor) => {
67
+ try {
68
+ const originalColorGrayScaled = Color(originalColor).grayscale().hsl();
69
+ const targetHslColor = Color(targetColor)
70
+ .hsl()
71
+ .lightness(originalColorGrayScaled.lightness());
72
+ return targetHslColor.rgb();
73
+ }
74
+ catch (e) {
75
+ return;
76
+ }
77
+ };
@@ -1,12 +1,16 @@
1
1
  import type { BrandPageModel, LogoTheme, FabricLogoTheme, ButtonStyles, PageModel } from '../models';
2
2
  import { NavigationDesktop, NavigationMobile } from '../models';
3
3
  import { PageStyles, PageHeaderMobile, PageHeaderDesktop, PageFooterMobile, PageFooterDesktop } from '../models';
4
- export declare const colorMatchCssKeyValue: (cssKey: string, cssValue: string, logoTheme: LogoTheme) => {
4
+ export declare const colorMatchCssKeyValue: (cssKey: string, cssValue: string, logoTheme: LogoTheme, applyColorWithMatchingLuminance?: {
5
+ originalColor: string;
6
+ }) => {
5
7
  cssValue: string;
6
8
  isModified: boolean;
7
9
  };
8
10
  type Style = Record<string, string | any>;
9
- export declare const applyLogoThemeToBrandPageStyleRecursive: (logoTheme: LogoTheme, style: Style | Style[]) => {
11
+ export declare const applyLogoThemeToBrandPageStyleRecursive: (logoTheme: LogoTheme, attribute: string, style: Style | Style[], options?: {
12
+ isMultiColorShape: boolean;
13
+ }) => {
10
14
  newStyle: Style | Style[];
11
15
  isApplied: boolean;
12
16
  };
@@ -2,7 +2,7 @@ import { VIEWPORTS, NavigationDesktop, NavigationMobile } from '../models';
2
2
  import { PageStyles, PageHeaderMobile, PageHeaderDesktop, PageFooterMobile, PageFooterDesktop, } from '../models';
3
3
  import { STYLE_THEME_KEYS } from '../constants';
4
4
  import { arrayToLinearGradient, linearGradientToArray, isColorLinearGradient, RGBAtoHex, } from '../../utils/helpers';
5
- import { addTransparentAlphaChannelToHex, calculateLuminanceRatio, } from './color.util';
5
+ import { addTransparentAlphaChannelToHex, calculateLuminanceRatio, getNewColorBasedOnTargetColorTheme, } from './color.util';
6
6
  import chroma from 'chroma-js';
7
7
  const MIN_LUM_RATIO = 0.3;
8
8
  const parseFabricColorToCssStyle = (fabricColor) => {
@@ -31,32 +31,43 @@ const getColorValueForCorrectCssProperty = (k, colorData) => {
31
31
  ? colorData.gradient
32
32
  : colorData.rgb;
33
33
  };
34
- export const colorMatchCssKeyValue = (cssKey, cssValue, logoTheme) => {
35
- switch (cssValue) {
36
- case STYLE_THEME_KEYS.LogoBackgroundColor:
37
- cssValue = getColorValueForCorrectCssProperty(cssKey, logoTheme.logoBackgroundColor);
38
- return { cssValue, isModified: true };
39
- case STYLE_THEME_KEYS.LogoTextColor:
40
- cssValue = getColorValueForCorrectCssProperty(cssKey, logoTheme.logoTextColor);
41
- return { cssValue, isModified: true };
34
+ export const colorMatchCssKeyValue = (cssKey, cssValue, logoTheme, applyColorWithMatchingLuminance) => {
35
+ if (applyColorWithMatchingLuminance?.originalColor) {
36
+ const styleThemeMatch = Object.values(STYLE_THEME_KEYS).find((k) => cssValue === k);
37
+ if (styleThemeMatch) {
38
+ const theme = styleThemeMatch.startsWith(STYLE_THEME_KEYS.LogoTextColor)
39
+ ? logoTheme.logoTextColor
40
+ : logoTheme.logoBackgroundColor;
41
+ let newColor = applyColorWithMatchingLuminance.originalColor;
42
+ try {
43
+ newColor = getNewColorBasedOnTargetColorTheme(applyColorWithMatchingLuminance.originalColor, theme.rgb).toString();
44
+ }
45
+ catch (e) { }
46
+ return { cssValue: newColor, isModified: true };
47
+ }
48
+ }
49
+ if (cssValue.match(new RegExp(STYLE_THEME_KEYS.LogoTextColor, 'g'))) {
50
+ cssValue = getColorValueForCorrectCssProperty(cssKey, logoTheme.logoTextColor);
51
+ return { cssValue, isModified: true };
42
52
  }
43
- const match = Object.values(STYLE_THEME_KEYS).find((k) => cssValue === k);
44
- if (match) {
45
- const split = match.split('-');
46
- const colorShadeKey = split[split.length - 1];
47
- const colorKey = match.startsWith(STYLE_THEME_KEYS.LogoBackgroundColor)
48
- ? logoTheme.logoBackgroundColor
49
- : logoTheme.logoTextColor;
50
- return { cssValue: colorKey[colorShadeKey], isModified: true };
53
+ else if (cssValue.match(new RegExp(STYLE_THEME_KEYS.LogoBackgroundColor, 'g'))) {
54
+ cssValue = getColorValueForCorrectCssProperty(cssKey, logoTheme.logoBackgroundColor);
55
+ return { cssValue, isModified: true };
51
56
  }
52
57
  return { cssValue, isModified: false };
53
58
  };
54
- export const applyLogoThemeToBrandPageStyleRecursive = (logoTheme, style) => {
59
+ export const applyLogoThemeToBrandPageStyleRecursive = (logoTheme, attribute, style, options) => {
55
60
  let isApplied = false;
56
61
  let newStyle = {};
57
62
  if (Array.isArray(style)) {
58
63
  newStyle = style.map((s) => {
59
- const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, s);
64
+ const isShapeColorReplacement = attribute === 'colorReplacements';
65
+ const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, attribute, s, isShapeColorReplacement
66
+ ? {
67
+ isMultiColorShape: style.filter((x) => x.originalColor.toLowerCase() !== '' &&
68
+ x.originalColor.toLowerCase() !== 'none').length > 1,
69
+ }
70
+ : undefined);
60
71
  isApplied = isApplied || output.isApplied;
61
72
  return output.newStyle;
62
73
  });
@@ -64,12 +75,17 @@ export const applyLogoThemeToBrandPageStyleRecursive = (logoTheme, style) => {
64
75
  else if (style && typeof style === 'object') {
65
76
  for (const [key, value] of Object.entries(style)) {
66
77
  if (typeof value === 'string') {
67
- const output = colorMatchCssKeyValue(key, value, logoTheme);
78
+ const applyColorWithMatchingLuminance = options?.isMultiColorShape && key === `replacementColor`
79
+ ? {
80
+ originalColor: style[`originalColor`],
81
+ }
82
+ : undefined;
83
+ const output = colorMatchCssKeyValue(key, value, logoTheme, applyColorWithMatchingLuminance);
68
84
  newStyle[key] = output.cssValue;
69
85
  isApplied = isApplied || output.isModified;
70
86
  }
71
87
  else if (typeof value === 'object') {
72
- const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, value);
88
+ const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, key, value);
73
89
  newStyle[key] = output.newStyle;
74
90
  isApplied = isApplied || output.isApplied;
75
91
  // if (process.env.NODE_ENV !== 'production' && output.isApplied) {
@@ -115,7 +131,7 @@ export const applyLogoThemeToBrandPageNavigationStyles = (logoTheme, navigation)
115
131
  newNavigation[key] = value;
116
132
  }
117
133
  else {
118
- const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, value);
134
+ const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, key, value);
119
135
  newNavigation[key] = output.newStyle;
120
136
  isModified = isModified || output.isApplied;
121
137
  }
@@ -139,7 +155,7 @@ export const applyLogoThemeToBrandPageHeaderStyles = (logoTheme, pageHeader) =>
139
155
  newPageHeader[key] = value;
140
156
  }
141
157
  else {
142
- const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, value);
158
+ const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, key, value);
143
159
  newPageHeader[key] = output.newStyle;
144
160
  isModified = isModified || output.isApplied;
145
161
  }
@@ -162,7 +178,7 @@ export const applyLogoThemeToBrandPageFooterStyles = (logoTheme, pageFooter) =>
162
178
  newPageFooter[key] = value;
163
179
  }
164
180
  else {
165
- const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, value);
181
+ const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, key, value);
166
182
  newPageFooter[key] = output.newStyle;
167
183
  isModified = isModified || output.isApplied;
168
184
  }
@@ -186,7 +202,7 @@ export const applyLogoThemeToContents = (logoTheme, pages) => {
186
202
  .filter(([, v]) => typeof v === 'object')
187
203
  .map(([k]) => k);
188
204
  for (const styleKey of styleKeys) {
189
- const { newStyle, isApplied } = applyLogoThemeToBrandPageStyleRecursive(logoTheme, content[styleKey]);
205
+ const { newStyle, isApplied } = applyLogoThemeToBrandPageStyleRecursive(logoTheme, styleKey, content[styleKey]);
190
206
  newContent[styleKey] = newStyle;
191
207
  isModified = isModified || isApplied;
192
208
  }
@@ -202,13 +218,13 @@ export const applyLogoThemeToBrandPageStyles = (logoTheme, pageStyles) => {
202
218
  for (const [key, value] of Object.entries(pageStyles)) {
203
219
  if (Array.isArray(value)) {
204
220
  for (let i = 0; i < value.length; i++) {
205
- const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, value[i]);
221
+ const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, `pageStyles`, value[i]);
206
222
  newStyle[key] = output.newStyle;
207
223
  isModified = isModified || output.isApplied;
208
224
  }
209
225
  }
210
226
  else {
211
- const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, value);
227
+ const output = applyLogoThemeToBrandPageStyleRecursive(logoTheme, key, value);
212
228
  newStyle[key] = output.newStyle;
213
229
  isModified = isModified || output.isApplied;
214
230
  }
@@ -257,28 +257,6 @@ declare const _default: import("vue").DefineComponent<{}, {
257
257
  styleThemeKeys: Readonly<{
258
258
  LogoTextColor: "logo-text-color";
259
259
  LogoBackgroundColor: "logo-background-color";
260
- LogoTextColor50: "logo-text-color-50";
261
- LogoTextColor100: "logo-text-color-100";
262
- LogoTextColor200: "logo-text-color-200";
263
- LogoTextColor300: "logo-text-color-300";
264
- LogoTextColor400: "logo-text-color-400";
265
- LogoTextColor500: "logo-text-color-500";
266
- LogoTextColor600: "logo-text-color-600";
267
- LogoTextColor700: "logo-text-color-700";
268
- LogoTextColor800: "logo-text-color-800";
269
- LogoTextColor900: "logo-text-color-900";
270
- LogoTextColor950: "logo-text-color-950";
271
- LogoBackgroundColor50: "logo-background-color-50";
272
- LogoBackgroundColor100: "logo-background-color-100";
273
- LogoBackgroundColor200: "logo-background-color-200";
274
- LogoBackgroundColor300: "logo-background-color-300";
275
- LogoBackgroundColor400: "logo-background-color-400";
276
- LogoBackgroundColor500: "logo-background-color-500";
277
- LogoBackgroundColor600: "logo-background-color-600";
278
- LogoBackgroundColor700: "logo-background-color-700";
279
- LogoBackgroundColor800: "logo-background-color-800";
280
- LogoBackgroundColor900: "logo-background-color-900";
281
- LogoBackgroundColor950: "logo-background-color-950";
282
260
  }>;
283
261
  configOptions: {
284
262
  readonly style: "style";
@@ -42,6 +42,12 @@ const safePushToDataLayer = async (eventPayload, { waitForEventCallback } = {})
42
42
  },
43
43
  eventTimeout: EVENT_TIMEOUT_MS,
44
44
  });
45
+ // This timeout will resolve the promise if the eventCallback fails to resolve the promise
46
+ setTimeout(() => {
47
+ if (!isEventCallbackCalled) {
48
+ resolve(false);
49
+ }
50
+ }, EVENT_TIMEOUT_MS + 50);
45
51
  }
46
52
  else {
47
53
  window.dataLayer.push(eventPayload);