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: remove css variables feature flag (#4337)

Bogdan Chadkin82c301372b72
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/navigator/navigator-tree.tsx b/apps/builder/app/builder/features/sidebar-left/panels/navigator/navigator-tree.tsx
index e6281874d1..782ddafc64 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/navigator/navigator-tree.tsx
+++ b/apps/builder/app/builder/features/sidebar-left/panels/navigator/navigator-tree.tsx
@@ -3,7 +3,6 @@ import { nanoid } from "nanoid";
import { atom, computed } from "nanostores";
import { mergeRefs } from "@react-aria/utils";
import { useStore } from "@nanostores/react";
-import { isFeatureEnabled } from "@webstudio-is/feature-flags";
import {
Box,
rawTheme,
@@ -481,7 +480,7 @@ export const NavigatorTree = () => {
}}
>
<TreeRoot>
- {isFeatureEnabled("cssVars") && rootMeta && (
+ {rootMeta && (
<TreeNode
level={0}
isSelected={selectedKey === ROOT_INSTANCE_ID}
diff --git a/apps/builder/app/builder/features/style-panel/property-label.tsx b/apps/builder/app/builder/features/style-panel/property-label.tsx
index 3c28dca3e7..c65a2c5b16 100644
--- a/apps/builder/app/builder/features/style-panel/property-label.tsx
+++ b/apps/builder/app/builder/features/style-panel/property-label.tsx
@@ -2,7 +2,6 @@ import { atom } from "nanostores";
import { useStore } from "@nanostores/react";
import { useState, type ReactNode } from "react";
import { AlertIcon, ResetIcon } from "@webstudio-is/icons";
-import { isFeatureEnabled } from "@webstudio-is/feature-flags";
import {
hyphenateProperty,
toValue,
@@ -55,7 +54,7 @@ const renderCss = (styles: ComputedStyleDecl[], isComputed: boolean) => {
for (const styleDecl of styles) {
const property = hyphenateProperty(styleDecl.property);
let value;
- if (isComputed && isFeatureEnabled("cssVars")) {
+ if (isComputed) {
value = toValue(styleDecl.usedValue);
} else {
value = toValue(styleDecl.cascadedValue);
diff --git a/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx b/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx
index 86bae276c8..fa66489084 100644
--- a/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx
@@ -11,7 +11,6 @@ import {
import { useStore } from "@nanostores/react";
import { computed } from "nanostores";
import { matchSorter } from "match-sorter";
-import { isFeatureEnabled } from "@webstudio-is/feature-flags";
import { PlusIcon } from "@webstudio-is/icons";
import {
Box,
@@ -123,9 +122,6 @@ const matchOrSuggestToCreate = (
const matched = matchSorter(items, search, {
keys: [itemToString],
});
- if (isFeatureEnabled("cssVars") === false) {
- return matched;
- }
const propertyName = search.trim();
if (
propertyName.startsWith("--") &&
@@ -149,9 +145,7 @@ const getNewPropertyDescription = (item: null | SearchItem) => {
};
const insertStyles = (text: string) => {
- const parsedStyles = parseCss(`selector{${text}}`, {
- customProperties: true,
- });
+ const parsedStyles = parseCss(`selector{${text}}`);
if (parsedStyles.length === 0) {
return false;
}
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-fragment.tsx b/apps/builder/app/builder/features/style-panel/shared/css-fragment.tsx
index 12da00f932..5308066e55 100644
--- a/apps/builder/app/builder/features/style-panel/shared/css-fragment.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/css-fragment.tsx
@@ -9,7 +9,6 @@ import {
} from "@codemirror/autocomplete";
import { parseCss } from "@webstudio-is/css-data";
import { css as style } from "@webstudio-is/design-system";
-import { isFeatureEnabled } from "@webstudio-is/feature-flags";
import {
CodeEditorBase,
getMinMaxHeightVars,
@@ -17,14 +16,10 @@ import {
import { $availableVariables } from "./model";
export const parseCssFragment = (css: string, fallbacks: string[]) => {
- let parsed = parseCss(`.styles{${css}}`, {
- customProperties: isFeatureEnabled("cssVars"),
- });
+ let parsed = parseCss(`.styles{${css}}`);
if (parsed.length === 0) {
for (const fallbackProperty of fallbacks) {
- parsed = parseCss(`.styles{${fallbackProperty}: ${css}}`, {
- customProperties: isFeatureEnabled("cssVars"),
- });
+ parsed = parseCss(`.styles{${fallbackProperty}: ${css}}`);
parsed = parsed.filter((styleDecl) => styleDecl.value.type !== "invalid");
if (parsed.length > 0) {
break;
diff --git a/apps/builder/app/shared/style-object-model.test.tsx b/apps/builder/app/shared/style-object-model.test.tsx
index 0964eaa6d5..efdcd960f1 100644
--- a/apps/builder/app/shared/style-object-model.test.tsx
+++ b/apps/builder/app/shared/style-object-model.test.tsx
@@ -46,7 +46,7 @@ const createModel = ({
matchingStates?: Set<string>;
}): StyleObjectModel => {
const instanceTags = new Map<Instance["id"], HtmlTags>();
- const parsedStyles = parseCss(css, { customProperties: true });
+ const parsedStyles = parseCss(css);
const styles: Styles = new Map();
for (const { breakpoint, selector, state, property, value } of parsedStyles) {
const styleDecl: StyleDecl = {
@@ -77,7 +77,7 @@ const createModel = ({
}
const presetStyles = new Map<string, StyleValue>();
for (const [componentName, css] of Object.entries(presets ?? {})) {
- const parsedStyles = parseCss(css, { customProperties: true });
+ const parsedStyles = parseCss(css);
for (const styleDecl of parsedStyles) {
const key = getPresetStyleDeclKey({
component: componentName,
diff --git a/packages/css-data/src/parse-css.test.ts b/packages/css-data/src/parse-css.test.ts
index 6d6e662b25..e8d0af223f 100644
--- a/packages/css-data/src/parse-css.test.ts
+++ b/packages/css-data/src/parse-css.test.ts
@@ -406,18 +406,7 @@ describe("Parse CSS", () => {
]);
});
- // @todo https://github.com/webstudio-is/webstudio/issues/3399
- test("parse variable as unset default", () => {
- expect(parseCss(`a { color: var(--color) }`)).toEqual([
- {
- selector: "a",
- property: "color",
- value: { type: "keyword", value: "unset" },
- },
- ]);
- });
-
- test("optionally parse variable as var value", () => {
+ test("parse variable as var value", () => {
expect(
parseCss(
`
@@ -425,8 +414,7 @@ describe("Parse CSS", () => {
color: var(--color);
background-color: var(--color, red);
}
- `,
- { customProperties: true }
+ `
)
).toEqual([
{
diff --git a/packages/css-data/src/parse-css.ts b/packages/css-data/src/parse-css.ts
index 292c3b5fef..8cb5a7a07e 100644
--- a/packages/css-data/src/parse-css.ts
+++ b/packages/css-data/src/parse-css.ts
@@ -57,8 +57,7 @@ const unprefixProperty = (property: string) => {
const parseCssValue = (
property: string,
- value: string,
- { customProperties }: { customProperties: boolean }
+ value: string
): Map<StyleProperty, StyleValue> => {
const expanded = new Map(expandShorthands([[property, value]]));
const final = new Map();
@@ -70,12 +69,6 @@ const parseCssValue = (
continue;
}
- // @todo https://github.com/webstudio-is/webstudio/issues/3399
- if (customProperties === false && value.includes("var(")) {
- final.set(property, { type: "keyword", value: "unset" });
- continue;
- }
-
final.set(
property,
parseCssValueLonghand(
@@ -101,12 +94,7 @@ type Selector = {
state?: string;
};
-type ParserOptions = {
- customProperties?: boolean;
-};
-
-export const parseCss = (css: string, options: ParserOptions = {}) => {
- const customProperties = options.customProperties ?? false;
+export const parseCss = (css: string) => {
const ast = cssTreeTryParse(css);
const styles = new Map<string, ParsedStyleDecl>();
@@ -231,8 +219,7 @@ export const parseCss = (css: string, options: ParserOptions = {}) => {
const parsedCss = parseCssValue(
unprefixProperty(node.property),
- stringValue,
- { customProperties }
+ stringValue
);
for (const { name: selector, state } of selectors) {
diff --git a/packages/feature-flags/src/flags.ts b/packages/feature-flags/src/flags.ts
index cadfe0dd43..0b6ccfc40a 100644
--- a/packages/feature-flags/src/flags.ts
+++ b/packages/feature-flags/src/flags.ts
@@ -4,7 +4,6 @@ export const internalComponents = false;
export const unsupportedBrowsers = false;
export const aiRadixComponents = false;
export const cms = false;
-export const cssVars = false;
export const filters = false;
export const xmlElement = false;
export const staticExport = false;