@gem-sdk/pages 1.38.7 → 1.39.9
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.
|
@@ -7,6 +7,11 @@ const baseDevices = {
|
|
|
7
7
|
tablet: '1023px',
|
|
8
8
|
mobile: '767px'
|
|
9
9
|
};
|
|
10
|
+
const devicesOrder = [
|
|
11
|
+
'desktop',
|
|
12
|
+
'tablet',
|
|
13
|
+
'mobile'
|
|
14
|
+
];
|
|
10
15
|
const flattenObject = (obj, prefix)=>{
|
|
11
16
|
return Object.keys(obj).reduce((acc, k)=>{
|
|
12
17
|
const pre = prefix ? `${prefix}-` : '';
|
|
@@ -15,11 +20,6 @@ const flattenObject = (obj, prefix)=>{
|
|
|
15
20
|
return acc;
|
|
16
21
|
}, {});
|
|
17
22
|
};
|
|
18
|
-
const devicesOrder = [
|
|
19
|
-
'desktop',
|
|
20
|
-
'tablet',
|
|
21
|
-
'mobile'
|
|
22
|
-
];
|
|
23
23
|
const mapObject = (obj)=>{
|
|
24
24
|
return Object.entries(obj ?? {}).reduce((acc, [k, v])=>{
|
|
25
25
|
return {
|
|
@@ -67,6 +67,14 @@ const getValueByDevice = (data, device)=>{
|
|
|
67
67
|
};
|
|
68
68
|
return deviceData;
|
|
69
69
|
};
|
|
70
|
+
const quoteFontName = (font)=>{
|
|
71
|
+
if ([
|
|
72
|
+
'sans-serif'
|
|
73
|
+
].includes(font)) {
|
|
74
|
+
return font;
|
|
75
|
+
}
|
|
76
|
+
return `'${font}'`;
|
|
77
|
+
};
|
|
70
78
|
const genCSSVariable = (deviceData)=>{
|
|
71
79
|
return Object.entries(mapObject(flattenObject(deviceData))).map(([key, value])=>{
|
|
72
80
|
if (value === undefined) return undefined;
|
|
@@ -74,7 +82,7 @@ const genCSSVariable = (deviceData)=>{
|
|
|
74
82
|
'font-heading',
|
|
75
83
|
'font-body'
|
|
76
84
|
].includes(key)) {
|
|
77
|
-
return `--g-${key}:
|
|
85
|
+
return `--g-${key}: ${quoteFontName(value)}`;
|
|
78
86
|
}
|
|
79
87
|
return `--g-${key}:${value}`;
|
|
80
88
|
}).filter((v)=>v !== undefined).join(';');
|
|
@@ -5,6 +5,11 @@ const baseDevices = {
|
|
|
5
5
|
tablet: '1023px',
|
|
6
6
|
mobile: '767px'
|
|
7
7
|
};
|
|
8
|
+
const devicesOrder = [
|
|
9
|
+
'desktop',
|
|
10
|
+
'tablet',
|
|
11
|
+
'mobile'
|
|
12
|
+
];
|
|
8
13
|
const flattenObject = (obj, prefix)=>{
|
|
9
14
|
return Object.keys(obj).reduce((acc, k)=>{
|
|
10
15
|
const pre = prefix ? `${prefix}-` : '';
|
|
@@ -13,11 +18,6 @@ const flattenObject = (obj, prefix)=>{
|
|
|
13
18
|
return acc;
|
|
14
19
|
}, {});
|
|
15
20
|
};
|
|
16
|
-
const devicesOrder = [
|
|
17
|
-
'desktop',
|
|
18
|
-
'tablet',
|
|
19
|
-
'mobile'
|
|
20
|
-
];
|
|
21
21
|
const mapObject = (obj)=>{
|
|
22
22
|
return Object.entries(obj ?? {}).reduce((acc, [k, v])=>{
|
|
23
23
|
return {
|
|
@@ -65,6 +65,14 @@ const getValueByDevice = (data, device)=>{
|
|
|
65
65
|
};
|
|
66
66
|
return deviceData;
|
|
67
67
|
};
|
|
68
|
+
const quoteFontName = (font)=>{
|
|
69
|
+
if ([
|
|
70
|
+
'sans-serif'
|
|
71
|
+
].includes(font)) {
|
|
72
|
+
return font;
|
|
73
|
+
}
|
|
74
|
+
return `'${font}'`;
|
|
75
|
+
};
|
|
68
76
|
const genCSSVariable = (deviceData)=>{
|
|
69
77
|
return Object.entries(mapObject(flattenObject(deviceData))).map(([key, value])=>{
|
|
70
78
|
if (value === undefined) return undefined;
|
|
@@ -72,7 +80,7 @@ const genCSSVariable = (deviceData)=>{
|
|
|
72
80
|
'font-heading',
|
|
73
81
|
'font-body'
|
|
74
82
|
].includes(key)) {
|
|
75
|
-
return `--g-${key}:
|
|
83
|
+
return `--g-${key}: ${quoteFontName(value)}`;
|
|
76
84
|
}
|
|
77
85
|
return `--g-${key}:${value}`;
|
|
78
86
|
}).filter((v)=>v !== undefined).join(';');
|