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.

chore: more stories updates (#5646)

Oleg Isonenc4d26cbf62bb
diff --git a/apps/builder/app/builder/features/breakpoints/breakpoints-selector.stories.tsx b/apps/builder/app/builder/features/breakpoints/breakpoints-selector.stories.tsx
index a40ec7f37e..ffc154ecec 100644
--- a/apps/builder/app/builder/features/breakpoints/breakpoints-selector.stories.tsx
+++ b/apps/builder/app/builder/features/breakpoints/breakpoints-selector.stories.tsx
@@ -1,15 +1,28 @@
import { StorySection } from "@webstudio-is/design-system";
import { BreakpointsSelector as BreakpointsSelectorComponent } from "./breakpoints-selector";
+import { $breakpoints } from "~/shared/nano-states";
+import { $selectedBreakpointId } from "~/shared/nano-states/breakpoints";
+
+const breakpointsMap = new Map([
+ ["1", { id: "1", label: "Mobile", maxWidth: 479 }],
+ ["2", { id: "2", label: "Tablet", maxWidth: 991 }],
+ ["3", { id: "3", label: "" }],
+ ["4", { id: "4", label: "Desktop", minWidth: 1280 }],
+ ["5", { id: "5", label: "Wide", minWidth: 1440 }],
+]);
+
+$breakpoints.set(breakpointsMap);
+$selectedBreakpointId.set("3");
export const BreakpointsSelector = () => {
return (
- <StorySection title="Breakpoints Selector">
+ <StorySection title="Breakpoints selector">
<BreakpointsSelectorComponent />
</StorySection>
);
};
export default {
- title: "Breakpoints Selector",
+ title: "Breakpoints selector",
component: BreakpointsSelector,
};
diff --git a/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.stories.tsx b/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.stories.tsx
index 0b9289fb62..c0ee270eff 100644
--- a/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.stories.tsx
+++ b/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.stories.tsx
@@ -15,7 +15,7 @@ export default {
style={{
background: theme.colors.backgroundPanel,
padding: 16,
- maxWidth: theme.sizes.sidebarWidth,
+ width: theme.sizes.sidebarWidth,
}}
>
<Story />
diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-content.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-content.stories.tsx
index f3346b9f89..c4d258f475 100644
--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-content.stories.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-content.stories.tsx
@@ -1,10 +1,11 @@
-import { useEffect, useRef } from "react";
+import { useEffect } from "react";
import { getStyleDeclKey, type StyleDecl } from "@webstudio-is/sdk";
import {
- FloatingPanel,
+ Box,
Flex,
StorySection,
Text,
+ theme,
} from "@webstudio-is/design-system";
import { createDefaultPages } from "@webstudio-is/project-build";
import {
@@ -60,7 +61,6 @@ $awareness.set({
});
const BackgroundStory = ({ styleValue }: { styleValue: StyleValue }) => {
- const elementRef = useRef<HTMLDivElement>(null);
const backgroundImage = useComputedStyleDecl("background-image");
useEffect(() => {
@@ -69,21 +69,9 @@ const BackgroundStory = ({ styleValue }: { styleValue: StyleValue }) => {
}, []);
return (
- <>
- <div
- ref={elementRef}
- style={{ marginLeft: "400px" }}
- data-floating-panel-container
- ></div>
-
- <FloatingPanel
- open
- title="Background"
- content={<BackgroundContentPanel index={0} />}
- >
- <button>Trigger</button>
- </FloatingPanel>
- </>
+ <Box css={{ width: theme.sizes.sidebarWidth }}>
+ <BackgroundContentPanel index={0} />
+ </Box>
);
};
diff --git a/packages/design-system/src/components/color-picker.stories.tsx b/packages/design-system/src/components/color-picker.stories.tsx
index a84584f351..75570a55c0 100644
--- a/packages/design-system/src/components/color-picker.stories.tsx
+++ b/packages/design-system/src/components/color-picker.stories.tsx
@@ -6,6 +6,7 @@ import {
ColorThumb,
} from "./color-picker";
import { Flex } from "./flex";
+import { Grid } from "./grid";
import { Text } from "./text";
import { StorySection } from "./storybook";
@@ -77,7 +78,13 @@ export const PopoverPositioning = () => {
}
};
return (
- <Flex gap="9" align="center" wrap="wrap" style={{ padding: 100 }}>
+ <Grid
+ columns={2}
+ gap="9"
+ align="center"
+ justify="center"
+ style={{ padding: 100, minHeight: "100vh" }}
+ >
<Flex direction="column" gap="2" align="center">
<Text variant="labels">Side top</Text>
<ColorPickerPopover
@@ -119,6 +126,6 @@ export const PopoverPositioning = () => {
open={true}
/>
</Flex>
- </Flex>
+ </Grid>
);
};
diff --git a/packages/design-system/src/components/combobox.stories.tsx b/packages/design-system/src/components/combobox.stories.tsx
index 530ffe6cf1..d3914041d7 100644
--- a/packages/design-system/src/components/combobox.stories.tsx
+++ b/packages/design-system/src/components/combobox.stories.tsx
@@ -18,24 +18,22 @@ import { Flex } from "./flex";
import { InputField } from "./input-field";
import { StorySection } from "./storybook";
-export const Basic = () => {
+const BasicDemo = () => {
const [value, setValue] = useState("");
return (
- <StorySection title="Basic">
- <Combobox<string>
- value={value}
- itemToString={(item) => item ?? ""}
- getItems={() => ["Apple", "Banana", "Orange"]}
- onItemSelect={setValue}
- onChange={(value) => {
- setValue(value ?? "");
- }}
- />
- </StorySection>
+ <Combobox<string>
+ value={value}
+ itemToString={(item) => item ?? ""}
+ getItems={() => ["Apple", "Banana", "Orange"]}
+ onItemSelect={setValue}
+ onChange={(value) => {
+ setValue(value ?? "");
+ }}
+ />
);
};
-export const Complex = () => {
+const ComplexDemo = () => {
const [value, setValue] = useState("");
const stateReducer = useCallback(
@@ -73,91 +71,83 @@ export const Complex = () => {
});
return (
- <StorySection title="Complex">
- <ComboboxRoot open={isOpen}>
- <Flex {...getComboboxProps()} direction="column" gap="3">
- <ComboboxAnchor asChild>
- <InputField
- prefix={
- <Flex align="center">
- <SearchIcon />
- </Flex>
- }
- {...getInputProps({ value })}
- />
- </ComboboxAnchor>
- <ComboboxContent>
- <ComboboxListbox {...getMenuProps()}>
- {items.map((item, index) => {
- return (
- <ComboboxListboxItem
- {...getItemProps({ item, index })}
- key={index}
- >
- {item}
- </ComboboxListboxItem>
- );
- })}
- <ComboboxItemDescription
- descriptions={["Hello", "World", "Description"]}
- >
- Description
- </ComboboxItemDescription>
- </ComboboxListbox>
- </ComboboxContent>
- </Flex>
- </ComboboxRoot>
- </StorySection>
+ <ComboboxRoot open={isOpen}>
+ <Flex {...getComboboxProps()} direction="column" gap="3">
+ <ComboboxAnchor asChild>
+ <InputField
+ prefix={
+ <Flex align="center">
+ <SearchIcon />
+ </Flex>
+ }
+ {...getInputProps({ value })}
+ />
+ </ComboboxAnchor>
+ <ComboboxContent>
+ <ComboboxListbox {...getMenuProps()}>
+ {items.map((item, index) => {
+ return (
+ <ComboboxListboxItem
+ {...getItemProps({ item, index })}
+ key={index}
+ >
+ {item}
+ </ComboboxListboxItem>
+ );
+ })}
+ <ComboboxItemDescription
+ descriptions={["Hello", "World", "Description"]}
+ >
+ Description
+ </ComboboxItemDescription>
+ </ComboboxListbox>
+ </ComboboxContent>
+ </Flex>
+ </ComboboxRoot>
);
};
-export const WithPlaceholder = () => {
+const WithPlaceholderDemo = () => {
const [value, setValue] = useState("");
return (
- <StorySection title="With placeholder">
- <Combobox<string>
- value={value}
- itemToString={(item) => item ?? ""}
- getItems={() => ["Apple", "Banana", "Orange"]}
- onItemSelect={setValue}
- onChange={(value) => setValue(value ?? "")}
- placeholder="Search fruits…"
- />
- </StorySection>
+ <Combobox<string>
+ value={value}
+ itemToString={(item) => item ?? ""}
+ getItems={() => ["Apple", "Banana", "Orange"]}
+ onItemSelect={setValue}
+ onChange={(value) => setValue(value ?? "")}
+ placeholder="Search fruits…"
+ />
);
};
-export const WithAutoFocus = () => {
+const WithAutoFocusDemo = () => {
const [value, setValue] = useState("");
return (
- <StorySection title="With auto focus">
- <Combobox<string>
- value={value}
- itemToString={(item) => item ?? ""}
- getItems={() => ["Apple", "Banana", "Orange"]}
- onItemSelect={setValue}
- onChange={(value) => setValue(value ?? "")}
- autoFocus
- placeholder="Focused on mount"
- />
- </StorySection>
+ <Combobox<string>
+ value={value}
+ itemToString={(item) => item ?? ""}
+ getItems={() => ["Apple", "Banana", "Orange"]}
+ onItemSelect={setValue}
+ onChange={(value) => setValue(value ?? "")}
+ autoFocus
+ placeholder="Focused on mount"
+ />
);
};
-export const WithErrorColor = () => {
+const WithErrorColorDemo = () => {
const [value, setValue] = useState("");
return (
- <StorySection title="With error color">
- <Combobox<string>
- value={value}
- itemToString={(item) => item ?? ""}
- getItems={() => ["Apple", "Banana", "Orange"]}
- onItemSelect={setValue}
- onChange={(value) => setValue(value ?? "")}
- color="error"
- placeholder="Error state"
- />
- </StorySection>
+ <Combobox<string>
+ value={value}
+ itemToString={(item) => item ?? ""}
+ getItems={() => ["Apple", "Banana", "Orange"]}
+ onItemSelect={setValue}
+ onChange={(value) => setValue(value ?? "")}
+ color="error"
+ placeholder="Error state"
+ />
);
};
@@ -167,24 +157,45 @@ const fruitDescriptions: Record<string, string> = {
Orange: "A citrus fruit",
} as const;
-export const WithDescription = () => {
+const WithDescriptionDemo = () => {
const [value, setValue] = useState("");
return (
- <StorySection title="With description">
- <Combobox<string>
- value={value}
- itemToString={(item) => item ?? ""}
- getItems={() => ["Apple", "Banana", "Orange"]}
- getDescription={(item) => (item ? fruitDescriptions[item] : undefined)}
- onItemSelect={setValue}
- onChange={(value) => setValue(value ?? "")}
- placeholder="Pick a fruit…"
- />
- </StorySection>
+ <Combobox<string>
+ value={value}
+ itemToString={(item) => item ?? ""}
+ getItems={() => ["Apple", "Banana", "Orange"]}
+ getDescription={(item) => (item ? fruitDescriptions[item] : undefined)}
+ onItemSelect={setValue}
+ onChange={(value) => setValue(value ?? "")}
+ placeholder="Pick a fruit…"
+ />
);
};
+export const ComboboxStory = () => (
+ <>
+ <StorySection title="Basic">
+ <BasicDemo />
+ </StorySection>
+ <StorySection title="Complex">
+ <ComplexDemo />
+ </StorySection>
+ <StorySection title="With placeholder">
+ <WithPlaceholderDemo />
+ </StorySection>
+ <StorySection title="With auto focus">
+ <WithAutoFocusDemo />
+ </StorySection>
+ <StorySection title="With error color">
+ <WithErrorColorDemo />
+ </StorySection>
+ <StorySection title="With description">
+ <WithDescriptionDemo />
+ </StorySection>
+ </>
+);
+
export default {
title: "Combobox",
- component: Complex,
+ component: ComboboxStory,
};
diff --git a/packages/design-system/src/components/floating-panel.stories.tsx b/packages/design-system/src/components/floating-panel.stories.tsx
index 7d7017bca8..ad2bb66021 100644
--- a/packages/design-system/src/components/floating-panel.stories.tsx
+++ b/packages/design-system/src/components/floating-panel.stories.tsx
@@ -4,7 +4,6 @@ import { Box } from "./box";
import { StorySection } from "./storybook";
import { Button } from "./button";
import { Text } from "./text";
-import { Flex } from "./flex";
import { CopyIcon } from "@webstudio-is/icons";
export default {
@@ -30,63 +29,81 @@ const Container = ({ children }: { children: ReactNode }) => {
);
};
-export const FloatingPanel = () => (
- <StorySection title="Floating panel">
- <Flex direction="column" gap="9">
- <Container>
- <FloatingPanelComponent
- open
- title="Left (default)"
- content={<Text>Content</Text>}
- >
- <Button>Open on the left</Button>
- </FloatingPanelComponent>
- </Container>
- <Container>
- <FloatingPanelComponent
- placement="right-start"
- open
- title="Right"
- content={<Text>Content</Text>}
- >
- <Button>Open on the right</Button>
- </FloatingPanelComponent>
- </Container>
- <Container>
- <FloatingPanelComponent
- placement="bottom-within"
- open
- title="Bottom"
- content={<Text>Content</Text>}
- >
- <Button>Open below</Button>
- </FloatingPanelComponent>
- </Container>
- <Container>
- <FloatingPanelComponent
- placement="center"
- open
- maximizable
- resize="both"
- title="Center"
- content={<Text>Content</Text>}
- >
- <Button>Open screen-centered</Button>
- </FloatingPanelComponent>
- </Container>
- <Container>
- <FloatingPanelComponent
- offset={{ mainAxis: 20, alignmentAxis: -100 }}
- width={200}
- height={300}
- open
- title="Custom Offset & Size"
- content={<Text>Content</Text>}
- >
- <Button>Open with custom offsets</Button>
- </FloatingPanelComponent>
- </Container>
- </Flex>
+export const LeftDefault = () => (
+ <StorySection title="Left (default)">
+ <Container>
+ <FloatingPanelComponent
+ open
+ title="Left (default)"
+ content={<Text>Content</Text>}
+ >
+ <Button>Open on the left</Button>
+ </FloatingPanelComponent>
+ </Container>
+ </StorySection>
+);
+
+export const RightStart = () => (
+ <StorySection title="Right start">
+ <Container>
+ <FloatingPanelComponent
+ placement="right-start"
+ open
+ title="Right"
+ content={<Text>Content</Text>}
+ >
+ <Button>Open on the right</Button>
+ </FloatingPanelComponent>
+ </Container>
+ </StorySection>
+);
+
+export const BottomWithin = () => (
+ <StorySection title="Bottom within">
+ <Container>
+ <FloatingPanelComponent
+ placement="bottom-within"
+ open
+ title="Bottom"
+ content={<Text>Content</Text>}
+ >
+ <Button>Open below</Button>
+ </FloatingPanelComponent>
+ </Container>
+ </StorySection>
+);
+
+export const Center = () => (
+ <StorySection title="Center">
+ <Container>
+ <FloatingPanelComponent
+ placement="center"
+ open
+ maximizable
+ resize="both"
+ title="Center"
+ content={<Text>Content</Text>}
+ >
+ <Button>Open screen-centered</Button>
+ </FloatingPanelComponent>
+ </Container>
+ </StorySection>
+);
+
+export const CustomOffsetAndSize = () => (
+ <StorySection title="Custom offset and size">
+ <Container>
+ <FloatingPanelComponent
+ offset={{ mainAxis: 20, alignmentAxis: -100 }}
+ width={200}
+ height={300}
+ open
+ title="Custom Offset & Size"
+ content={<Text>Content</Text>}
+ >
+ <Button>Open with custom offsets</Button>
+ </FloatingPanelComponent>
+ </Container>
</StorySection>
);
diff --git a/packages/design-system/src/components/popover.stories.tsx b/packages/design-system/src/components/popover.stories.tsx
index e1cc10e9a1..a7e1613011 100644
--- a/packages/design-system/src/components/popover.stories.tsx
+++ b/packages/design-system/src/components/popover.stories.tsx
@@ -80,9 +80,9 @@ export const WithTitleActions = () => (
</StorySection>
);
-export const SidePlacement = () => (
- <StorySection title="Side placement">
- <Flex gap="9" style={{ padding: 100 }}>
+export const SideRight = () => (
+ <StorySection title="Side right">
+ <Flex style={{ padding: 100 }}>
<Popover defaultOpen>
<PopoverTrigger asChild>
<Button>Right</Button>
@@ -93,6 +93,13 @@ export const SidePlacement = () => (
</Flex>
</PopoverContent>
</Popover>
+ </Flex>
+ </StorySection>
+);
+
+export const SideTop = () => (
+ <StorySection title="Side top">
+ <Flex style={{ padding: 100 }}>
<Popover defaultOpen>
<PopoverTrigger asChild>
<Button>Top</Button>
@@ -103,6 +110,13 @@ export const SidePlacement = () => (
</Flex>
</PopoverContent>
</Popover>
+ </Flex>
+ </StorySection>
+);
+
+export const SideBottomWithOffset = () => (
+ <StorySection title="Side bottom with offset">
+ <Flex style={{ padding: 100 }}>
<Popover defaultOpen>
<PopoverTrigger asChild>
<Button>Bottom</Button>
diff --git a/packages/sdk-components-animation/private-src b/packages/sdk-components-animation/private-src
index 525d2607e3..aceca8f788 160000
--- a/packages/sdk-components-animation/private-src
+++ b/packages/sdk-components-animation/private-src
@@ -1 +1 @@
-Subproject commit 525d2607e3879b7ea95f291b0e3013ba96805177
+Subproject commit aceca8f788bbaa307414bb4374287883eb5cb26c