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.

use any temporarily

Oleg Isonen48f66a0dc212
diff --git a/apps/designer/app/canvas/shared/styles.ts b/apps/designer/app/canvas/shared/styles.ts
index d54fed3463..e3b6f26a7f 100644
--- a/apps/designer/app/canvas/shared/styles.ts
+++ b/apps/designer/app/canvas/shared/styles.ts
@@ -100,7 +100,8 @@ export const GlobalStyles = ({ assets }: { assets: Array<Asset> }) => {
});
} else {
varsRuleRef.current.styleMap.clear();
- for (const property in style) {
+ let property: StyleProperty;
+ for (property in style) {
varsRuleRef.current.styleMap.set(property, style[property]);
}
}
diff --git a/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts b/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts
index 62e7202223..3125f6f817 100644
--- a/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts
@@ -14,7 +14,8 @@ const propertyNames = Object.keys(properties) as Array<StyleProperty>;
// All inheritable properties we support
const inheritableProperties: InheritableProperties = propertyNames.reduce(
(acc: InheritableProperties, property: StyleProperty) => {
- const config = properties[property];
+ // @todo
+ const config = (properties as any)[property];
if (config.inherited) {
acc[property as StyleProperty] = true;
}
diff --git a/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts b/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts
index e24e632ddf..85ca10fa72 100644
--- a/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts
@@ -135,7 +135,8 @@ export const useStyleData = ({
publishUpdates("update", updates);
const nextStyle = updates.reduce(
(currentStyle, { property, value }) => {
- currentStyle[property] = value;
+ // @todo
+ (currentStyle as any)[property] = value;
return currentStyle;
},
{ ...currentStyle }
diff --git a/packages/css-data/src/schema.ts b/packages/css-data/src/schema.ts
index 0808d3745f..312fd52008 100644
--- a/packages/css-data/src/schema.ts
+++ b/packages/css-data/src/schema.ts
@@ -2,10 +2,18 @@ import { units } from "./units";
import { properties } from "./properties";
import { z } from "zod";
-type Properties = typeof properties;
+type Properties = typeof properties & {
+ [custom: CustomProperty]: {
+ appliesTo: "allElements";
+ initial: string;
+ inherited: boolean;
+ };
+};
export type StyleProperty = keyof Properties;
+type CustomProperty = `--${string}`;
+
export type AppliesTo = Properties[StyleProperty]["appliesTo"];
export const Unit = z.union([z.enum(units), z.literal("number")]);
@@ -73,11 +81,9 @@ export type StyleValue = z.infer<typeof StyleValue>;
export const Style = z.record(z.string(), StyleValue);
-type CustomProperty = `--${string}`;
-
export type Style = {
- [property in StyleProperty | CustomProperty]?: StyleValue;
-};
+ [property in StyleProperty]?: StyleValue;
+} & { [property: CustomProperty]: StyleValue };
export const CssRule = z.object({
style: Style,
diff --git a/packages/css-engine/src/core/css-engine.ts b/packages/css-engine/src/core/css-engine.ts
index 90700ef65d..c62d7aa6ec 100644
--- a/packages/css-engine/src/core/css-engine.ts
+++ b/packages/css-engine/src/core/css-engine.ts
@@ -45,7 +45,8 @@ export class CssEngine {
// Should be impossible to reach.
throw new Error("No media rule found");
}
- return mediaRule.insertRule(styleRule);
+ mediaRule.insertRule(styleRule);
+ return styleRule;
}
addPlaintextRule(cssText: string) {
const rule = this.#plainRules.get(cssText);
diff --git a/packages/react-sdk/src/css/get-browser-style.ts b/packages/react-sdk/src/css/get-browser-style.ts
index b38391e123..452e11c093 100644
--- a/packages/react-sdk/src/css/get-browser-style.ts
+++ b/packages/react-sdk/src/css/get-browser-style.ts
@@ -21,8 +21,9 @@ const parseValue = (property: StyleProperty, value: string): StyleValue => {
};
}
- if (number === 0) {
- return properties[property].initial;
+ if (number === 0 && property in properties) {
+ // @todo
+ return (properties as any)[property].initial;
}
return {