Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

refactor: rewrite html styles with css (#3938)

Bogdan Chadkin3a35b6cbc32f
diff --git a/packages/css-data/bin/html.css.ts b/packages/css-data/bin/html.css.ts
new file mode 100644
index 0000000000..78116800a9
--- /dev/null
+++ b/packages/css-data/bin/html.css.ts
@@ -0,0 +1,23 @@
+import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import type { StyleValue } from "@webstudio-is/css-engine";
+import { parseCss } from "../src/parse-css";
+
+const css = readFileSync("./src/html.css", "utf8");
+const parsed = parseCss(css);
+const result: Record<
+ string,
+ Array<{ property: string; value: StyleValue }>
+> = {};
+for (const styleDecl of parsed) {
+ result[styleDecl.selector] ??= [];
+ result[styleDecl.selector].push({
+ property: styleDecl.property,
+ value: styleDecl.value,
+ });
+}
+
+mkdirSync("./src/__generated__", { recursive: true });
+writeFileSync(
+ "./src/__generated__/html.ts",
+ `export const html = ${JSON.stringify(result)}`
+);
diff --git a/packages/css-data/package.json b/packages/css-data/package.json
index 6a28f77da4..5ece909059 100644
--- a/packages/css-data/package.json
+++ b/packages/css-data/package.json
@@ -7,6 +7,7 @@
"type": "module",
"scripts": {
"typecheck": "tsc",
+ "build:html.css": "tsx ./bin/html.css.ts && prettier --write ./src/__generated__/html.ts",
"build:mdn-data": "tsx ./bin/mdn-data.ts ./src/__generated__ && prettier --write \"./src/__generated__/\" \"../css-engine/src/__generated__/\"",
"build:descriptions": "tsx ./bin/property-value-descriptions.ts",
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
diff --git a/packages/css-data/src/__generated__/html.ts b/packages/css-data/src/__generated__/html.ts
new file mode 100644
index 0000000000..2518099a11
--- /dev/null
+++ b/packages/css-data/src/__generated__/html.ts
@@ -0,0 +1,680 @@
+export const html = {
+ article: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ ],
+ aside: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ details: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ ],
+ div: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ dt: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ figcaption: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ ],
+ footer: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ form: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ header: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ hgroup: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ html: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ main: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ nav: [{ property: "display", value: { type: "keyword", value: "block" } }],
+ section: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ ],
+ summary: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ ],
+ body: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "marginTop", value: { type: "unit", unit: "px", value: 8 } },
+ { property: "marginRight", value: { type: "unit", unit: "px", value: 8 } },
+ { property: "marginBottom", value: { type: "unit", unit: "px", value: 8 } },
+ { property: "marginLeft", value: { type: "unit", unit: "px", value: 8 } },
+ ],
+ p: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginBottom", value: { type: "unit", unit: "em", value: 1 } },
+ ],
+ dl: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginBottom", value: { type: "unit", unit: "em", value: 1 } },
+ ],
+ dd: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "marginLeft", value: { type: "unit", unit: "px", value: 40 } },
+ ],
+ blockquote: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginRight", value: { type: "unit", unit: "px", value: 40 } },
+ { property: "marginBottom", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginLeft", value: { type: "unit", unit: "px", value: 40 } },
+ ],
+ figure: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginRight", value: { type: "unit", unit: "px", value: 40 } },
+ { property: "marginBottom", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginLeft", value: { type: "unit", unit: "px", value: 40 } },
+ ],
+ address: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "fontStyle", value: { type: "keyword", value: "italic" } },
+ ],
+ h1: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "fontWeight", value: { type: "keyword", value: "bold" } },
+ { property: "fontSize", value: { type: "unit", unit: "em", value: 2 } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 0.67 } },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "em", value: 0.67 },
+ },
+ ],
+ h2: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "fontWeight", value: { type: "keyword", value: "bold" } },
+ { property: "fontSize", value: { type: "unit", unit: "em", value: 1.5 } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 0.83 } },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "em", value: 0.83 },
+ },
+ ],
+ h3: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "fontWeight", value: { type: "keyword", value: "bold" } },
+ { property: "fontSize", value: { type: "unit", unit: "em", value: 1.17 } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginBottom", value: { type: "unit", unit: "em", value: 1 } },
+ ],
+ h4: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "fontWeight", value: { type: "keyword", value: "bold" } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1.33 } },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "em", value: 1.33 },
+ },
+ ],
+ h5: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "fontWeight", value: { type: "keyword", value: "bold" } },
+ { property: "fontSize", value: { type: "unit", unit: "em", value: 0.83 } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1.67 } },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "em", value: 1.67 },
+ },
+ ],
+ h6: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "fontWeight", value: { type: "keyword", value: "bold" } },
+ { property: "fontSize", value: { type: "unit", unit: "em", value: 0.67 } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 2.33 } },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "em", value: 2.33 },
+ },
+ ],
+ pre: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ {
+ property: "whiteSpaceCollapse",
+ value: { type: "keyword", value: "preserve" },
+ },
+ { property: "textWrapMode", value: { type: "keyword", value: "nowrap" } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginBottom", value: { type: "unit", unit: "em", value: 1 } },
+ ],
+ table: [
+ { property: "display", value: { type: "keyword", value: "table" } },
+ {
+ property: "borderSpacing",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderCollapse",
+ value: { type: "keyword", value: "separate" },
+ },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ {
+ property: "textIndent",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ ],
+ caption: [
+ { property: "display", value: { type: "keyword", value: "table-caption" } },
+ { property: "textAlign", value: { type: "keyword", value: "center" } },
+ ],
+ tr: [
+ { property: "display", value: { type: "keyword", value: "table-row" } },
+ { property: "verticalAlign", value: { type: "keyword", value: "inherit" } },
+ ],
+ col: [
+ { property: "display", value: { type: "keyword", value: "table-column" } },
+ ],
+ colgroup: [
+ {
+ property: "display",
+ value: { type: "keyword", value: "table-column-group" },
+ },
+ ],
+ tbody: [
+ {
+ property: "display",
+ value: { type: "keyword", value: "table-row-group" },
+ },
+ { property: "verticalAlign", value: { type: "keyword", value: "middle" } },
+ ],
+ thead: [
+ {
+ property: "display",
+ value: { type: "keyword", value: "table-header-group" },
+ },
+ { property: "verticalAlign", value: { type: "keyword", value: "middle" } },
+ ],
+ tfoot: [
+ {
+ property: "display",
+ value: { type: "keyword", value: "table-footer-group" },
+ },
+ { property: "verticalAlign", value: { type: "keyword", value: "middle" } },
+ ],
+ td: [
+ { property: "display", value: { type: "keyword", value: "table-cell" } },
+ { property: "verticalAlign", value: { type: "keyword", value: "inherit" } },
+ { property: "paddingTop", value: { type: "unit", unit: "px", value: 1 } },
+ { property: "paddingRight", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "paddingBottom",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 1 } },
+ ],
+ th: [
+ { property: "display", value: { type: "keyword", value: "table-cell" } },
+ { property: "verticalAlign", value: { type: "keyword", value: "inherit" } },
+ { property: "fontWeight", value: { type: "keyword", value: "bold" } },
+ { property: "paddingTop", value: { type: "unit", unit: "px", value: 1 } },
+ { property: "paddingRight", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "paddingBottom",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 1 } },
+ ],
+ b: [{ property: "fontWeight", value: { type: "keyword", value: "bold" } }],
+ strong: [
+ { property: "fontWeight", value: { type: "keyword", value: "bold" } },
+ ],
+ i: [{ property: "fontStyle", value: { type: "keyword", value: "italic" } }],
+ cite: [
+ { property: "fontStyle", value: { type: "keyword", value: "italic" } },
+ ],
+ em: [{ property: "fontStyle", value: { type: "keyword", value: "italic" } }],
+ var: [{ property: "fontStyle", value: { type: "keyword", value: "italic" } }],
+ dfn: [{ property: "fontStyle", value: { type: "keyword", value: "italic" } }],
+ code: [
+ {
+ property: "fontFamily",
+ value: { type: "fontFamily", value: ["monospace"] },
+ },
+ ],
+ kbd: [
+ {
+ property: "fontFamily",
+ value: { type: "fontFamily", value: ["monospace"] },
+ },
+ ],
+ samp: [
+ {
+ property: "fontFamily",
+ value: { type: "fontFamily", value: ["monospace"] },
+ },
+ ],
+ mark: [
+ {
+ property: "backgroundColor",
+ value: { type: "keyword", value: "yellow" },
+ },
+ { property: "color", value: { type: "keyword", value: "black" } },
+ ],
+ u: [
+ {
+ property: "textDecorationLine",
+ value: { type: "keyword", value: "underline" },
+ },
+ ],
+ ins: [
+ {
+ property: "textDecorationLine",
+ value: { type: "keyword", value: "underline" },
+ },
+ ],
+ s: [
+ {
+ property: "textDecorationLine",
+ value: { type: "keyword", value: "line-through" },
+ },
+ ],
+ del: [
+ {
+ property: "textDecorationLine",
+ value: { type: "keyword", value: "line-through" },
+ },
+ ],
+ sub: [
+ { property: "verticalAlign", value: { type: "keyword", value: "sub" } },
+ { property: "fontSize", value: { type: "keyword", value: "smaller" } },
+ ],
+ sup: [
+ { property: "verticalAlign", value: { type: "keyword", value: "super" } },
+ { property: "fontSize", value: { type: "keyword", value: "smaller" } },
+ ],
+ a: [
+ {
+ property: "textDecorationLine",
+ value: { type: "keyword", value: "underline" },
+ },
+ { property: "cursor", value: { type: "keyword", value: "pointer" } },
+ { property: "color", value: { type: "rgb", alpha: 1, r: 0, g: 0, b: 238 } },
+ ],
+ ul: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "listStyleType", value: { type: "keyword", value: "disc" } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginBottom", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 40 } },
+ ],
+ ol: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "listStyleType", value: { type: "keyword", value: "decimal" } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "marginBottom", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 40 } },
+ ],
+ li: [
+ { property: "display", value: { type: "keyword", value: "list-item" } },
+ {
+ property: "textAlign",
+ value: { type: "keyword", value: "match-parent" },
+ },
+ ],
+ hr: [
+ { property: "color", value: { type: "keyword", value: "gray" } },
+ {
+ property: "borderTopWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "borderTopStyle", value: { type: "keyword", value: "solid" } },
+ {
+ property: "borderRightStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ {
+ property: "borderBottomStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ { property: "borderLeftStyle", value: { type: "keyword", value: "solid" } },
+ { property: "marginTop", value: { type: "unit", unit: "em", value: 0.5 } },
+ { property: "marginRight", value: { type: "keyword", value: "auto" } },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "em", value: 0.5 },
+ },
+ { property: "marginLeft", value: { type: "keyword", value: "auto" } },
+ { property: "overflowX", value: { type: "keyword", value: "hidden" } },
+ { property: "overflowY", value: { type: "keyword", value: "hidden" } },
+ { property: "display", value: { type: "keyword", value: "block" } },
+ ],
+ legend: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 2 } },
+ { property: "paddingRight", value: { type: "unit", unit: "px", value: 2 } },
+ ],
+ fieldset: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "marginLeft", value: { type: "unit", unit: "px", value: 2 } },
+ { property: "marginRight", value: { type: "unit", unit: "px", value: 2 } },
+ {
+ property: "paddingTop",
+ value: { type: "unit", unit: "em", value: 0.35 },
+ },
+ {
+ property: "paddingRight",
+ value: { type: "unit", unit: "em", value: 0.75 },
+ },
+ {
+ property: "paddingBottom",
+ value: { type: "unit", unit: "em", value: 0.625 },
+ },
+ {
+ property: "paddingLeft",
+ value: { type: "unit", unit: "em", value: 0.75 },
+ },
+ {
+ property: "borderTopWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ { property: "borderTopStyle", value: { type: "keyword", value: "solid" } },
+ {
+ property: "borderRightStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ {
+ property: "borderBottomStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ { property: "borderLeftStyle", value: { type: "keyword", value: "solid" } },
+ {
+ property: "borderTopColor",
+ value: { type: "keyword", value: "lightgray" },
+ },
+ {
+ property: "borderRightColor",
+ value: { type: "keyword", value: "lightgray" },
+ },
+ {
+ property: "borderBottomColor",
+ value: { type: "keyword", value: "lightgray" },
+ },
+ {
+ property: "borderLeftColor",
+ value: { type: "keyword", value: "lightgray" },
+ },
+ { property: "minWidth", value: { type: "keyword", value: "min-content" } },
+ ],
+ label: [{ property: "cursor", value: { type: "keyword", value: "default" } }],
+ input: [
+ { property: "appearance", value: { type: "keyword", value: "auto" } },
+ { property: "paddingTop", value: { type: "unit", unit: "px", value: 1 } },
+ { property: "paddingRight", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "paddingBottom",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderTopWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ { property: "borderTopStyle", value: { type: "keyword", value: "solid" } },
+ {
+ property: "borderRightStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ {
+ property: "borderBottomStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ { property: "borderLeftStyle", value: { type: "keyword", value: "solid" } },
+ { property: "backgroundColor", value: { type: "keyword", value: "white" } },
+ { property: "cursor", value: { type: "keyword", value: "text" } },
+ ],
+ textarea: [
+ { property: "color", value: { type: "keyword", value: "initial" } },
+ { property: "letterSpacing", value: { type: "keyword", value: "normal" } },
+ { property: "wordSpacing", value: { type: "keyword", value: "normal" } },
+ { property: "lineHeight", value: { type: "keyword", value: "normal" } },
+ { property: "textTransform", value: { type: "keyword", value: "none" } },
+ {
+ property: "textIndent",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "textShadow",
+ value: {
+ type: "layers",
+ value: [{ type: "tuple", value: [{ type: "keyword", value: "none" }] }],
+ },
+ },
+ { property: "display", value: { type: "keyword", value: "inline-block" } },
+ { property: "textAlign", value: { type: "keyword", value: "start" } },
+ { property: "appearance", value: { type: "keyword", value: "auto" } },
+ { property: "marginTop", value: { type: "unit", unit: "px", value: 1 } },
+ { property: "marginBottom", value: { type: "unit", unit: "px", value: 1 } },
+ {
+ property: "borderTopWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "borderTopStyle", value: { type: "keyword", value: "solid" } },
+ {
+ property: "borderRightStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ {
+ property: "borderBottomStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ { property: "borderLeftStyle", value: { type: "keyword", value: "solid" } },
+ { property: "paddingTop", value: { type: "unit", unit: "px", value: 2 } },
+ { property: "paddingRight", value: { type: "unit", unit: "px", value: 2 } },
+ {
+ property: "paddingBottom",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 2 } },
+ { property: "backgroundColor", value: { type: "keyword", value: "white" } },
+ {
+ property: "verticalAlign",
+ value: { type: "keyword", value: "text-bottom" },
+ },
+ { property: "cursor", value: { type: "keyword", value: "text" } },
+ { property: "resize", value: { type: "keyword", value: "both" } },
+ {
+ property: "whiteSpaceCollapse",
+ value: { type: "keyword", value: "preserve" },
+ },
+ { property: "textWrapMode", value: { type: "keyword", value: "wrap" } },
+ { property: "wordWrap", value: { type: "keyword", value: "break-word" } },
+ ],
+ select: [
+ { property: "color", value: { type: "keyword", value: "initial" } },
+ { property: "letterSpacing", value: { type: "keyword", value: "normal" } },
+ { property: "wordSpacing", value: { type: "keyword", value: "normal" } },
+ { property: "lineHeight", value: { type: "keyword", value: "normal" } },
+ { property: "textTransform", value: { type: "keyword", value: "none" } },
+ {
+ property: "textIndent",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "textShadow",
+ value: {
+ type: "layers",
+ value: [{ type: "tuple", value: [{ type: "keyword", value: "none" }] }],
+ },
+ },
+ { property: "display", value: { type: "keyword", value: "inline-block" } },
+ { property: "textAlign", value: { type: "keyword", value: "start" } },
+ {
+ property: "marginTop",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "marginRight",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "marginBottom",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "marginLeft",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ { property: "paddingTop", value: { type: "unit", unit: "px", value: 1 } },
+ { property: "paddingRight", value: { type: "unit", unit: "px", value: 4 } },
+ {
+ property: "paddingBottom",
+ value: { type: "unit", unit: "px", value: 1 },
+ },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 4 } },
+ {
+ property: "borderTopWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ { property: "borderTopStyle", value: { type: "keyword", value: "solid" } },
+ {
+ property: "borderRightStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ {
+ property: "borderBottomStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ { property: "borderLeftStyle", value: { type: "keyword", value: "solid" } },
+ { property: "textWrapMode", value: { type: "keyword", value: "nowrap" } },
+ { property: "wordWrap", value: { type: "keyword", value: "normal" } },
+ { property: "cursor", value: { type: "keyword", value: "default" } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "userSelect", value: { type: "keyword", value: "none" } },
+ { property: "overflowX", value: { type: "keyword", value: "clip" } },
+ { property: "overflowY", value: { type: "keyword", value: "clip" } },
+ {
+ property: "verticalAlign",
+ value: { type: "keyword", value: "baseline" },
+ },
+ { property: "appearance", value: { type: "keyword", value: "auto" } },
+ ],
+ button: [
+ { property: "color", value: { type: "keyword", value: "initial" } },
+ { property: "letterSpacing", value: { type: "keyword", value: "normal" } },
+ { property: "wordSpacing", value: { type: "keyword", value: "normal" } },
+ { property: "lineHeight", value: { type: "keyword", value: "normal" } },
+ { property: "textTransform", value: { type: "keyword", value: "none" } },
+ {
+ property: "textIndent",
+ value: { type: "unit", unit: "number", value: 0 },
+ },
+ {
+ property: "textShadow",
+ value: {
+ type: "layers",
+ value: [{ type: "tuple", value: [{ type: "keyword", value: "none" }] }],
+ },
+ },
+ { property: "display", value: { type: "keyword", value: "inline-block" } },
+ { property: "appearance", value: { type: "keyword", value: "auto" } },
+ { property: "paddingTop", value: { type: "unit", unit: "px", value: 2 } },
+ { property: "paddingRight", value: { type: "unit", unit: "px", value: 6 } },
+ {
+ property: "paddingBottom",
+ value: { type: "unit", unit: "px", value: 3 },
+ },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 6 } },
+ {
+ property: "borderTopWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderRightWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderBottomWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ {
+ property: "borderLeftWidth",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ { property: "borderTopStyle", value: { type: "keyword", value: "solid" } },
+ {
+ property: "borderRightStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ {
+ property: "borderBottomStyle",
+ value: { type: "keyword", value: "solid" },
+ },
+ { property: "borderLeftStyle", value: { type: "keyword", value: "solid" } },
+ { property: "cursor", value: { type: "keyword", value: "default" } },
+ { property: "boxSizing", value: { type: "keyword", value: "border-box" } },
+ { property: "userSelect", value: { type: "keyword", value: "none" } },
+ { property: "textAlign", value: { type: "keyword", value: "center" } },
+ {
+ property: "backgroundColor",
+ value: { type: "keyword", value: "lightgray" },
+ },
+ ],
+ option: [
+ { property: "display", value: { type: "keyword", value: "block" } },
+ { property: "float", value: { type: "keyword", value: "none" } },
+ { property: "position", value: { type: "keyword", value: "static" } },
+ { property: "minHeight", value: { type: "unit", unit: "em", value: 1 } },
+ { property: "paddingTop", value: { type: "unit", unit: "px", value: 2 } },
+ { property: "paddingRight", value: { type: "unit", unit: "px", value: 2 } },
+ {
+ property: "paddingBottom",
+ value: { type: "unit", unit: "px", value: 2 },
+ },
+ { property: "paddingLeft", value: { type: "unit", unit: "px", value: 4 } },
+ { property: "userSelect", value: { type: "keyword", value: "none" } },
+ { property: "textWrapMode", value: { type: "keyword", value: "nowrap" } },
+ { property: "wordWrap", value: { type: "keyword", value: "normal" } },
+ ],
+};
diff --git a/packages/css-data/src/html-check.ts b/packages/css-data/src/html-check.ts
deleted file mode 100644
index 24e3c3e556..0000000000
--- a/packages/css-data/src/html-check.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import * as html from "./html";
-import type { htmlTags as HtmlTags } from "html-tags";
-
-type ExportedTags = keyof typeof html;
-
-declare let exportedTags: ExportedTags;
-
-exportedTags satisfies HtmlTags;
diff --git a/packages/css-data/src/html.css b/packages/css-data/src/html.css
new file mode 100644
index 0000000000..5d9595f11a
--- /dev/null
+++ b/packages/css-data/src/html.css
@@ -0,0 +1,395 @@
+/*
+
+all styles are taken from following source
+https://searchfox.org/mozilla-central/source/layout/style/res/html.css
+https://chromium.googlesource.com/chromium/blink/+/master/Source/core/css/html.css
+https://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css
+
+*/
+
+/* blocks */
+
+article,
+aside,
+details,
+div,
+dt,
+figcaption,
+footer,
+form,
+header,
+hgroup,
+html,
+main,
+nav,
+section,
+summary {
+ display: block;
+}
+
+body {
+ display: block;
+ margin: 8px;
+}
+
+p,
+dl {
+ display: block;
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+
+dd {
+ display: block;
+ margin-left: 40px;
+}
+
+blockquote,
+figure {
+ display: block;
+ margin: 1em 40px;
+}
+
+address {
+ display: block;
+ font-style: italic;
+}
+
+/*
+
+h1 font-size, margin-top and margin-bottom depend on parent tags
+so better define statically in preset styles
+
+*/
+
+h1 {
+ display: block;
+ font-weight: bold;
+ font-size: 2em;
+ margin-top: 0.67em;
+ margin-bottom: 0.67em;
+}
+
+h2 {
+ display: block;
+ font-weight: bold;
+ font-size: 1.5em;
+ margin-top: 0.83em;
+ margin-bottom: 0.83em;
+}
+
+h3 {
+ display: block;
+ font-weight: bold;
+ font-size: 1.17em;
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+
+h4 {
+ display: block;
+ font-weight: bold;
+ margin-top: 1.33em;
+ margin-bottom: 1.33em;
+}
+
+h5 {
+ display: block;
+ font-weight: bold;
+ font-size: 0.83em;
+ margin-top: 1.67em;
+ margin-bottom: 1.67em;
+}
+
+h6 {
+ display: block;
+ font-weight: bold;
+ font-size: 0.67em;
+ margin-top: 2.33em;
+ margin-bottom: 2.33em;
+}
+
+pre {
+ display: block;
+ white-space-collapse: preserve;
+ text-wrap-mode: nowrap;
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+
+/* tables */
+
+table {
+ display: table;
+ border-spacing: 2px;
+ border-collapse: separate;
+ box-sizing: border-box;
+ text-indent: 0;
+}
+
+caption {
+ display: table-caption;
+ text-align: center;
+}
+
+tr {
+ display: table-row;
+ vertical-align: inherit;
+}
+
+col {
+ display: table-column;
+}
+
+colgroup {
+ display: table-column-group;
+}
+
+tbody {
+ display: table-row-group;
+ vertical-align: middle;
+}
+
+thead {
+ display: table-header-group;
+ vertical-align: middle;
+}
+
+tfoot {
+ display: table-footer-group;
+ vertical-align: middle;
+}
+
+td {
+ display: table-cell;
+ vertical-align: inherit;
+ padding: 1px;
+}
+
+th {
+ display: table-cell;
+ vertical-align: inherit;
+ font-weight: bold;
+ padding: 1px;
+}
+
+/* inlines */
+
+b,
+strong {
+ /* in firefox defined as bolder */
+ font-weight: bold;
+}
+
+i,
+cite,
+em,
+var,
+dfn {
+ font-style: italic;
+}
+
+code,
+kbd,
+samp {
+ /* in firefox defined as -moz-fixed */
+ font-family: monospace;
+}
+
+mark {
+ /* in firefox defined as Mark */
+ background-color: yellow;
+ /* in firefox defined as MarkText */
+ color: black;
+}
+
+u,
+ins {
+ text-decoration-line: underline;
+}
+
+s,
+del {
+ text-decoration-line: line-through;
+}
+
+sub {
+ vertical-align: sub;
+ font-size: smaller;
+}
+
+sup {
+ vertical-align: super;
+ font-size: smaller;
+}
+
+/*
+
+active and visited states are not defined as usually overriden with stateless color
+and modeling var-like defaults is too complex
+
+*/
+a {
+ text-decoration-line: underline;
+ cursor: pointer;
+ color: rgb(0 0 238 / 1);
+}
+
+/* lists */
+
+/*
+
+nested lists have no top/bottom margins
+so better redefine statically in preset
+
+*/
+
+ul {
+ display: block;
+ list-style-type: disc;
+ margin-top: 1em;
+ margin-bottom: 1em;
+ padding-left: 40px;
+}
+
+ol {
+ display: block;
+ list-style-type: decimal;
+ margin-top: 1em;
+ margin-bottom: 1em;
+ padding-left: 40px;
+}
+
+li {
+ display: list-item;
+ text-align: match-parent;
+}
+
+/* leafs */
+
+hr {
+ color: gray;
+ border-width: 1px;
+ /* in browsers defined as inset */
+ border-style: solid;
+ margin: 0.5em auto;
+ /* firefox only */
+ overflow: hidden;
+ /* This is not really per spec but all browsers define it */
+ display: block;
+}
+
+/**
+ *
+forms
+https://searchfox.org/mozilla-central/source/layout/style/res/forms.css
+
+*/
+
+legend {
+ display: block;
+ padding-left: 2px;
+ padding-right: 2px;
+}
+
+fieldset {
+ display: block;
+ margin-left: 2px;
+ margin-right: 2px;
+ padding: 0.35em 0.75em 0.625em;
+ /* in browsers defined as groove style with ThreeDFace color */
+ border: 2px solid lightgray;
+ min-width: min-content;
+}
+
+label {
+ cursor: default;
+}
+
+input {
+ appearance: auto;
+ padding: 1px;
+ border-width: 2px;
+ /* in browsers defined as inset */
+ border-style: solid;
+ /* in firefox defined as Field */
+ background-color: white;
+ cursor: text;
+}
+
+/* font controls reset */
+textarea,
+select,
+button {
+ /* in firefox defined as FieldText */
+ color: initial;
+ letter-spacing: normal;
+ word-spacing: normal;
+ line-height: normal;
+ text-transform: none;
+ text-indent: 0;
+ text-shadow: none;
+ display: inline-block;
+}
+
+textarea {
+ text-align: start;
+ appearance: auto;
+ margin-top: 1px;
+ margin-bottom: 1px;
+ /* in firefox 2px */
+ border-width: 1px;
+ /* in browsers defined as inset */
+ border-style: solid;
+ padding: 2px;
+ /* in firefox defined as Field */
+ background-color: white;
+ vertical-align: text-bottom;
+ cursor: text;
+ resize: both;
+ white-space-collapse: preserve;
+ text-wrap-mode: wrap;
+ word-wrap: break-word;
+}
+
+select {
+ text-align: start;
+ margin: 0;
+ padding: 1px 4px;
+ border-width: 2px;
+ /* in browsers defined as inset */
+ border-style: solid;
+ text-wrap-mode: nowrap;
+ word-wrap: normal;
+ cursor: default;
+ box-sizing: border-box;
+ user-select: none;
+ overflow: clip;
+ vertical-align: baseline;
+ appearance: auto;
+}
+
+option {
+ display: block;
+ float: none;
+ position: static;
+ min-height: 1em;
+ padding: 2px 2px 2px 4px;
+ user-select: none;
+ text-wrap-mode: nowrap;
+ word-wrap: normal;
+}
+
+button {
+ appearance: auto;
+ /* in firefox defined as 1px 8px */
+ padding: 2px 6px 3px;
+ border-width: 2px;
+ /* in browsers defined as outset */
+ border-style: solid;
+ cursor: default;
+ box-sizing: border-box;
+ user-select: none;
+ text-align: center;
+ background-color: lightgray;
+}
diff --git a/packages/css-data/src/html.ts b/packages/css-data/src/html.ts
deleted file mode 100644
index 882a033448..0000000000
--- a/packages/css-data/src/html.ts
+++ /dev/null
@@ -1,629 +0,0 @@
-// all styles are taken from following source
-// https://searchfox.org/mozilla-central/source/layout/style/res/html.css
-// https://chromium.googlesource.com/chromium/blink/+/master/Source/core/css/html.css
-// https://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css
-
-import type { htmlTags as HtmlTags } from "html-tags";
-import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";
-
-type StyleDecl = {
- property: StyleProperty;
- value: StyleValue;
-};
-type Styles = StyleDecl[];
-
-export type Html = {
- [tag in HtmlTags]?: Styles;
-};
-
-const display = (value: string): Styles[number] => ({
- property: "display",
- value: { type: "keyword", value },
-});
-
-const marginTop = (value: number, unit?: "em" | "px"): Styles[number] => ({
- property: "marginTop",
- value: { type: "unit", value, unit: unit ?? "number" },
-});
-
-const marginRight = (value: number, unit?: "em" | "px"): Styles[number] => ({
- property: "marginRight",
- value: { type: "unit", value, unit: unit ?? "number" },
-});
-
-const marginBottom = (value: number, unit?: "em" | "px"): Styles[number] => ({
- property: "marginBottom",
- value: { type: "unit", value, unit: unit ?? "number" },
-});
-
-const marginLeft = (value: number, unit?: "em" | "px"): Styles[number] => ({
- property: "marginLeft",
- value: { type: "unit", value, unit: unit ?? "number" },
-});
-
-const paddingTop = (value: number, unit: "em" | "px"): Styles[number] => ({
- property: "paddingTop",
- value: { type: "unit", value, unit },
-});
-
-const paddingRight = (value: number, unit: "em" | "px"): Styles[number] => ({
- property: "paddingRight",
- value: { type: "unit", value, unit },
-});
-
-const paddingBottom = (value: number, unit: "em" | "px"): Styles[number] => ({
- property: "paddingBottom",
- value: { type: "unit", value, unit },
-});
-
-const paddingLeft = (value: number, unit: "em" | "px"): Styles[number] => ({
- property: "paddingLeft",
- value: { type: "unit", value, unit },
-});
-
-const color = (value: string): Styles[number] => ({
- property: "color",
- value: { type: "keyword", value },
-});
-
-const fontSize = (value: number, unit: "em"): Styles[number] => ({
- property: "fontSize",
- value: { type: "unit", value, unit },
-});
-
-const fontWeight = (value: "bold"): Styles[number] => ({
- property: "fontWeight",
- value: { type: "keyword", value },
-});
-
-const fontStyle = (value: "italic"): Styles[number] => ({
- property: "fontStyle",
- value: { type: "keyword", value },
-});
-
-const textAlign = (value: string): Styles[number] => ({
- property: "textAlign",
- value: { type: "keyword", value },
-});
-
-const verticalAlign = (value: string): Styles[number] => ({
- property: "verticalAlign",
- value: { type: "keyword", value },
-});
-
-const whiteSpaceCollapse = (value: string): Styles[number] => ({
- property: "whiteSpaceCollapse",
- value: { type: "keyword", value },
-});
-
-const textWrapMode = (value: string): Styles[number] => ({
- property: "textWrapMode",
- value: { type: "keyword", value },
-});
-
-const cursor = (value: string): Styles[number] => ({
- property: "cursor",
- value: { type: "keyword", value },
-});
-
-const borderWidth = (value: number, unit: "px"): Styles => [
- {
- property: "borderTopWidth",
- value: { type: "unit", value, unit },
- },
- {
- property: "borderRightWidth",
- value: { type: "unit", value, unit },
- },
- {
- property: "borderBottomWidth",
- value: { type: "unit", value, unit },
- },
- {
- property: "borderLeftWidth",
- value: { type: "unit", value, unit },
- },
-];
-
-const borderStyle = (value: string): Styles => [
- {
- property: "borderTopStyle",
- value: { type: "keyword", value },
- },
- {
- property: "borderRightStyle",
- value: { type: "keyword", value },
- },
- {
- property: "borderBottomStyle",
- value: { type: "keyword", value },
- },
- {
- property: "borderLeftStyle",
- value: { type: "keyword", value },
- },
-];
-
-const borderColor = (value: string): Styles => [
- {
- property: "borderTopColor",
- value: { type: "keyword", value },
- },
- {
- property: "borderRightColor",
- value: { type: "keyword", value },
- },
- {
- property: "borderBottomColor",
- value: { type: "keyword", value },
- },
- {
- property: "borderLeftColor",
- value: { type: "keyword", value },
- },
-];
-
-const overflow = (value: string): Styles => [
- {
- property: "overflowX",
- value: { type: "keyword", value },
- },
- {
- property: "overflowY",
- value: { type: "keyword", value },
- },
-];
-
-const appearance = (value: string): Styles[number] => ({
- property: "appearance",
- value: { type: "keyword", value },
-});
-
-const userSelect = (value: string): Styles[number] => ({
- property: "userSelect",
- value: { type: "keyword", value },
-});
-
-const boxSizing = (value: string): Styles[number] => ({
- property: "boxSizing",
- value: { type: "keyword", value },
-});
-
-/* blocks */
-
-export const article: Styles = [display("block")];
-export {
- article as aside,
- article as details,
- article as div,
- article as dt,
- article as figcaption,
- article as footer,
- article as form,
- article as header,
- article as hgroup,
- article as html,
- article as main,
- article as nav,
- article as section,
- article as summary,
-};
-
-export const body: Styles = [
- display("block"),
- marginTop(8, "px"),
- marginRight(8, "px"),
- marginBottom(8, "px"),
- marginLeft(8, "px"),
-];
-
-export const p: Styles = [
- display("block"),
- marginTop(1, "em"),
- marginBottom(1, "em"),
-];
-export { p as dl };
-
-export const dd: Styles = [display("block"), marginLeft(40, "px")];
-
-export const blockquote: Styles = [
- display("block"),
- marginTop(1, "em"),
- marginBottom(1, "em"),
- marginLeft(40, "px"),
- marginRight(40, "px"),
-];
-export { blockquote as figure };
-
-export const address: Styles = [display("block"), fontStyle("italic")];
-
-// h1 font-size, margin-top and margin-bottom depend on outer tags
-// so better define statically in preset styles
-export const h1: Styles = [
- display("block"),
- fontWeight("bold"),
- fontSize(2, "em"),
- marginTop(0.67, "em"),
- marginBottom(0.67, "em"),
-];
-
-export const h2: Styles = [
- display("block"),
- fontWeight("bold"),
- fontSize(1.5, "em"),
- marginTop(0.83, "em"),
- marginBottom(0.83, "em"),
-];
-
-export const h3: Styles = [
- display("block"),
- fontWeight("bold"),
- fontSize(1.17, "em"),
- marginTop(1, "em"),
- marginBottom(1, "em"),
-];
-
-export const h4: Styles = [
- display("block"),
- fontWeight("bold"),
- marginTop(1.33, "em"),
- marginBottom(1.33, "em"),
-];
-
-export const h5: Styles = [
- display("block"),
- fontWeight("bold"),
- fontSize(0.83, "em"),
- marginTop(1.67, "em"),
- marginBottom(1.67, "em"),
-];
-
-export const h6: Styles = [
- display("block"),
- fontWeight("bold"),
- fontSize(0.67, "em"),
- marginTop(2.33, "em"),
- marginBottom(2.33, "em"),
-];
-
-export const pre: Styles = [
- display("block"),
- whiteSpaceCollapse("preserve"),
- textWrapMode("nowrap"),
- marginTop(1, "em"),
- marginBottom(1, "em"),
-];
-
-/* tables */
-
-export const table: Styles = [
- display("table"),
- {
- property: "borderSpacing",
- value: { type: "unit", value: 2, unit: "px" },
- },
- {
- property: "borderCollapse",
- value: { type: "keyword", value: "separate" },
- },
- boxSizing("border-box"),
- {
- property: "textIndent",
- value: { type: "unit", value: 0, unit: "number" },
- },
-];
-
-export const caption: Styles = [display("table-caption"), textAlign("center")];
-
-export const tr: Styles = [display("table-row"), verticalAlign("inherit")];
-
-export const col: Styles = [display("table-column")];
-
-export const colgroup: Styles = [display("table-column-group")];
-
-export const tbody: Styles = [
- display("table-row-group"),
- verticalAlign("middle"),
-];
-
-export const thead: Styles = [
- display("table-header-group"),
- verticalAlign("middle"),
-];
-
-export const tfoot: Styles = [
- display("table-footer-group"),
- verticalAlign("middle"),
-];
-
-export const td: Styles = [
- display("table-cell"),
- verticalAlign("inherit"),
- paddingTop(1, "px"),
- paddingRight(1, "px"),
- paddingBottom(1, "px"),
- paddingLeft(1, "px"),
-];
-
-export const th: Styles = [
- display("table-cell"),
- verticalAlign("inherit"),
- fontWeight("bold"),
- paddingTop(1, "px"),
- paddingRight(1, "px"),
- paddingBottom(1, "px"),
- paddingLeft(1, "px"),
-];
-
-/* inlines */
-
-export const b: Styles = [
- // in firefox defined as bolder
- fontWeight("bold"),
-];
-export { b as strong };
-
-export const i: Styles = [fontStyle("italic")];
-export { i as cite, i as em, i as var, i as dfn };
-
-export const code: Styles = [
- {
- property: "fontFamily",
- // in firefox defined as -moz-fixed
- value: { type: "fontFamily", value: ["monospace"] },
- },
-];
-export { code as kbd, code as samp };
-
-export const mark: Styles = [
- {
- property: "backgroundColor",
- // in firefox defined as Mark
- value: { type: "keyword", value: "yellow" },
- },
- // in firefox defined as MarkText
- color("black"),
-];
-
-export const u: Styles = [
- {
- property: "textDecorationStyle",
- value: { type: "keyword", value: "underline" },
- },
-];
-export { u as ins };
-
-export const s: Styles = [
- {
- property: "textDecorationStyle",
- value: { type: "keyword", value: "line-through" },
- },
-];
-export { s as del };
-
-export const sub: Styles = [
- verticalAlign("sub"),
- {
- property: "fontSize",
- value: { type: "keyword", value: "smaller" },
- },
-];
-
-export const sup: Styles = [
- verticalAlign("super"),
- {
- property: "fontSize",
- value: { type: "keyword", value: "smaller" },
- },
-];
-
-export const a: Styles = [
- {
- property: "textDecorationLine",
- value: { type: "keyword", value: "underline" },
- },
- cursor("pointer"),
- {
- property: "color",
- value: { type: "rgb", r: 0, g: 0, b: 238, alpha: 1 },
- },
- // active and visited states are not defined as usually overriden with stateless color
- // and modeling var-like defaults is too complex
-];
-
-/* lists */
-
-// nested lists have no top/bottom margins
-// so better redefine statically in preset
-export const ul: Styles = [
- display("block"),
- {
- property: "listStyleType",
- value: { type: "keyword", value: "disc" },
- },
- marginTop(1, "em"),
- marginBottom(1, "em"),
- paddingLeft(40, "px"),
-];
-
-export const ol: Styles = [
- display("block"),
- {
- property: "listStyleType",
- value: { type: "keyword", value: "decimal" },
- },
- marginTop(1, "em"),
- marginBottom(1, "em"),
- paddingLeft(40, "px"),
-];
-
-export const li: Styles = [display("list-item"), textAlign("match-parent")];
-
-/* leafs */
-
-export const hr: Styles = [
- color("gray"),
- ...borderWidth(1, "px"),
- ...borderStyle("inset"),
- marginTop(0.5, "em"),
- marginBottom(0.5, "em"),
- {
- property: "marginLeft",
- value: { type: "keyword", value: "auto" },
- },
- {
- property: "marginRight",
- value: { type: "keyword", value: "auto" },
- },
- // firefox only
- ...overflow("hidden"),
- /* This is not really per spec but all browsers define it */
- display("block"),
-];
-
-/**
- * forms
- * https://searchfox.org/mozilla-central/source/layout/style/res/forms.css
- **/
-
-const formControlReset: Styles = [
- // in firefox defined as FieldText
- color("initial"),
- { property: "letterSpacing", value: { type: "keyword", value: "normal" } },
- { property: "wordSpacing", value: { type: "keyword", value: "normal" } },
- { property: "lineHeight", value: { type: "keyword", value: "normal" } },
- { property: "textTransform", value: { type: "keyword", value: "none" } },
- { property: "textIndent", value: { type: "unit", value: 0, unit: "number" } },
- { property: "textShadow", value: { type: "keyword", value: "none" } },
- display("inline-block"),
- textAlign("start"),
-];
-
-export const legend: Styles = [
- display("block"),
- paddingLeft(2, "px"),
- paddingRight(2, "px"),
-];
-
-export const fieldset: Styles = [
- display("block"),
- marginLeft(2, "px"),
- marginRight(2, "px"),
- paddingTop(0.35, "em"),
- paddingBottom(0.625, "em"),
- paddingLeft(0.75, "em"),
- paddingRight(0.75, "em"),
- ...borderWidth(2, "px"),
- // in browsers defined as groove
- ...borderStyle("solid"),
- ...borderColor("ThreeDFace"),
- { property: "minWidth", value: { type: "keyword", value: "min-content" } },
-];
-
-export const label: Styles = [cursor("default")];
-
-export const input: Styles = [
- appearance("auto"),
- paddingTop(1, "px"),
- paddingRight(1, "px"),
- paddingBottom(1, "px"),
- paddingLeft(1, "px"),
- ...borderWidth(2, "px"),
- // in browsers defined as inset
- ...borderStyle("solid"),
- // in firefox defined as Field
- { property: "backgroundColor", value: { type: "keyword", value: "white" } },
- cursor("text"),
-];
-
-export const textarea: Styles = [
- ...formControlReset,
- appearance("auto"),
- marginTop(1, "px"),
- marginBottom(1, "px"),
- // in firefox 2px
- ...borderWidth(1, "px"),
- // in browsers defined as inset
- ...borderStyle("solid"),
- paddingTop(2, "px"),
- paddingRight(2, "px"),
- paddingBottom(2, "px"),
- paddingLeft(2, "px"),
- // in firefox defined as Field
- { property: "backgroundColor", value: { type: "keyword", value: "white" } },
- verticalAlign("text-bottom"),
- cursor("text"),
- { property: "resize", value: { type: "keyword", value: "both" } },
- whiteSpaceCollapse("preserve"),
- textWrapMode("wrap"),
- {
- property: "wordWrap",
- value: { type: "keyword", value: "break-word" },
- },
-];
-
-export const select: Styles = [
- ...formControlReset,
- display("inline-block"),
- marginTop(0),
- marginRight(0),
- marginBottom(0),
- marginLeft(0),
- paddingTop(1, "px"),
- paddingBottom(1, "px"),
- paddingRight(4, "px"),
- paddingLeft(4, "px"),
- ...borderWidth(2, "px"),
- // in browsers defined as inset
- ...borderStyle("solid"),
- textWrapMode("nowrap"),
- {
- property: "wordWrap",
- value: { type: "keyword", value: "normal" },
- },
- cursor("default"),
- boxSizing("border-box"),
- userSelect("none"),
- ...overflow("clip"),
- verticalAlign("baseline"),
- appearance("auto"),
-];
-
-export const option: Styles = [
- display("block"),
- { property: "float", value: { type: "keyword", value: "none" } },
- { property: "position", value: { type: "keyword", value: "static" } },
- { property: "minHeight", value: { type: "unit", value: 1, unit: "em" } },
- paddingTop(2, "px"),
- paddingBottom(2, "px"),
- paddingRight(2, "px"),
- paddingLeft(4, "px"),
- userSelect("none"),
- textWrapMode("nowrap"),
- {
- property: "wordWrap",
- value: { type: "keyword", value: "normal" },
- },
-];
-
-export const button: Styles = [
- ...formControlReset,
- appearance("auto"),
- // in firefox defined as 1px 8px
- paddingTop(2, "px"),
- paddingBottom(3, "px"),
- paddingLeft(6, "px"),
- paddingRight(6, "px"),
- ...borderWidth(2, "px"),
- // in browsers defined as outset
- ...borderStyle("solid"),
- cursor("default"),
- boxSizing("border-box"),
- userSelect("none"),
- textAlign("center"),
- {
- property: "backgroundColor",
- // in browsers defined as ButtonFace
- value: { type: "keyword", value: "lightgray" },
- },
-];
diff --git a/packages/css-data/src/index.ts b/packages/css-data/src/index.ts
index c31ad1d9e7..7d3d6c29f6 100644
--- a/packages/css-data/src/index.ts
+++ b/packages/css-data/src/index.ts
@@ -1,7 +1,13 @@
import type { WritableDeep } from "type-fest";
-import type { Html } from "./html";
-import * as exportedHtml from "./html";
-export const html: Html = exportedHtml;
+import type { htmlTags as HtmlTags } from "html-tags";
+import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";
+import { html as htmlJson } from "./__generated__/html";
+
+type Html = {
+ [tag in HtmlTags]?: Array<{ property: StyleProperty; value: StyleValue }>;
+};
+undefined as unknown as keyof typeof htmlJson satisfies HtmlTags;
+export const html = htmlJson as Html;
export * from "./__generated__/keyword-values";
export * from "./__generated__/units";