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.

Support bold and normal font-weight (#1641)

Bogdan Chadkin9d0285f56be8
diff --git a/apps/builder/app/builder/features/style-panel/controls/font-weight/font-weight-control.tsx b/apps/builder/app/builder/features/style-panel/controls/font-weight/font-weight-control.tsx
index b246b48e7f..d59fe5718f 100644
--- a/apps/builder/app/builder/features/style-panel/controls/font-weight/font-weight-control.tsx
+++ b/apps/builder/app/builder/features/style-panel/controls/font-weight/font-weight-control.tsx
@@ -49,6 +49,13 @@ const useLabels = (
availableFontWeights: Array<FontWeightItem>,
currentWeight: string
) => {
+ // support named aliases
+ if (currentWeight === "normal") {
+ currentWeight = "400";
+ }
+ if (currentWeight === "bold") {
+ currentWeight = "700";
+ }
const labels = useMemo(
() => availableFontWeights.map((option) => option.label),
[availableFontWeights]
diff --git a/packages/css-data/bin/mdn-data.ts b/packages/css-data/bin/mdn-data.ts
index f0fc736382..3fbe60c08c 100755
--- a/packages/css-data/bin/mdn-data.ts
+++ b/packages/css-data/bin/mdn-data.ts
@@ -65,16 +65,6 @@ const beautifyKeyword = (property: string, keyword: string) => {
if (keyword === "currentcolor" || keyword === "invertOrCurrentColor") {
return "currentColor";
}
- // builder style panel cannot interpret "normal" and "bold"
- // always expected numeric value
- if (property === "font-weight") {
- if (keyword === "normal") {
- return "400";
- }
- if (keyword === "bold") {
- return "700";
- }
- }
return keyword;
};
diff --git a/packages/css-data/src/__generated__/keyword-values.ts b/packages/css-data/src/__generated__/keyword-values.ts
index 4d8a443ca4..fcc23e6725 100644
--- a/packages/css-data/src/__generated__/keyword-values.ts
+++ b/packages/css-data/src/__generated__/keyword-values.ts
@@ -3836,8 +3836,8 @@ export const keywordValues = {
"unset",
],
fontWeight: [
- "400",
- "700",
+ "normal",
+ "bold",
"bolder",
"lighter",
"initial",
diff --git a/packages/css-data/src/__generated__/properties.ts b/packages/css-data/src/__generated__/properties.ts
index 0ced72ff2a..53e3ee6632 100644
--- a/packages/css-data/src/__generated__/properties.ts
+++ b/packages/css-data/src/__generated__/properties.ts
@@ -1445,7 +1445,7 @@ export const properties = {
inherited: true,
initial: {
type: "keyword",
- value: "400",
+ value: "normal",
},
popularity: 0.88598106,
appliesTo: "allElements",
diff --git a/packages/css-data/src/html.ts b/packages/css-data/src/html.ts
index 58497c9db6..983d03f4b1 100644
--- a/packages/css-data/src/html.ts
+++ b/packages/css-data/src/html.ts
@@ -48,9 +48,7 @@ const pl40px: Styles[number] = {
const fontWeightBold: Styles[number] = {
property: "fontWeight",
- // in browsers defined as bold
- // though builder accepts only numeric values
- value: { type: "keyword", value: "700" },
+ value: { type: "keyword", value: "bold" },
};
const fontStyleItalic: Styles[number] = {