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
refactor to use new tokens, use value-picker-popover instead
Sultanc7b921427fd5
diff --git a/apps/designer/app/designer/features/style-panel/sections/flex-child/flex-child.tsx b/apps/designer/app/designer/features/style-panel/sections/flex-child/flex-child.tsxindex 28fe43a641..b950e30bc7 100644--- a/apps/designer/app/designer/features/style-panel/sections/flex-child/flex-child.tsx+++ b/apps/designer/app/designer/features/style-panel/sections/flex-child/flex-child.tsx@@ -1,4 +1,4 @@-import { Flex, Grid, FloatingPopover } from "@webstudio-is/design-system";+import { Flex, Grid } from "@webstudio-is/design-system";import type { RenderCategoryProps } from "../../style-sections";import { ToggleGroupControl } from "../../controls";import { PropertyName } from "../../shared/property-name";@@ -16,6 +16,7 @@ import {OrderLastIcon,EllipsesIcon,} from "@webstudio-is/icons";+import { ValuePickerPopover } from "../../shared/value-picker-popover";export const FlexChildSection = ({setProperty,@@ -47,7 +48,7 @@ export const FlexChildSection = ({};return (- <Flex css={{ flexDirection: "column", gap: "$2" }}>+ <Flex css={{ flexDirection: "column", gap: "$spacing$5" }}><Grid css={{ gridTemplateColumns: "4fr auto" }}><PropertyNameproperty={sectionStyle.alignSelf?.styleConfig.property}@@ -145,17 +146,19 @@ export const FlexChildSection = ({},{child: (- <FloatingPopover+ <ValuePickerPopovertitle="Sizing"content={<Gridcss={{gridTemplateColumns: "1.5fr 1fr 1fr",- gap: "$3",- padding: "$3",+ gap: "$spacing$9",+ padding: "$spacing$9",}}>- <Grid css={{ gridTemplateColumns: "auto", gap: "$1" }}>+ <Grid+ css={{ gridTemplateColumns: "auto", gap: "$spacing$3" }}+ ><PropertyNameproperty={sectionStyle.flexBasis?.styleConfig.property@@ -164,14 +167,18 @@ export const FlexChildSection = ({/><TextControl {...sectionStyle.flexBasis} /></Grid>- <Grid css={{ gridTemplateColumns: "auto", gap: "$1" }}>+ <Grid+ css={{ gridTemplateColumns: "auto", gap: "$spacing$3" }}+ ><PropertyNameproperty={sectionStyle.flexGrow?.styleConfig.property}label="Grow"/><TextControl {...sectionStyle.flexGrow} /></Grid>- <Grid css={{ gridTemplateColumns: "auto", gap: "$1" }}>+ <Grid+ css={{ gridTemplateColumns: "auto", gap: "$spacing$3" }}+ ><PropertyNameproperty={sectionStyle.flexShrink?.styleConfig.property@@ -183,8 +190,10 @@ export const FlexChildSection = ({</Grid>}>- <EllipsesIcon />- </FloatingPopover>+ <Flex>+ <EllipsesIcon />+ </Flex>+ </ValuePickerPopover>),label: "More sizing options",value: "",@@ -228,10 +237,10 @@ export const FlexChildSection = ({},{child: (- <FloatingPopover+ <ValuePickerPopovertitle="Order"content={- <Grid css={{ padding: "$3" }}>+ <Grid css={{ padding: "$spacing$9" }}><Grid css={{ gridTemplateColumns: "4fr 6fr" }}><PropertyNameproperty={sectionStyle.order?.styleConfig.property}@@ -242,8 +251,10 @@ export const FlexChildSection = ({</Grid>}>- <EllipsesIcon />- </FloatingPopover>+ <Flex>+ <EllipsesIcon />+ </Flex>+ </ValuePickerPopover>),label: "Customize order",value: "",diff --git a/apps/designer/app/designer/features/style-panel/shared/value-picker-popover.tsx b/apps/designer/app/designer/features/style-panel/shared/value-picker-popover.tsxindex 0195cfadd7..f2cad9a0d2 100644--- a/apps/designer/app/designer/features/style-panel/shared/value-picker-popover.tsx+++ b/apps/designer/app/designer/features/style-panel/shared/value-picker-popover.tsx@@ -4,6 +4,7 @@ import {PopoverContent,PopoverHeader,PopoverPortal,+ Flex,} from "@webstudio-is/design-system";import { PANEL_WIDTH } from "~/designer/shared/constants";import { MutableRefObject, useRef, useState } from "react";diff --git a/packages/design-system/src/components/popover.tsx b/packages/design-system/src/components/popover.tsxindex 7340fecee6..980b54d517 100644--- a/packages/design-system/src/components/popover.tsx+++ b/packages/design-system/src/components/popover.tsx@@ -78,7 +78,7 @@ export const PopoverHeader = ({ title }: PopoverHeaderProps) => {<IconButtonsize="1"css={{- marginRight: "$2",+ marginRight: "$spacing$5","&:not(:hover):focus": { background: "none" },}}aria-label="Close"@@ -96,50 +96,3 @@ export const PopoverHeader = ({ title }: PopoverHeaderProps) => {export const PopoverTrigger = PopoverPrimitive.Trigger;export const PopoverClose = PopoverPrimitive.Close;export const PopoverPortal = PopoverPrimitive.Portal;--const useSideOffset = (- isOpen: boolean-): [MutableRefObject<HTMLButtonElement | null>, number] => {- const ref = useRef<HTMLButtonElement | null>(null);- const sideOffset =- isOpen && ref.current !== null ? 240 - ref.current.offsetWidth : 0;- return [ref, sideOffset];-};--export const FloatingPopover = ({- title,- content,- children,-}: {- title: string;- content: JSX.Element;- children: JSX.Element;-}) => {- const [isOpen, setIsOpen] = useState(false);- const [ref, sideOffset] = useSideOffset(isOpen);-- return (- <Popover open={isOpen} onOpenChange={setIsOpen} modal>- <PopoverTrigger- ref={ref}- asChild- onClick={() => {- setIsOpen(true);- }}- >- <Flex>{children}</Flex>- </PopoverTrigger>- <PopoverPortal>- <PopoverContent- sideOffset={sideOffset}- side="right"- hideArrow- css={{ backgroundColor: "$loContrast" }}- >- <PopoverHeader title={title} />- {content}- </PopoverContent>- </PopoverPortal>- </Popover>- );-};diff --git a/packages/design-system/src/components/toggle-group.tsx b/packages/design-system/src/components/toggle-group.tsxindex 1431a0ac1f..421cfc312a 100644--- a/packages/design-system/src/components/toggle-group.tsx+++ b/packages/design-system/src/components/toggle-group.tsx@@ -3,8 +3,8 @@ import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";export const Root = styled(ToggleGroupPrimitive.Root, {display: "inline-flex",- borderRadius: "$1",- boxShadow: `0 0 0 1px $colors$slate7`,+ borderRadius: "$spacing$3",+ boxShadow: `0 0 0 $spacing$1 $colors$slate7`,padding: 2,});@@ -19,9 +19,10 @@ export const Item = styled(ToggleGroupPrimitive.Item, {alignItems: "center",justifyContent: "center",marginLeft: 1,+ borderRadius: 2,+ height: "$spacing$11","&": {- px: "$spacing$5",- py: "$spacing$3",+ px: "$spacing$3",},"&:first-child": {marginLeft: 0,@@ -30,6 +31,7 @@ export const Item = styled(ToggleGroupPrimitive.Item, {},"&:last-child": { borderTopRightRadius: 4, borderBottomRightRadius: 4 },"&:hover": { backgroundColor: "$slateA3" },+ "&:focus": { boxShadow: "0 0 0 $spacing$2 $colors$blue10", zIndex: 1 },"&[data-state=on]": {backgroundColor: "$slate5","&[data-breakpoint=true]": {