@webstudio-is/react-sdk 0.59.0 → 0.61.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/app/custom-components/shared/remix-link.js +2 -2
- package/lib/app/index.js +0 -1
- package/lib/cjs/app/custom-components/shared/remix-link.js +2 -2
- package/lib/cjs/app/index.js +0 -1
- package/lib/cjs/components/__generated__/blockquote.props.js +5 -0
- package/lib/cjs/components/__generated__/body.props.js +5 -0
- package/lib/cjs/components/__generated__/bold.props.js +5 -0
- package/lib/cjs/components/__generated__/box.props.js +5 -0
- package/lib/cjs/components/__generated__/button.props.js +5 -1
- package/lib/cjs/components/__generated__/code.props.js +5 -0
- package/lib/cjs/components/__generated__/form.props.js +5 -0
- package/lib/cjs/components/__generated__/heading.props.js +5 -0
- package/lib/cjs/components/__generated__/image.props.js +5 -0
- package/lib/cjs/components/__generated__/input.props.js +11 -2
- package/lib/cjs/components/__generated__/italic.props.js +5 -0
- package/lib/cjs/components/__generated__/link-block.props.js +5 -1
- package/lib/cjs/components/__generated__/link.props.js +5 -1
- package/lib/cjs/components/__generated__/list-item.props.js +5 -0
- package/lib/cjs/components/__generated__/list.props.js +5 -0
- package/lib/cjs/components/__generated__/paragraph.props.js +5 -0
- package/lib/cjs/components/__generated__/rich-text-link.props.js +5 -1
- package/lib/cjs/components/__generated__/separator.props.js +5 -0
- package/lib/cjs/components/__generated__/span.props.js +5 -0
- package/lib/cjs/components/__generated__/subscript.props.js +5 -0
- package/lib/cjs/components/__generated__/superscript.props.js +5 -0
- package/lib/cjs/components/__generated__/text-block.props.js +5 -0
- package/lib/cjs/components/blockquote.ws.js +36 -48
- package/lib/cjs/components/body.ws.js +19 -24
- package/lib/cjs/components/button.ws.js +1 -1
- package/lib/cjs/components/code.ws.js +20 -28
- package/lib/cjs/components/component-meta.js +2 -1
- package/lib/cjs/components/form.ws.js +14 -7
- package/lib/cjs/components/heading.ws.js +1 -1
- package/lib/cjs/components/image.ws.js +8 -9
- package/lib/cjs/components/italic.ws.js +5 -5
- package/lib/cjs/components/link-block.ws.js +5 -5
- package/lib/cjs/components/link.js +1 -1
- package/lib/cjs/components/link.ws.js +9 -10
- package/lib/cjs/components/list-item.ws.js +1 -1
- package/lib/cjs/components/list.ws.js +22 -22
- package/lib/cjs/components/paragraph.ws.js +1 -1
- package/lib/cjs/components/separator.ws.js +20 -20
- package/lib/cjs/components/text-block.ws.js +6 -7
- package/lib/cjs/css/css.js +6 -9
- package/lib/cjs/css/normalize.js +166 -185
- package/lib/cjs/css/presets.js +14 -34
- package/lib/cjs/css/style-rules.js +17 -0
- package/lib/cjs/embed-template.js +160 -0
- package/lib/cjs/index.js +1 -0
- package/lib/components/__generated__/blockquote.props.js +5 -0
- package/lib/components/__generated__/body.props.js +5 -0
- package/lib/components/__generated__/bold.props.js +5 -0
- package/lib/components/__generated__/box.props.js +5 -0
- package/lib/components/__generated__/button.props.js +5 -1
- package/lib/components/__generated__/code.props.js +5 -0
- package/lib/components/__generated__/form.props.js +5 -0
- package/lib/components/__generated__/heading.props.js +5 -0
- package/lib/components/__generated__/image.props.js +5 -0
- package/lib/components/__generated__/input.props.js +11 -2
- package/lib/components/__generated__/italic.props.js +5 -0
- package/lib/components/__generated__/link-block.props.js +5 -1
- package/lib/components/__generated__/link.props.js +5 -1
- package/lib/components/__generated__/list-item.props.js +5 -0
- package/lib/components/__generated__/list.props.js +5 -0
- package/lib/components/__generated__/paragraph.props.js +5 -0
- package/lib/components/__generated__/rich-text-link.props.js +5 -1
- package/lib/components/__generated__/separator.props.js +5 -0
- package/lib/components/__generated__/span.props.js +5 -0
- package/lib/components/__generated__/subscript.props.js +5 -0
- package/lib/components/__generated__/superscript.props.js +5 -0
- package/lib/components/__generated__/text-block.props.js +5 -0
- package/lib/components/blockquote.ws.js +36 -48
- package/lib/components/body.ws.js +19 -24
- package/lib/components/button.ws.js +1 -1
- package/lib/components/code.ws.js +20 -28
- package/lib/components/component-meta.js +2 -1
- package/lib/components/form.ws.js +14 -7
- package/lib/components/heading.ws.js +1 -1
- package/lib/components/image.ws.js +8 -9
- package/lib/components/italic.ws.js +5 -5
- package/lib/components/link-block.ws.js +5 -5
- package/lib/components/link.js +1 -1
- package/lib/components/link.ws.js +9 -10
- package/lib/components/list-item.ws.js +1 -1
- package/lib/components/list.ws.js +22 -22
- package/lib/components/paragraph.ws.js +1 -1
- package/lib/components/separator.ws.js +20 -20
- package/lib/components/text-block.ws.js +6 -7
- package/lib/css/css.js +8 -11
- package/lib/css/normalize.js +166 -185
- package/lib/css/presets.js +14 -34
- package/lib/css/style-rules.js +17 -0
- package/lib/embed-template.js +140 -0
- package/lib/index.js +1 -0
- package/lib/types/app/index.d.ts +0 -1
- package/lib/types/components/box.stories.d.ts +2 -2
- package/lib/types/components/component-meta.d.ts +20 -5
- package/lib/types/components/components-utils.d.ts +1 -1
- package/lib/types/css/normalize.d.ts +8786 -2286
- package/lib/types/css/presets.d.ts +2 -38
- package/lib/types/css/style-rules.d.ts +11 -9
- package/lib/types/embed-template.d.ts +1725 -0
- package/lib/types/embed-template.test.d.ts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +16 -19
- package/src/app/custom-components/shared/remix-link.tsx +2 -2
- package/src/app/index.ts +0 -1
- package/src/components/__generated__/blockquote.props.ts +5 -0
- package/src/components/__generated__/body.props.ts +5 -0
- package/src/components/__generated__/bold.props.ts +5 -0
- package/src/components/__generated__/box.props.ts +5 -0
- package/src/components/__generated__/button.props.ts +5 -1
- package/src/components/__generated__/code.props.ts +5 -0
- package/src/components/__generated__/form.props.ts +5 -0
- package/src/components/__generated__/heading.props.ts +5 -0
- package/src/components/__generated__/image.props.ts +5 -0
- package/src/components/__generated__/input.props.ts +11 -2
- package/src/components/__generated__/italic.props.ts +5 -0
- package/src/components/__generated__/link-block.props.ts +5 -1
- package/src/components/__generated__/link.props.ts +5 -1
- package/src/components/__generated__/list-item.props.ts +5 -0
- package/src/components/__generated__/list.props.ts +5 -0
- package/src/components/__generated__/paragraph.props.ts +5 -0
- package/src/components/__generated__/rich-text-link.props.ts +5 -1
- package/src/components/__generated__/separator.props.ts +5 -0
- package/src/components/__generated__/span.props.ts +5 -0
- package/src/components/__generated__/subscript.props.ts +5 -0
- package/src/components/__generated__/superscript.props.ts +5 -0
- package/src/components/__generated__/text-block.props.ts +5 -0
- package/src/components/blockquote.ws.tsx +42 -52
- package/src/components/body.ws.tsx +25 -32
- package/src/components/bold.ws.tsx +6 -3
- package/src/components/box.ws.ts +6 -3
- package/src/components/button.ws.tsx +7 -4
- package/src/components/code.ws.tsx +26 -32
- package/src/components/component-meta.ts +5 -3
- package/src/components/form.ws.tsx +19 -9
- package/src/components/heading.ws.tsx +7 -4
- package/src/components/image.ws.tsx +14 -12
- package/src/components/input.ws.tsx +6 -3
- package/src/components/italic.ws.tsx +11 -8
- package/src/components/link-block.ws.tsx +11 -8
- package/src/components/link.tsx +1 -1
- package/src/components/link.ws.tsx +15 -13
- package/src/components/list-item.ws.tsx +7 -4
- package/src/components/list.ws.tsx +28 -25
- package/src/components/paragraph.ws.tsx +7 -4
- package/src/components/separator.ws.tsx +26 -25
- package/src/components/span.ws.tsx +6 -3
- package/src/components/subscript.ws.tsx +6 -3
- package/src/components/superscript.ws.tsx +6 -3
- package/src/components/text-block.ws.tsx +12 -11
- package/src/css/css.ts +8 -11
- package/src/css/normalize.ts +165 -188
- package/src/css/presets.ts +15 -37
- package/src/css/style-rules.ts +24 -0
- package/src/embed-template.test.ts +210 -0
- package/src/embed-template.ts +187 -0
- package/src/index.ts +1 -0
- package/lib/app/handle-request.server.js +0 -16
- package/lib/cjs/app/handle-request.server.js +0 -36
- package/lib/types/app/handle-request.server.d.ts +0 -2
- package/src/app/handle-request.server.tsx +0 -21
package/src/css/normalize.ts
CHANGED
|
@@ -15,18 +15,17 @@
|
|
|
15
15
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type { Style } from "@webstudio-is/css-data";
|
|
19
|
-
|
|
20
18
|
// webstudio custom opinionated presets
|
|
21
19
|
import { borders } from "./presets";
|
|
20
|
+
import type { EmbedTemplateStyleDecl } from "../embed-template";
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
Use a better box model (opinionated).
|
|
25
24
|
*/
|
|
26
25
|
const boxSizing = {
|
|
27
|
-
|
|
28
|
-
value: "border-box",
|
|
29
|
-
}
|
|
26
|
+
property: "boxSizing",
|
|
27
|
+
value: { type: "keyword", value: "border-box" },
|
|
28
|
+
} satisfies EmbedTemplateStyleDecl;
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* We dont support rules like this now, implement boxSizing for each used element
|
|
@@ -36,10 +35,7 @@ const boxSizing = {
|
|
|
36
35
|
* box-sizing: border-box;
|
|
37
36
|
}
|
|
38
37
|
*/
|
|
39
|
-
const baseStyle =
|
|
40
|
-
boxSizing,
|
|
41
|
-
...borders,
|
|
42
|
-
} as const satisfies Style;
|
|
38
|
+
const baseStyle = [boxSizing, ...borders] satisfies EmbedTemplateStyleDecl[];
|
|
43
39
|
|
|
44
40
|
export const div = baseStyle;
|
|
45
41
|
export const address = baseStyle;
|
|
@@ -78,83 +74,78 @@ export const span = baseStyle;
|
|
|
78
74
|
2. Prevent adjustments of font size after orientation changes in iOS.
|
|
79
75
|
3. Use a more readable tab size (opinionated).
|
|
80
76
|
*/
|
|
81
|
-
export const html =
|
|
77
|
+
export const html = [
|
|
82
78
|
/* 1 */
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
value: 1.15,
|
|
86
|
-
unit: "number",
|
|
79
|
+
{
|
|
80
|
+
property: "lineHeight",
|
|
81
|
+
value: { type: "unit", value: 1.15, unit: "number" },
|
|
87
82
|
},
|
|
88
|
-
|
|
89
83
|
/* 2 */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
value: 100,
|
|
93
|
-
unit: "%",
|
|
84
|
+
{
|
|
85
|
+
property: "textSizeAdjust",
|
|
86
|
+
value: { type: "unit", value: 100, unit: "%" },
|
|
94
87
|
},
|
|
95
|
-
|
|
96
88
|
/* 3 */
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
value: 4,
|
|
100
|
-
unit: "number",
|
|
89
|
+
{
|
|
90
|
+
property: "tabSize",
|
|
91
|
+
value: { type: "unit", value: 4, unit: "number" },
|
|
101
92
|
},
|
|
102
|
-
|
|
103
93
|
boxSizing,
|
|
104
94
|
...borders,
|
|
105
|
-
|
|
95
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
106
96
|
|
|
107
97
|
/**
|
|
108
98
|
1. Remove the margin in all browsers.
|
|
109
99
|
2. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
|
|
110
100
|
*/
|
|
111
|
-
export const body =
|
|
101
|
+
export const body = [
|
|
112
102
|
/* 1 */
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
value: 0,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
type: "unit",
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
marginLeft: {
|
|
129
|
-
type: "unit",
|
|
130
|
-
value: 0,
|
|
131
|
-
unit: "number",
|
|
103
|
+
{
|
|
104
|
+
property: "marginTop",
|
|
105
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
property: "marginRight",
|
|
109
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
property: "marginBottom",
|
|
113
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
property: "marginLeft",
|
|
117
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
132
118
|
},
|
|
133
119
|
/* 2 */
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
value:
|
|
120
|
+
{
|
|
121
|
+
property: "fontFamily",
|
|
122
|
+
value: {
|
|
123
|
+
type: "keyword",
|
|
124
|
+
value: `system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'`,
|
|
125
|
+
},
|
|
137
126
|
},
|
|
138
127
|
boxSizing,
|
|
139
128
|
...borders,
|
|
140
|
-
|
|
129
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
141
130
|
|
|
142
131
|
/**
|
|
143
132
|
1. Add the correct height in Firefox.
|
|
144
133
|
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
|
|
145
134
|
*/
|
|
146
|
-
export const hr =
|
|
135
|
+
export const hr = [
|
|
147
136
|
/* 1 */
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
value: 0,
|
|
151
|
-
unit: "number",
|
|
137
|
+
{
|
|
138
|
+
property: "height",
|
|
139
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
152
140
|
},
|
|
153
141
|
/* 2 */
|
|
154
|
-
|
|
142
|
+
{
|
|
143
|
+
property: "color",
|
|
144
|
+
value: { type: "keyword", value: "inherit" },
|
|
145
|
+
},
|
|
155
146
|
boxSizing,
|
|
156
147
|
...borders,
|
|
157
|
-
|
|
148
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
158
149
|
|
|
159
150
|
/**
|
|
160
151
|
Add the correct text decoration in Chrome, Edge, and Safari.
|
|
@@ -169,35 +160,37 @@ abbr[title] {
|
|
|
169
160
|
/**
|
|
170
161
|
Add the correct font weight in Edge and Safari.
|
|
171
162
|
*/
|
|
172
|
-
export const b =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
value: "
|
|
163
|
+
export const b = [
|
|
164
|
+
{
|
|
165
|
+
property: "fontWeight",
|
|
166
|
+
value: { type: "keyword", value: "700" },
|
|
176
167
|
},
|
|
177
168
|
boxSizing,
|
|
178
169
|
...borders,
|
|
179
|
-
|
|
170
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
180
171
|
export const strong = b;
|
|
181
172
|
|
|
182
173
|
/**
|
|
183
174
|
1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
|
|
184
175
|
2. Correct the odd 'em' font sizing in all browsers.
|
|
185
176
|
*/
|
|
186
|
-
export const code =
|
|
177
|
+
export const code = [
|
|
187
178
|
/* 1 */
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
value:
|
|
179
|
+
{
|
|
180
|
+
property: "fontFamily",
|
|
181
|
+
value: {
|
|
182
|
+
type: "keyword",
|
|
183
|
+
value: `ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace`,
|
|
184
|
+
},
|
|
191
185
|
},
|
|
192
186
|
/* 2 */
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
value: 1,
|
|
196
|
-
unit: "em",
|
|
187
|
+
{
|
|
188
|
+
property: "fontSize",
|
|
189
|
+
value: { type: "unit", value: 1, unit: "em" },
|
|
197
190
|
},
|
|
198
191
|
boxSizing,
|
|
199
192
|
...borders,
|
|
200
|
-
|
|
193
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
201
194
|
|
|
202
195
|
export const kbd = code;
|
|
203
196
|
export const samp = code;
|
|
@@ -207,60 +200,55 @@ export const pre = code;
|
|
|
207
200
|
Add the correct font size in all browsers.
|
|
208
201
|
*/
|
|
209
202
|
|
|
210
|
-
export const small =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
value: 80,
|
|
214
|
-
unit: "%",
|
|
203
|
+
export const small = [
|
|
204
|
+
{
|
|
205
|
+
property: "fontSize",
|
|
206
|
+
value: { type: "unit", value: 80, unit: "%" },
|
|
215
207
|
},
|
|
216
208
|
boxSizing,
|
|
217
209
|
...borders,
|
|
218
|
-
|
|
210
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
219
211
|
|
|
220
212
|
/**
|
|
221
213
|
Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
|
|
222
214
|
*/
|
|
223
215
|
|
|
224
|
-
const subSupBase =
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
value: 75,
|
|
228
|
-
unit: "%",
|
|
216
|
+
const subSupBase = [
|
|
217
|
+
{
|
|
218
|
+
property: "fontSize",
|
|
219
|
+
value: { type: "unit", value: 75, unit: "%" },
|
|
229
220
|
},
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
value: 0,
|
|
233
|
-
unit: "number",
|
|
221
|
+
{
|
|
222
|
+
property: "lineHeight",
|
|
223
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
234
224
|
},
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
value: "relative",
|
|
225
|
+
{
|
|
226
|
+
property: "position",
|
|
227
|
+
value: { type: "keyword", value: "relative" },
|
|
238
228
|
},
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
value: "baseline",
|
|
229
|
+
{
|
|
230
|
+
property: "verticalAlign",
|
|
231
|
+
value: { type: "keyword", value: "baseline" },
|
|
242
232
|
},
|
|
243
233
|
boxSizing,
|
|
244
234
|
...borders,
|
|
245
|
-
|
|
235
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
246
236
|
|
|
247
|
-
export const sub =
|
|
237
|
+
export const sub = [
|
|
248
238
|
...subSupBase,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
value: -0.25,
|
|
252
|
-
unit: "em",
|
|
239
|
+
{
|
|
240
|
+
property: "bottom",
|
|
241
|
+
value: { type: "unit", value: -0.25, unit: "em" },
|
|
253
242
|
},
|
|
254
|
-
|
|
243
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
255
244
|
|
|
256
|
-
export const sup =
|
|
245
|
+
export const sup = [
|
|
257
246
|
...subSupBase,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
value: -0.5,
|
|
261
|
-
unit: "em",
|
|
247
|
+
{
|
|
248
|
+
property: "top",
|
|
249
|
+
value: { type: "unit", value: -0.5, unit: "em" },
|
|
262
250
|
},
|
|
263
|
-
|
|
251
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
264
252
|
|
|
265
253
|
/*
|
|
266
254
|
Tabular data
|
|
@@ -272,33 +260,32 @@ Tabular data
|
|
|
272
260
|
2. Correct table border color inheritance in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
|
|
273
261
|
*/
|
|
274
262
|
|
|
275
|
-
export const table =
|
|
263
|
+
export const table = [
|
|
276
264
|
/* 1 */
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
value: 0,
|
|
280
|
-
unit: "number",
|
|
265
|
+
{
|
|
266
|
+
property: "textIndent",
|
|
267
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
281
268
|
},
|
|
282
269
|
...borders,
|
|
283
270
|
/* 2 */
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
value: "inherit",
|
|
271
|
+
{
|
|
272
|
+
property: "borderTopColor",
|
|
273
|
+
value: { type: "keyword", value: "inherit" },
|
|
287
274
|
},
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
value: "inherit",
|
|
275
|
+
{
|
|
276
|
+
property: "borderRightColor",
|
|
277
|
+
value: { type: "keyword", value: "inherit" },
|
|
291
278
|
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
value: "inherit",
|
|
279
|
+
{
|
|
280
|
+
property: "borderBottomColor",
|
|
281
|
+
value: { type: "keyword", value: "inherit" },
|
|
295
282
|
},
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
value: "inherit",
|
|
283
|
+
{
|
|
284
|
+
property: "borderLeftColor",
|
|
285
|
+
value: { type: "keyword", value: "inherit" },
|
|
299
286
|
},
|
|
300
287
|
boxSizing,
|
|
301
|
-
|
|
288
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
302
289
|
|
|
303
290
|
/*
|
|
304
291
|
Forms
|
|
@@ -310,46 +297,40 @@ Forms
|
|
|
310
297
|
2. Remove the margin in Firefox and Safari.
|
|
311
298
|
*/
|
|
312
299
|
|
|
313
|
-
const buttonBase =
|
|
300
|
+
const buttonBase = [
|
|
314
301
|
/* 1 */
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
value: "inherit",
|
|
302
|
+
{
|
|
303
|
+
property: "fontFamily",
|
|
304
|
+
value: { type: "keyword", value: "inherit" },
|
|
318
305
|
},
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
value: 100,
|
|
322
|
-
unit: "%",
|
|
306
|
+
{
|
|
307
|
+
property: "fontSize",
|
|
308
|
+
value: { type: "unit", value: 100, unit: "%" },
|
|
323
309
|
},
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
value: 1.15,
|
|
327
|
-
unit: "number",
|
|
310
|
+
{
|
|
311
|
+
property: "lineHeight",
|
|
312
|
+
value: { type: "unit", value: 1.15, unit: "number" },
|
|
328
313
|
},
|
|
329
314
|
/* 2 */
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
value: 0,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
type: "unit",
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
marginLeft: {
|
|
346
|
-
type: "unit",
|
|
347
|
-
value: 0,
|
|
348
|
-
unit: "number",
|
|
315
|
+
{
|
|
316
|
+
property: "marginTop",
|
|
317
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
property: "marginRight",
|
|
321
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
property: "marginBottom",
|
|
325
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
property: "marginLeft",
|
|
329
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
349
330
|
},
|
|
350
331
|
boxSizing,
|
|
351
332
|
...borders,
|
|
352
|
-
|
|
333
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
353
334
|
|
|
354
335
|
export const input = buttonBase;
|
|
355
336
|
export const optgroup = buttonBase;
|
|
@@ -358,13 +339,13 @@ export const textarea = buttonBase;
|
|
|
358
339
|
/**
|
|
359
340
|
Remove the inheritance of text transform in Edge and Firefox.
|
|
360
341
|
*/
|
|
361
|
-
export const button =
|
|
342
|
+
export const button = [
|
|
362
343
|
...buttonBase,
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
value: "none",
|
|
344
|
+
{
|
|
345
|
+
property: "textTransform",
|
|
346
|
+
value: { type: "keyword", value: "none" },
|
|
366
347
|
},
|
|
367
|
-
|
|
348
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
368
349
|
|
|
369
350
|
export const select = button;
|
|
370
351
|
|
|
@@ -417,43 +398,39 @@ See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d4
|
|
|
417
398
|
Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
|
|
418
399
|
*/
|
|
419
400
|
|
|
420
|
-
export const legend =
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
value: 0,
|
|
424
|
-
unit: "number",
|
|
401
|
+
export const legend = [
|
|
402
|
+
{
|
|
403
|
+
property: "paddingTop",
|
|
404
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
425
405
|
},
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
value: 0,
|
|
429
|
-
unit: "number",
|
|
406
|
+
{
|
|
407
|
+
property: "paddingRight",
|
|
408
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
430
409
|
},
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
value: 0,
|
|
434
|
-
unit: "number",
|
|
410
|
+
{
|
|
411
|
+
property: "paddingBottom",
|
|
412
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
435
413
|
},
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
value: 0,
|
|
439
|
-
unit: "number",
|
|
414
|
+
{
|
|
415
|
+
property: "paddingLeft",
|
|
416
|
+
value: { type: "unit", value: 0, unit: "number" },
|
|
440
417
|
},
|
|
441
418
|
boxSizing,
|
|
442
419
|
...borders,
|
|
443
|
-
|
|
420
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
444
421
|
|
|
445
422
|
/**
|
|
446
423
|
Add the correct vertical alignment in Chrome and Firefox.
|
|
447
424
|
*/
|
|
448
425
|
|
|
449
|
-
export const progress =
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
value: "baseline",
|
|
426
|
+
export const progress = [
|
|
427
|
+
{
|
|
428
|
+
property: "verticalAlign",
|
|
429
|
+
value: { type: "keyword", value: "baseline" },
|
|
453
430
|
},
|
|
454
431
|
boxSizing,
|
|
455
432
|
...borders,
|
|
456
|
-
|
|
433
|
+
] satisfies EmbedTemplateStyleDecl[];
|
|
457
434
|
|
|
458
435
|
/**
|
|
459
436
|
Correct the cursor style of increment and decrement buttons in Safari.
|
|
@@ -509,11 +486,11 @@ Interactive
|
|
|
509
486
|
Add the correct display in Chrome and Safari.
|
|
510
487
|
*/
|
|
511
488
|
|
|
512
|
-
export const summary =
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
value: "list-item",
|
|
489
|
+
export const summary = [
|
|
490
|
+
{
|
|
491
|
+
property: "display",
|
|
492
|
+
value: { type: "keyword", value: "list-item" },
|
|
516
493
|
},
|
|
517
494
|
boxSizing,
|
|
518
495
|
...borders,
|
|
519
|
-
|
|
496
|
+
] satisfies EmbedTemplateStyleDecl[];
|
package/src/css/presets.ts
CHANGED
|
@@ -1,42 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EmbedTemplateStyleDecl } from "../embed-template";
|
|
2
2
|
|
|
3
|
-
export const borders =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: "
|
|
3
|
+
export const borders: EmbedTemplateStyleDecl[] = [
|
|
4
|
+
{
|
|
5
|
+
property: "borderTopWidth",
|
|
6
|
+
value: { type: "unit", value: 1, unit: "px" },
|
|
7
7
|
},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
value: "
|
|
8
|
+
{
|
|
9
|
+
property: "borderRightWidth",
|
|
10
|
+
value: { type: "unit", value: 1, unit: "px" },
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
value: "
|
|
12
|
+
{
|
|
13
|
+
property: "borderBottomWidth",
|
|
14
|
+
value: { type: "unit", value: 1, unit: "px" },
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
value: "
|
|
16
|
+
{
|
|
17
|
+
property: "borderLeftWidth",
|
|
18
|
+
value: { type: "unit", value: 1, unit: "px" },
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
borderTopWidth: {
|
|
22
|
-
type: "unit",
|
|
23
|
-
value: 1,
|
|
24
|
-
unit: "px",
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
borderRightWidth: {
|
|
28
|
-
type: "unit",
|
|
29
|
-
value: 1,
|
|
30
|
-
unit: "px",
|
|
31
|
-
},
|
|
32
|
-
borderBottomWidth: {
|
|
33
|
-
type: "unit",
|
|
34
|
-
value: 1,
|
|
35
|
-
unit: "px",
|
|
36
|
-
},
|
|
37
|
-
borderLeftWidth: {
|
|
38
|
-
type: "unit",
|
|
39
|
-
value: 1,
|
|
40
|
-
unit: "px",
|
|
41
|
-
},
|
|
42
|
-
} as const satisfies Style;
|
|
20
|
+
];
|
package/src/css/style-rules.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type {
|
|
|
6
6
|
StyleSource,
|
|
7
7
|
StyleSourceSelections,
|
|
8
8
|
} from "@webstudio-is/project-build";
|
|
9
|
+
import type { PresetStyle } from "../components/component-meta";
|
|
10
|
+
import { componentAttribute } from "../tree";
|
|
9
11
|
|
|
10
12
|
type StyleRule = {
|
|
11
13
|
instanceId: string;
|
|
@@ -75,3 +77,25 @@ export const getStyleRules = (
|
|
|
75
77
|
|
|
76
78
|
return styleRules;
|
|
77
79
|
};
|
|
80
|
+
|
|
81
|
+
export const getPresetStyleRules = (
|
|
82
|
+
component: string,
|
|
83
|
+
presetStyle: PresetStyle
|
|
84
|
+
) => {
|
|
85
|
+
// group style declarations by selector to render as separate rules
|
|
86
|
+
const presetStyleRules = new Map<string, Style>();
|
|
87
|
+
for (const [tag, styles] of Object.entries(presetStyle)) {
|
|
88
|
+
for (const styleDecl of styles) {
|
|
89
|
+
const selector = `${tag}:where([${componentAttribute}=${component}])${
|
|
90
|
+
styleDecl.state ?? ""
|
|
91
|
+
}`;
|
|
92
|
+
let rule = presetStyleRules.get(selector);
|
|
93
|
+
if (rule === undefined) {
|
|
94
|
+
rule = {};
|
|
95
|
+
presetStyleRules.set(selector, rule);
|
|
96
|
+
}
|
|
97
|
+
rule[styleDecl.property] = styleDecl.value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return presetStyleRules;
|
|
101
|
+
};
|