@webstudio-is/css-engine 0.27.0 → 0.28.0
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/lib/cjs/core/rules.cjs +9 -1
- package/lib/cjs/core/to-value.cjs +3 -0
- package/lib/core/rules.js +9 -1
- package/lib/core/to-value.js +3 -0
- package/package.json +3 -3
- package/src/core/rules.ts +11 -3
- package/src/core/to-value.ts +4 -0
package/lib/cjs/core/rules.cjs
CHANGED
|
@@ -169,9 +169,17 @@ class FontFaceRule {
|
|
|
169
169
|
this.options = options;
|
|
170
170
|
}
|
|
171
171
|
get cssText() {
|
|
172
|
+
const decls = [];
|
|
172
173
|
const { fontFamily, fontStyle, fontWeight, fontDisplay, src } = this.options;
|
|
174
|
+
decls.push(
|
|
175
|
+
`font-family: ${/\s/.test(fontFamily) ? `"${fontFamily}"` : fontFamily}`
|
|
176
|
+
);
|
|
177
|
+
decls.push(`font-style: ${fontStyle}`);
|
|
178
|
+
decls.push(`font-weight: ${fontWeight}`);
|
|
179
|
+
decls.push(`font-display: ${fontDisplay}`);
|
|
180
|
+
decls.push(`src: ${src}`);
|
|
173
181
|
return `@font-face {
|
|
174
|
-
|
|
182
|
+
${decls.join("; ")};
|
|
175
183
|
}`;
|
|
176
184
|
}
|
|
177
185
|
}
|
|
@@ -71,6 +71,9 @@ const toValue = (value, options = defaultOptions) => {
|
|
|
71
71
|
(imageAsset) => `url(${imageAsset.value.path}) /* id=${imageAsset.value.id} */`
|
|
72
72
|
).join(", ");
|
|
73
73
|
}
|
|
74
|
+
if (value.type === "unparsed") {
|
|
75
|
+
return value.value;
|
|
76
|
+
}
|
|
74
77
|
assertUnreachable(value, `Unknown value type`);
|
|
75
78
|
throw new Error("Unknown value type");
|
|
76
79
|
};
|
package/lib/core/rules.js
CHANGED
|
@@ -137,9 +137,17 @@ class FontFaceRule {
|
|
|
137
137
|
this.options = options;
|
|
138
138
|
}
|
|
139
139
|
get cssText() {
|
|
140
|
+
const decls = [];
|
|
140
141
|
const { fontFamily, fontStyle, fontWeight, fontDisplay, src } = this.options;
|
|
142
|
+
decls.push(
|
|
143
|
+
`font-family: ${/\s/.test(fontFamily) ? `"${fontFamily}"` : fontFamily}`
|
|
144
|
+
);
|
|
145
|
+
decls.push(`font-style: ${fontStyle}`);
|
|
146
|
+
decls.push(`font-weight: ${fontWeight}`);
|
|
147
|
+
decls.push(`font-display: ${fontDisplay}`);
|
|
148
|
+
decls.push(`src: ${src}`);
|
|
141
149
|
return `@font-face {
|
|
142
|
-
|
|
150
|
+
${decls.join("; ")};
|
|
143
151
|
}`;
|
|
144
152
|
}
|
|
145
153
|
}
|
package/lib/core/to-value.js
CHANGED
|
@@ -48,6 +48,9 @@ const toValue = (value, options = defaultOptions) => {
|
|
|
48
48
|
(imageAsset) => `url(${imageAsset.value.path}) /* id=${imageAsset.value.id} */`
|
|
49
49
|
).join(", ");
|
|
50
50
|
}
|
|
51
|
+
if (value.type === "unparsed") {
|
|
52
|
+
return value.value;
|
|
53
|
+
}
|
|
51
54
|
assertUnreachable(value, `Unknown value type`);
|
|
52
55
|
throw new Error("Unknown value type");
|
|
53
56
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/css-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "CSS Renderer for Webstudio",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"hyphenate-style-name": "^1.0.4",
|
|
10
10
|
"react": "^17.0.2",
|
|
11
11
|
"react-dom": "^17.0.2",
|
|
12
|
-
"@webstudio-is/fonts": "^0.
|
|
12
|
+
"@webstudio-is/fonts": "^0.28.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@jest/globals": "^29.3.1",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@types/react-dom": "^17.0.9",
|
|
22
22
|
"jest": "^29.3.1",
|
|
23
23
|
"typescript": "4.7.4",
|
|
24
|
-
"@webstudio-is/css-data": "^0.
|
|
24
|
+
"@webstudio-is/css-data": "^0.28.0",
|
|
25
25
|
"@webstudio-is/jest-config": "^1.0.2",
|
|
26
26
|
"@webstudio-is/scripts": "^0.0.0",
|
|
27
27
|
"@webstudio-is/storybook-config": "^0.0.0",
|
package/src/core/rules.ts
CHANGED
|
@@ -130,8 +130,8 @@ export class PlaintextRule {
|
|
|
130
130
|
|
|
131
131
|
export type FontFaceOptions = {
|
|
132
132
|
fontFamily: string;
|
|
133
|
-
fontStyle
|
|
134
|
-
fontWeight
|
|
133
|
+
fontStyle?: "normal" | "italic" | "oblique";
|
|
134
|
+
fontWeight?: number | string;
|
|
135
135
|
fontDisplay: "swap" | "auto" | "block" | "fallback" | "optional";
|
|
136
136
|
src: string;
|
|
137
137
|
};
|
|
@@ -142,9 +142,17 @@ export class FontFaceRule {
|
|
|
142
142
|
this.options = options;
|
|
143
143
|
}
|
|
144
144
|
get cssText() {
|
|
145
|
+
const decls = [];
|
|
145
146
|
const { fontFamily, fontStyle, fontWeight, fontDisplay, src } =
|
|
146
147
|
this.options;
|
|
147
|
-
|
|
148
|
+
decls.push(
|
|
149
|
+
`font-family: ${/\s/.test(fontFamily) ? `"${fontFamily}"` : fontFamily}`
|
|
150
|
+
);
|
|
151
|
+
decls.push(`font-style: ${fontStyle}`);
|
|
152
|
+
decls.push(`font-weight: ${fontWeight}`);
|
|
153
|
+
decls.push(`font-display: ${fontDisplay}`);
|
|
154
|
+
decls.push(`src: ${src}`);
|
|
155
|
+
return `@font-face {\n ${decls.join("; ")};\n}`;
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
|
package/src/core/to-value.ts
CHANGED