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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Fix unstable lostpixel (#1493)
Roman Pominov012765fd4a67
diff --git a/apps/builder/.storybook/preview.tsx b/apps/builder/.storybook/preview.tsxindex f4a8c0012d..37d348ef61 100644--- a/apps/builder/.storybook/preview.tsx+++ b/apps/builder/.storybook/preview.tsx@@ -3,6 +3,7 @@ import { TooltipProvider } from "@radix-ui/react-tooltip";import { theme, globalCss } from "@webstudio-is/design-system";import { setEnv } from "@webstudio-is/feature-flags";import "@webstudio-is/storybook-config/setup-fonts";+import { decorators as globalDecorators } from "@webstudio-is/storybook-config/decorators";export const parameters = {actions: { argTypesRegex: "^on[A-Z].*" },@@ -23,6 +24,7 @@ const globalStyles = globalCss({});export const decorators = [+ ...globalDecorators,(StoryFn: any) => {globalStyles();setEnv("*");diff --git a/packages/design-system/.storybook/preview.js b/packages/design-system/.storybook/preview.jsindex c644259b63..2342665952 100644--- a/packages/design-system/.storybook/preview.js+++ b/packages/design-system/.storybook/preview.js@@ -1,6 +1,8 @@import "@webstudio-is/storybook-config/setup-fonts";import { color } from "../src/__generated__/figma-design-tokens";+export { decorators } from "@webstudio-is/storybook-config/decorators";+export const parameters = {actions: { argTypesRegex: "^on[A-Z].*" },controls: {diff --git a/packages/storybook-config/decorators.tsx b/packages/storybook-config/decorators.tsxnew file mode 100644index 0000000000..a58195ec3e--- /dev/null+++ b/packages/storybook-config/decorators.tsx@@ -0,0 +1,38 @@+import * as React from "react";+import { useEffect } from "react";++const WaitForFonts = ({ children }) => {+ const [isFontsLoaded, setIsFontsLoaded] = React.useState(false);++ useEffect(() => {+ let isUnsubscribed = false;+ document.fonts.ready.then(() => {+ if (isUnsubscribed === false) {+ setIsFontsLoaded(true);+ }+ });+ return () => {+ isUnsubscribed = true;+ };+ }, []);++ return isFontsLoaded ? (+ children+ ) : (+ <div>+ Waiting for fonts to load ...+ {/* not rendering children initially breaks backgrounds addon,+ * so we always render it */}+ <div style={{ display: "none" }}>{children}</div>+ </div>+ );+};++export const decorators = [+ // waiting for fonts makes screenshot tests more stable+ (Story) => (+ <WaitForFonts>+ <Story />+ </WaitForFonts>+ ),+];