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 scroll area in style right panels (#1434)

Oleg Isonenffb38113807e
diff --git a/apps/builder/app/builder/features/props-panel/props-panel.tsx b/apps/builder/app/builder/features/props-panel/props-panel.tsx
index 1c7f6047e5..62dd231187 100644
--- a/apps/builder/app/builder/features/props-panel/props-panel.tsx
+++ b/apps/builder/app/builder/features/props-panel/props-panel.tsx
@@ -2,7 +2,6 @@ import store from "immerhin";
import type { Instance, Prop } from "@webstudio-is/project-build";
import {
theme,
- Box,
useCombobox,
Combobox,
ComboboxContent,
@@ -15,6 +14,7 @@ import {
Flex,
Text,
type CSS,
+ ScrollArea,
} from "@webstudio-is/design-system";
import { ChevronDownIcon } from "@webstudio-is/icons";
import type { Publish } from "~/shared/pubsub";
@@ -202,11 +202,10 @@ export const PropsPanel = ({
const hasAddedProps = logic.addedProps.length > 0 || addingProp;
return (
- <Box css={{ paddingTop: theme.spacing[3] }}>
+ <ScrollArea css={{ paddingTop: theme.spacing[3] }}>
<Row>
<InstanceInfo meta={componentMeta} label={instanceLabel} />
</Row>
-
<Row
css={{
paddingTop: theme.spacing[3],
@@ -264,7 +263,7 @@ export const PropsPanel = ({
)}
</CollapsibleSectionWithAddButton>
<Separator />
- </Box>
+ </ScrollArea>
);
};
diff --git a/apps/builder/app/builder/features/settings-panel/settings-panel.tsx b/apps/builder/app/builder/features/settings-panel/settings-panel.tsx
index ba5d69367c..8dc15372df 100644
--- a/apps/builder/app/builder/features/settings-panel/settings-panel.tsx
+++ b/apps/builder/app/builder/features/settings-panel/settings-panel.tsx
@@ -4,6 +4,7 @@ import {
Label,
DeprecatedTextField,
theme,
+ ScrollArea,
} from "@webstudio-is/design-system";
import { getComponentMeta } from "@webstudio-is/react-sdk";
import { selectedInstanceStore } from "~/shared/nano-states";
@@ -17,7 +18,7 @@ export const SettingsPanel = () => {
}
const label = getComponentMeta(selectedInstance.component)?.label;
return (
- <Flex css={{ px: theme.spacing[9] }}>
+ <ScrollArea css={{ px: theme.spacing[9] }}>
<Flex gap="1" direction="column" grow>
<Label>Instance Name</Label>
<DeprecatedTextField
@@ -32,6 +33,6 @@ export const SettingsPanel = () => {
}}
/>
</Flex>
- </Flex>
+ </ScrollArea>
);
};
diff --git a/apps/builder/app/builder/features/style-panel/style-panel.tsx b/apps/builder/app/builder/features/style-panel/style-panel.tsx
index 61eb64878d..e03e0e0efe 100644
--- a/apps/builder/app/builder/features/style-panel/style-panel.tsx
+++ b/apps/builder/app/builder/features/style-panel/style-panel.tsx
@@ -4,6 +4,7 @@ import {
Box,
Card,
DeprecatedParagraph,
+ ScrollArea,
} from "@webstudio-is/design-system";
import type { Instance } from "@webstudio-is/project-build";
import type { Publish } from "~/shared/pubsub";
@@ -95,18 +96,14 @@ export const StylePanel = ({ selectedInstance, publish }: StylePanelProps) => {
>
<StyleSourcesSection />
</Box>
- <Box
- css={{
- overflow: "auto",
- }}
- >
+ <ScrollArea>
<StyleSettings
currentStyle={currentStyle}
setProperty={setProperty}
deleteProperty={deleteProperty}
createBatchUpdate={createBatchUpdate}
/>
- </Box>
+ </ScrollArea>
</>
);
};
diff --git a/apps/builder/app/builder/shared/assets/assets-shell.tsx b/apps/builder/app/builder/shared/assets/assets-shell.tsx
index 7ada56addd..b510b4edf3 100644
--- a/apps/builder/app/builder/shared/assets/assets-shell.tsx
+++ b/apps/builder/app/builder/shared/assets/assets-shell.tsx
@@ -1,6 +1,6 @@
import type { ComponentProps } from "react";
import type { AssetType } from "@webstudio-is/asset-uploader";
-import { Flex, SearchField } from "@webstudio-is/design-system";
+import { Flex, ScrollArea, SearchField } from "@webstudio-is/design-system";
import { AssetUpload } from "./asset-upload";
import { NotFound } from "./not-found";
import { Separator } from "./separator";
@@ -40,15 +40,16 @@ export const AssetsShell = ({
</Flex>
<Separator />
{isEmpty && <NotFound />}
- <Flex
+ <ScrollArea
css={{
+ display: "flex",
flexDirection: "column",
px: theme.spacing[9],
overflow: "auto",
}}
>
{children}
- </Flex>
+ </ScrollArea>
</Flex>
);
};
diff --git a/packages/design-system/src/components/list.tsx b/packages/design-system/src/components/list.tsx
index e1aa811586..7d5465acbf 100644
--- a/packages/design-system/src/components/list.tsx
+++ b/packages/design-system/src/components/list.tsx
@@ -23,6 +23,7 @@ const ListItemBase = styled("li", {
justifyContent: "space-between",
height: theme.spacing[11],
px: theme.spacing[3],
+ mx: theme.spacing[2],
listStyle: "none",
borderRadius: theme.borderRadius[4],
outline: 0,
diff --git a/packages/design-system/src/components/panel-title.tsx b/packages/design-system/src/components/panel-title.tsx
index ed8257a951..3a24d25726 100644
--- a/packages/design-system/src/components/panel-title.tsx
+++ b/packages/design-system/src/components/panel-title.tsx
@@ -17,6 +17,7 @@ type TitleProps = {
const Container = styled("div", textVariants.titles, {
display: "flex",
alignItems: "center",
+ flexShrink: 0,
justifyContent: "space-between",
height: theme.spacing[15],
paddingLeft: theme.spacing[9],
diff --git a/packages/design-system/src/components/scroll-area.tsx b/packages/design-system/src/components/scroll-area.tsx
index 66b00772bb..6f7d50e04f 100644
--- a/packages/design-system/src/components/scroll-area.tsx
+++ b/packages/design-system/src/components/scroll-area.tsx
@@ -1,3 +1,4 @@
+import { forwardRef, type ComponentProps, type Ref } from "react";
import { styled, theme } from "../stitches.config";
import { Root, Viewport, Scrollbar, Thumb } from "@radix-ui/react-scroll-area";
@@ -27,7 +28,7 @@ const ScrollAreaThumb = styled(Thumb, {
transform: "translate(-50%, -50%)",
width: "100%",
height: "100%",
- minWidth: 44,
+ minWidth: 16,
minHeight: 44,
},
});
@@ -38,8 +39,8 @@ const ScrollAreaScrollbar = styled(Scrollbar, {
userSelect: "none",
// disable browser handling of all panning and scaleUp gestures on touch devices
touchAction: "none",
- paddingRight: theme.spacing[2],
- paddingLeft: theme.spacing[2],
+ padding: 2,
+ paddingRight: 3,
'&[data-orientation="vertical"]': {
width: theme.spacing[6],
},
@@ -49,18 +50,23 @@ const ScrollAreaScrollbar = styled(Scrollbar, {
},
});
-type ScrollAreaProps = { children: JSX.Element | Array<JSX.Element> };
+type ScrollAreaProps = ComponentProps<typeof ScrollAreaViewport>;
-export const ScrollArea = ({ children }: ScrollAreaProps) => {
- return (
- <ScrollAreaRoot scrollHideDelay={0}>
- <ScrollAreaViewport>{children}</ScrollAreaViewport>
- <ScrollAreaScrollbar orientation="vertical">
- <ScrollAreaThumb />
- </ScrollAreaScrollbar>
- <ScrollAreaScrollbar orientation="horizontal">
- <ScrollAreaThumb />
- </ScrollAreaScrollbar>
- </ScrollAreaRoot>
- );
-};
+export const ScrollArea = forwardRef(
+ ({ children, css, onScroll }: ScrollAreaProps, ref: Ref<HTMLDivElement>) => {
+ return (
+ <ScrollAreaRoot scrollHideDelay={0} css={css}>
+ <ScrollAreaViewport ref={ref} onScroll={onScroll}>
+ {children}
+ </ScrollAreaViewport>
+ <ScrollAreaScrollbar orientation="vertical">
+ <ScrollAreaThumb />
+ </ScrollAreaScrollbar>
+ <ScrollAreaScrollbar orientation="horizontal">
+ <ScrollAreaThumb />
+ </ScrollAreaScrollbar>
+ </ScrollAreaRoot>
+ );
+ }
+);
+ScrollArea.displayName = "ScrollArea";
diff --git a/packages/design-system/src/components/tree/tree.tsx b/packages/design-system/src/components/tree/tree.tsx
index 18afbdbf4e..49485656ea 100644
--- a/packages/design-system/src/components/tree/tree.tsx
+++ b/packages/design-system/src/components/tree/tree.tsx
@@ -21,6 +21,7 @@ import {
getElementByItemSelector,
getItemSelectorFromElement,
} from "./item-utils";
+import { ScrollArea } from "../scroll-area";
export type TreeProps<Data extends { id: string }> = {
root: Data;
@@ -267,7 +268,7 @@ export const Tree = <Data extends { id: string }>({
});
return (
- <Box
+ <ScrollArea
css={{
width: "100%",
overflowY: "auto",
@@ -315,7 +316,7 @@ export const Tree = <Data extends { id: string }>({
/>,
document.body
)}
- </Box>
+ </ScrollArea>
);
};