@gem-sdk/pages 2.0.0-dev.549 → 2.0.0-dev.576
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/cjs/components/builder/Toolbox.js +7 -4
- package/dist/cjs/components/composable/getListFontWeightTypos.js +14 -0
- package/dist/cjs/components/image-to-layout/DropElement.js +10 -5
- package/dist/cjs/libs/google-fonts.js +24 -4
- package/dist/esm/components/builder/Toolbox.js +7 -4
- package/dist/esm/components/composable/getListFontWeightTypos.js +12 -0
- package/dist/esm/components/image-to-layout/DropElement.js +10 -5
- package/dist/esm/libs/google-fonts.js +24 -4
- package/package.json +2 -2
|
@@ -8,11 +8,12 @@ var core = require('@gem-sdk/core');
|
|
|
8
8
|
var react = require('react');
|
|
9
9
|
var getStorefrontApi = require('../../libs/get-storefront-api.js');
|
|
10
10
|
var googleFonts = require('../../libs/google-fonts.js');
|
|
11
|
+
var checkOptionFont = require('../../libs/helpers/check-option-font.js');
|
|
11
12
|
var genCss = require('../../libs/helpers/gen-css.js');
|
|
12
13
|
var genFonts = require('../../libs/helpers/gen-fonts.js');
|
|
13
14
|
var shopifyCdnWithGoogleFonts = require('../../libs/shopify-cdn-with-google-fonts.js');
|
|
14
15
|
var libsStore = require('../../store/libs-store.js');
|
|
15
|
-
var
|
|
16
|
+
var getListFontWeightTypos = require('../composable/getListFontWeightTypos.js');
|
|
16
17
|
|
|
17
18
|
const globalStyleId = 'global-style';
|
|
18
19
|
const Toolbox = ()=>{
|
|
@@ -137,9 +138,11 @@ const Toolbox = ()=>{
|
|
|
137
138
|
try {
|
|
138
139
|
if (detail.data) {
|
|
139
140
|
const themeStyle = genCss.genCSS(detail.data, detail.mobileOnly);
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
const fontWeights = getListFontWeightTypos.getListFontWeightTypos(detail.data?.typography);
|
|
142
|
+
const font = Object.entries(detail.data?.font).map(([, value])=>({
|
|
143
|
+
...value,
|
|
144
|
+
variants: value.variants.filter((variant)=>fontWeights.includes(variant) || variant === 'regular' && fontWeights.includes('400')).map((variant)=>variant === 'regular' ? '400' : variant)
|
|
145
|
+
})).map((item)=>{
|
|
143
146
|
if (item.type == 'custom') {
|
|
144
147
|
const isGoogleFont = shopifyCdnWithGoogleFonts.shopifyCdnWithGoogleFonts.find((ggFont)=>ggFont.family == item.family);
|
|
145
148
|
if (isGoogleFont) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getListFontWeightTypos = (font)=>{
|
|
4
|
+
const fontWeights = new Set();
|
|
5
|
+
Object.values(font).forEach((fontStyle)=>{
|
|
6
|
+
// Check desktop fontWeight
|
|
7
|
+
if (fontStyle.desktop?.fontWeight) {
|
|
8
|
+
fontWeights.add(fontStyle.desktop.fontWeight);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return Array.from(fontWeights);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.getListFontWeightTypos = getListFontWeightTypos;
|
|
@@ -4,8 +4,13 @@
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var core = require('@gem-sdk/core');
|
|
6
6
|
|
|
7
|
+
const SALE_FUNNEL_PAGE_TYPES = [
|
|
8
|
+
'GP_FUNNEL_PAGE',
|
|
9
|
+
'GP_PRE_SALE_PAGE'
|
|
10
|
+
];
|
|
7
11
|
const DropElement = ()=>{
|
|
8
12
|
const editingPageType = core.useShopStore((s)=>s.pageType);
|
|
13
|
+
const isFunnelSalesPage = SALE_FUNNEL_PAGE_TYPES.includes(editingPageType || '');
|
|
9
14
|
const dispatchEventBuildWithSectionActiveTab = (value)=>{
|
|
10
15
|
const event = new CustomEvent('editor:sidebar:build-with-section-active-tab', {
|
|
11
16
|
bubbles: true,
|
|
@@ -112,7 +117,7 @@ const DropElement = ()=>{
|
|
|
112
117
|
children: [
|
|
113
118
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
114
119
|
className: "gp-text-16 gp-font-medium gp-mb-4 gp-text-[#212121]",
|
|
115
|
-
children:
|
|
120
|
+
children: isFunnelSalesPage ? 'Start building with Sections/Elements or' : 'Start with Sections from sidebar'
|
|
116
121
|
}),
|
|
117
122
|
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
118
123
|
className: "gp-flex gp-gap-3 gp-justify-between",
|
|
@@ -120,22 +125,22 @@ const DropElement = ()=>{
|
|
|
120
125
|
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
121
126
|
"data-button-add-section": true,
|
|
122
127
|
onClick: ()=>{
|
|
123
|
-
if (
|
|
128
|
+
if (isFunnelSalesPage) {
|
|
124
129
|
dispatchEventBuildWithTemplateActiveTab('funnelExisting');
|
|
125
130
|
} else dispatchEventBuildWithSectionActiveTab(true);
|
|
126
131
|
},
|
|
127
132
|
className: "gp-flex gp-h-[40px] gp-px-6 gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#1C1C1C] gp-text-[14px] gp-text-white hover:gp-bg-[#3B3B3B]",
|
|
128
|
-
children:
|
|
133
|
+
children: isFunnelSalesPage ? 'Use existing page designs' : 'Add sections'
|
|
129
134
|
}),
|
|
130
135
|
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
131
136
|
"data-button-add-elements": true,
|
|
132
137
|
onClick: ()=>{
|
|
133
|
-
if (
|
|
138
|
+
if (isFunnelSalesPage) {
|
|
134
139
|
dispatchEventBuildWithTemplateActiveTab('templates');
|
|
135
140
|
} else dispatchEventBuildWithSectionActiveTab(false);
|
|
136
141
|
},
|
|
137
142
|
className: "gp-flex gp-h-[40px] gp-px-6 gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#f4f4f4] gp-text-[14px] gp-text-[#212121] hover:gp-bg-[#E2E2E2]",
|
|
138
|
-
children:
|
|
143
|
+
children: isFunnelSalesPage ? 'Explore templates' : 'Add elements'
|
|
139
144
|
})
|
|
140
145
|
]
|
|
141
146
|
}),
|
|
@@ -36,7 +36,27 @@ const composeFonts = (fonts)=>{
|
|
|
36
36
|
};
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
|
-
const
|
|
39
|
+
const handleGenerateFontParams = (variants, fontType = 'google')=>{
|
|
40
|
+
const regularWeights = [];
|
|
41
|
+
if (!variants.length) {
|
|
42
|
+
return fontType === 'bunny' ? '400' : 'wght@400';
|
|
43
|
+
}
|
|
44
|
+
// Get regular weights and remove italic variants
|
|
45
|
+
variants.forEach((variant)=>{
|
|
46
|
+
if (variant.includes('italic')) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const weight = variant === 'regular' ? '400' : variant;
|
|
50
|
+
regularWeights.push(weight);
|
|
51
|
+
});
|
|
52
|
+
// Sort weights numerically (ex: [900, 700, 400] -> [400, 700, 900])
|
|
53
|
+
const sortedRegularWeights = regularWeights.sort((a, b)=>Number(a) - Number(b));
|
|
54
|
+
// Build the variant string with only regular weights
|
|
55
|
+
const axisPrefix = 'wght@';
|
|
56
|
+
const listVariantsGoogleFonts = sortedRegularWeights.map((weight)=>weight);
|
|
57
|
+
return fontType === 'google' ? `${axisPrefix}${listVariantsGoogleFonts.join(';')}` : sortedRegularWeights.join(',');
|
|
58
|
+
};
|
|
59
|
+
const createFontUrl = (fonts, option, fontType = 'google')=>{
|
|
40
60
|
const mainFonts = fonts.filter((font)=>{
|
|
41
61
|
return !([
|
|
42
62
|
'bunny',
|
|
@@ -50,8 +70,8 @@ const createFontUrl = (fonts, option, fontType)=>{
|
|
|
50
70
|
return index === arr.findIndex((t)=>t.family === font.family);
|
|
51
71
|
});
|
|
52
72
|
const family = composeFonts(uniqFonts).map((font)=>{
|
|
53
|
-
return `${font.family.replace(/ /g, '+')}:${font.variants
|
|
54
|
-
}).join('|');
|
|
73
|
+
return `${font.family.replace(/ /g, '+')}:${handleGenerateFontParams(font.variants, fontType)}`;
|
|
74
|
+
}).join(fontType === 'google' ? '&family=' : '|');
|
|
55
75
|
params.append('family', family);
|
|
56
76
|
params.append('display', display);
|
|
57
77
|
if (option?.subset) {
|
|
@@ -61,7 +81,7 @@ const createFontUrl = (fonts, option, fontType)=>{
|
|
|
61
81
|
params.append('effect', option.effect);
|
|
62
82
|
}
|
|
63
83
|
const bunnyFontUrl = `https://fonts.bunny.net/css?family=${family}`;
|
|
64
|
-
const googleFontUrl = `https://fonts.googleapis.com/
|
|
84
|
+
const googleFontUrl = `https://fonts.googleapis.com/css2?${decodeURIComponent(params.toString())}`;
|
|
65
85
|
return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
|
|
66
86
|
};
|
|
67
87
|
// eslint-disable-next-line max-params
|
|
@@ -4,11 +4,12 @@ import { useMatchMutate, useShopStore, usePageStore, useBuilderPreviewStore, use
|
|
|
4
4
|
import { memo, useMemo, useCallback, useEffect } from 'react';
|
|
5
5
|
import { getStorefrontApi } from '../../libs/get-storefront-api.js';
|
|
6
6
|
import { createFontUrl } from '../../libs/google-fonts.js';
|
|
7
|
+
import { checkNotInOptionFont } from '../../libs/helpers/check-option-font.js';
|
|
7
8
|
import { genCSS } from '../../libs/helpers/gen-css.js';
|
|
8
9
|
import { getFontsFromDataBuilder } from '../../libs/helpers/gen-fonts.js';
|
|
9
10
|
import { shopifyCdnWithGoogleFonts } from '../../libs/shopify-cdn-with-google-fonts.js';
|
|
10
11
|
import { libsStore } from '../../store/libs-store.js';
|
|
11
|
-
import {
|
|
12
|
+
import { getListFontWeightTypos } from '../composable/getListFontWeightTypos.js';
|
|
12
13
|
|
|
13
14
|
const globalStyleId = 'global-style';
|
|
14
15
|
const Toolbox = ()=>{
|
|
@@ -133,9 +134,11 @@ const Toolbox = ()=>{
|
|
|
133
134
|
try {
|
|
134
135
|
if (detail.data) {
|
|
135
136
|
const themeStyle = genCSS(detail.data, detail.mobileOnly);
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
const fontWeights = getListFontWeightTypos(detail.data?.typography);
|
|
138
|
+
const font = Object.entries(detail.data?.font).map(([, value])=>({
|
|
139
|
+
...value,
|
|
140
|
+
variants: value.variants.filter((variant)=>fontWeights.includes(variant) || variant === 'regular' && fontWeights.includes('400')).map((variant)=>variant === 'regular' ? '400' : variant)
|
|
141
|
+
})).map((item)=>{
|
|
139
142
|
if (item.type == 'custom') {
|
|
140
143
|
const isGoogleFont = shopifyCdnWithGoogleFonts.find((ggFont)=>ggFont.family == item.family);
|
|
141
144
|
if (isGoogleFont) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const getListFontWeightTypos = (font)=>{
|
|
2
|
+
const fontWeights = new Set();
|
|
3
|
+
Object.values(font).forEach((fontStyle)=>{
|
|
4
|
+
// Check desktop fontWeight
|
|
5
|
+
if (fontStyle.desktop?.fontWeight) {
|
|
6
|
+
fontWeights.add(fontStyle.desktop.fontWeight);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
return Array.from(fontWeights);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { getListFontWeightTypos };
|
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useShopStore } from '@gem-sdk/core';
|
|
4
4
|
|
|
5
|
+
const SALE_FUNNEL_PAGE_TYPES = [
|
|
6
|
+
'GP_FUNNEL_PAGE',
|
|
7
|
+
'GP_PRE_SALE_PAGE'
|
|
8
|
+
];
|
|
5
9
|
const DropElement = ()=>{
|
|
6
10
|
const editingPageType = useShopStore((s)=>s.pageType);
|
|
11
|
+
const isFunnelSalesPage = SALE_FUNNEL_PAGE_TYPES.includes(editingPageType || '');
|
|
7
12
|
const dispatchEventBuildWithSectionActiveTab = (value)=>{
|
|
8
13
|
const event = new CustomEvent('editor:sidebar:build-with-section-active-tab', {
|
|
9
14
|
bubbles: true,
|
|
@@ -110,7 +115,7 @@ const DropElement = ()=>{
|
|
|
110
115
|
children: [
|
|
111
116
|
/*#__PURE__*/ jsx("div", {
|
|
112
117
|
className: "gp-text-16 gp-font-medium gp-mb-4 gp-text-[#212121]",
|
|
113
|
-
children:
|
|
118
|
+
children: isFunnelSalesPage ? 'Start building with Sections/Elements or' : 'Start with Sections from sidebar'
|
|
114
119
|
}),
|
|
115
120
|
/*#__PURE__*/ jsxs("div", {
|
|
116
121
|
className: "gp-flex gp-gap-3 gp-justify-between",
|
|
@@ -118,22 +123,22 @@ const DropElement = ()=>{
|
|
|
118
123
|
/*#__PURE__*/ jsx("button", {
|
|
119
124
|
"data-button-add-section": true,
|
|
120
125
|
onClick: ()=>{
|
|
121
|
-
if (
|
|
126
|
+
if (isFunnelSalesPage) {
|
|
122
127
|
dispatchEventBuildWithTemplateActiveTab('funnelExisting');
|
|
123
128
|
} else dispatchEventBuildWithSectionActiveTab(true);
|
|
124
129
|
},
|
|
125
130
|
className: "gp-flex gp-h-[40px] gp-px-6 gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#1C1C1C] gp-text-[14px] gp-text-white hover:gp-bg-[#3B3B3B]",
|
|
126
|
-
children:
|
|
131
|
+
children: isFunnelSalesPage ? 'Use existing page designs' : 'Add sections'
|
|
127
132
|
}),
|
|
128
133
|
/*#__PURE__*/ jsx("button", {
|
|
129
134
|
"data-button-add-elements": true,
|
|
130
135
|
onClick: ()=>{
|
|
131
|
-
if (
|
|
136
|
+
if (isFunnelSalesPage) {
|
|
132
137
|
dispatchEventBuildWithTemplateActiveTab('templates');
|
|
133
138
|
} else dispatchEventBuildWithSectionActiveTab(false);
|
|
134
139
|
},
|
|
135
140
|
className: "gp-flex gp-h-[40px] gp-px-6 gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#f4f4f4] gp-text-[14px] gp-text-[#212121] hover:gp-bg-[#E2E2E2]",
|
|
136
|
-
children:
|
|
141
|
+
children: isFunnelSalesPage ? 'Explore templates' : 'Add elements'
|
|
137
142
|
})
|
|
138
143
|
]
|
|
139
144
|
}),
|
|
@@ -34,7 +34,27 @@ const composeFonts = (fonts)=>{
|
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
const
|
|
37
|
+
const handleGenerateFontParams = (variants, fontType = 'google')=>{
|
|
38
|
+
const regularWeights = [];
|
|
39
|
+
if (!variants.length) {
|
|
40
|
+
return fontType === 'bunny' ? '400' : 'wght@400';
|
|
41
|
+
}
|
|
42
|
+
// Get regular weights and remove italic variants
|
|
43
|
+
variants.forEach((variant)=>{
|
|
44
|
+
if (variant.includes('italic')) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const weight = variant === 'regular' ? '400' : variant;
|
|
48
|
+
regularWeights.push(weight);
|
|
49
|
+
});
|
|
50
|
+
// Sort weights numerically (ex: [900, 700, 400] -> [400, 700, 900])
|
|
51
|
+
const sortedRegularWeights = regularWeights.sort((a, b)=>Number(a) - Number(b));
|
|
52
|
+
// Build the variant string with only regular weights
|
|
53
|
+
const axisPrefix = 'wght@';
|
|
54
|
+
const listVariantsGoogleFonts = sortedRegularWeights.map((weight)=>weight);
|
|
55
|
+
return fontType === 'google' ? `${axisPrefix}${listVariantsGoogleFonts.join(';')}` : sortedRegularWeights.join(',');
|
|
56
|
+
};
|
|
57
|
+
const createFontUrl = (fonts, option, fontType = 'google')=>{
|
|
38
58
|
const mainFonts = fonts.filter((font)=>{
|
|
39
59
|
return !([
|
|
40
60
|
'bunny',
|
|
@@ -48,8 +68,8 @@ const createFontUrl = (fonts, option, fontType)=>{
|
|
|
48
68
|
return index === arr.findIndex((t)=>t.family === font.family);
|
|
49
69
|
});
|
|
50
70
|
const family = composeFonts(uniqFonts).map((font)=>{
|
|
51
|
-
return `${font.family.replace(/ /g, '+')}:${font.variants
|
|
52
|
-
}).join('|');
|
|
71
|
+
return `${font.family.replace(/ /g, '+')}:${handleGenerateFontParams(font.variants, fontType)}`;
|
|
72
|
+
}).join(fontType === 'google' ? '&family=' : '|');
|
|
53
73
|
params.append('family', family);
|
|
54
74
|
params.append('display', display);
|
|
55
75
|
if (option?.subset) {
|
|
@@ -59,7 +79,7 @@ const createFontUrl = (fonts, option, fontType)=>{
|
|
|
59
79
|
params.append('effect', option.effect);
|
|
60
80
|
}
|
|
61
81
|
const bunnyFontUrl = `https://fonts.bunny.net/css?family=${family}`;
|
|
62
|
-
const googleFontUrl = `https://fonts.googleapis.com/
|
|
82
|
+
const googleFontUrl = `https://fonts.googleapis.com/css2?${decodeURIComponent(params.toString())}`;
|
|
63
83
|
return fontType === 'bunny' ? bunnyFontUrl : googleFontUrl;
|
|
64
84
|
};
|
|
65
85
|
// eslint-disable-next-line max-params
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.576",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"next": "14.2.20"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "2.0.0-dev.
|
|
29
|
+
"@gem-sdk/core": "2.0.0-dev.575",
|
|
30
30
|
"@gem-sdk/plugin-cookie-bar": "2.0.0-dev.348",
|
|
31
31
|
"@gem-sdk/plugin-quick-view": "2.0.0-dev.348",
|
|
32
32
|
"@gem-sdk/plugin-sticky-add-to-cart": "2.0.0-dev.348"
|