@gem-sdk/pages 1.44.0-dev.143 → 1.44.0-dev.146

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.
@@ -14,57 +14,72 @@ const getFontsFromDataBuilder = (dataBuilder)=>{
14
14
  return fonts;
15
15
  };
16
16
  const getFontFromGroupSetting = (fonts, groupSetting)=>{
17
+ const states = [
18
+ 'normal',
19
+ 'hover',
20
+ 'focus',
21
+ 'active',
22
+ 'disabled',
23
+ 'price',
24
+ 'compareAtPrice'
25
+ ];
17
26
  for(const attr in groupSetting){
18
27
  if (Object.prototype.hasOwnProperty.call(groupSetting, attr)) {
19
28
  const value = groupSetting[attr];
20
- if (value) {
21
- let customFontFamily = value.custom?.fontFamily;
22
- if (typeof customFontFamily === 'string') {
23
- customFontFamily = {
24
- value: value.custom?.fontFamily || '',
25
- type: 'google'
26
- };
27
- }
28
- const fontFamily = customFontFamily?.value;
29
- let customFontVariants = value.custom?.fontVariants;
30
- if (!customFontVariants?.length) {
31
- customFontVariants = [
32
- value.custom?.fontWeight
29
+ if (!value) continue;
30
+ getFontValue(fonts, value);
31
+ for (const state of states){
32
+ if (!value[state]) continue;
33
+ getFontValue(fonts, value[state]);
34
+ }
35
+ }
36
+ }
37
+ };
38
+ const getFontValue = (fonts, value)=>{
39
+ let customFontFamily = value.custom?.fontFamily;
40
+ if (typeof customFontFamily === 'string') {
41
+ customFontFamily = {
42
+ value: value.custom?.fontFamily || '',
43
+ type: 'google'
44
+ };
45
+ }
46
+ const fontFamily = customFontFamily?.value;
47
+ let customFontVariants = value.custom?.fontVariants;
48
+ if (!customFontVariants?.length) {
49
+ customFontVariants = [
50
+ value.custom?.fontWeight
51
+ ];
52
+ }
53
+ if (customFontFamily && customFontVariants?.length) {
54
+ const variants = customFontVariants.map((item)=>{
55
+ switch(item){
56
+ case 'regular':
57
+ return '400';
58
+ }
59
+ return item;
60
+ });
61
+ const customFontWeight = value.custom?.fontWeight && variants.includes(value.custom?.fontWeight) ? value.custom?.fontWeight : variants[0];
62
+ if (customFontWeight) {
63
+ const isExist = fonts.find((item)=>item.family == fontFamily && item.variants.includes(customFontWeight));
64
+ if (!isExist) {
65
+ const isFontFamily = fonts.find((item)=>item.family == fontFamily);
66
+ if (isFontFamily) {
67
+ isFontFamily.variants.push(customFontWeight);
68
+ } else {
69
+ const fontVariants = [
70
+ customFontWeight
33
71
  ];
34
- }
35
- if (customFontFamily && customFontVariants?.length) {
36
- const variants = customFontVariants.map((item)=>{
37
- switch(item){
38
- case 'regular':
39
- return '400';
40
- }
41
- return item;
42
- });
43
- const customFontWeight = value.custom?.fontWeight && variants.includes(value.custom?.fontWeight) ? value.custom?.fontWeight : variants[0];
44
- if (customFontWeight) {
45
- const isExist = fonts.find((item)=>item.family == fontFamily && item.variants.includes(customFontWeight));
46
- if (!isExist) {
47
- const isFontFamily = fonts.find((item)=>item.family == fontFamily);
48
- if (isFontFamily) {
49
- isFontFamily.variants.push(customFontWeight);
50
- } else {
51
- const fontVariants = [
52
- customFontWeight
53
- ];
54
- if (customFontWeight !== '700') {
55
- if (variants.includes('700')) {
56
- fontVariants.push('700'); // Auto add 700 for bold in editor inline
57
- }
58
- }
59
- fonts.push({
60
- family: fontFamily || '',
61
- variants: fontVariants,
62
- subsets: [],
63
- type: customFontFamily.type
64
- });
65
- }
72
+ if (customFontWeight !== '700') {
73
+ if (variants.includes('700')) {
74
+ fontVariants.push('700'); // Auto add 700 for bold in editor inline
66
75
  }
67
76
  }
77
+ fonts.push({
78
+ family: fontFamily || '',
79
+ variants: fontVariants,
80
+ subsets: [],
81
+ type: customFontFamily.type
82
+ });
68
83
  }
69
84
  }
70
85
  }
@@ -12,57 +12,72 @@ const getFontsFromDataBuilder = (dataBuilder)=>{
12
12
  return fonts;
13
13
  };
14
14
  const getFontFromGroupSetting = (fonts, groupSetting)=>{
15
+ const states = [
16
+ 'normal',
17
+ 'hover',
18
+ 'focus',
19
+ 'active',
20
+ 'disabled',
21
+ 'price',
22
+ 'compareAtPrice'
23
+ ];
15
24
  for(const attr in groupSetting){
16
25
  if (Object.prototype.hasOwnProperty.call(groupSetting, attr)) {
17
26
  const value = groupSetting[attr];
18
- if (value) {
19
- let customFontFamily = value.custom?.fontFamily;
20
- if (typeof customFontFamily === 'string') {
21
- customFontFamily = {
22
- value: value.custom?.fontFamily || '',
23
- type: 'google'
24
- };
25
- }
26
- const fontFamily = customFontFamily?.value;
27
- let customFontVariants = value.custom?.fontVariants;
28
- if (!customFontVariants?.length) {
29
- customFontVariants = [
30
- value.custom?.fontWeight
27
+ if (!value) continue;
28
+ getFontValue(fonts, value);
29
+ for (const state of states){
30
+ if (!value[state]) continue;
31
+ getFontValue(fonts, value[state]);
32
+ }
33
+ }
34
+ }
35
+ };
36
+ const getFontValue = (fonts, value)=>{
37
+ let customFontFamily = value.custom?.fontFamily;
38
+ if (typeof customFontFamily === 'string') {
39
+ customFontFamily = {
40
+ value: value.custom?.fontFamily || '',
41
+ type: 'google'
42
+ };
43
+ }
44
+ const fontFamily = customFontFamily?.value;
45
+ let customFontVariants = value.custom?.fontVariants;
46
+ if (!customFontVariants?.length) {
47
+ customFontVariants = [
48
+ value.custom?.fontWeight
49
+ ];
50
+ }
51
+ if (customFontFamily && customFontVariants?.length) {
52
+ const variants = customFontVariants.map((item)=>{
53
+ switch(item){
54
+ case 'regular':
55
+ return '400';
56
+ }
57
+ return item;
58
+ });
59
+ const customFontWeight = value.custom?.fontWeight && variants.includes(value.custom?.fontWeight) ? value.custom?.fontWeight : variants[0];
60
+ if (customFontWeight) {
61
+ const isExist = fonts.find((item)=>item.family == fontFamily && item.variants.includes(customFontWeight));
62
+ if (!isExist) {
63
+ const isFontFamily = fonts.find((item)=>item.family == fontFamily);
64
+ if (isFontFamily) {
65
+ isFontFamily.variants.push(customFontWeight);
66
+ } else {
67
+ const fontVariants = [
68
+ customFontWeight
31
69
  ];
32
- }
33
- if (customFontFamily && customFontVariants?.length) {
34
- const variants = customFontVariants.map((item)=>{
35
- switch(item){
36
- case 'regular':
37
- return '400';
38
- }
39
- return item;
40
- });
41
- const customFontWeight = value.custom?.fontWeight && variants.includes(value.custom?.fontWeight) ? value.custom?.fontWeight : variants[0];
42
- if (customFontWeight) {
43
- const isExist = fonts.find((item)=>item.family == fontFamily && item.variants.includes(customFontWeight));
44
- if (!isExist) {
45
- const isFontFamily = fonts.find((item)=>item.family == fontFamily);
46
- if (isFontFamily) {
47
- isFontFamily.variants.push(customFontWeight);
48
- } else {
49
- const fontVariants = [
50
- customFontWeight
51
- ];
52
- if (customFontWeight !== '700') {
53
- if (variants.includes('700')) {
54
- fontVariants.push('700'); // Auto add 700 for bold in editor inline
55
- }
56
- }
57
- fonts.push({
58
- family: fontFamily || '',
59
- variants: fontVariants,
60
- subsets: [],
61
- type: customFontFamily.type
62
- });
63
- }
70
+ if (customFontWeight !== '700') {
71
+ if (variants.includes('700')) {
72
+ fontVariants.push('700'); // Auto add 700 for bold in editor inline
64
73
  }
65
74
  }
75
+ fonts.push({
76
+ family: fontFamily || '',
77
+ variants: fontVariants,
78
+ subsets: [],
79
+ type: customFontFamily.type
80
+ });
66
81
  }
67
82
  }
68
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/pages",
3
- "version": "1.44.0-dev.143",
3
+ "version": "1.44.0-dev.146",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -26,7 +26,7 @@
26
26
  "next": "latest"
27
27
  },
28
28
  "devDependencies": {
29
- "@gem-sdk/core": "1.44.0-dev.143",
29
+ "@gem-sdk/core": "1.44.0-dev.145",
30
30
  "@gem-sdk/plugin-cookie-bar": "1.44.0-dev.143",
31
31
  "@gem-sdk/plugin-quick-view": "1.44.0-dev.143",
32
32
  "@gem-sdk/plugin-sticky-add-to-cart": "1.44.0-dev.143"