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 popover into popover component file, match figma design style, fix tooltip issue
Sultan2488f5b7b337
diff --git a/apps/designer/app/designer/features/style-panel/controls/toggle/toggle-control.tsx b/apps/designer/app/designer/features/style-panel/controls/toggle/toggle-control.tsxindex 23d1555cb9..5d4dacdcaa 100644--- a/apps/designer/app/designer/features/style-panel/controls/toggle/toggle-control.tsx+++ b/apps/designer/app/designer/features/style-panel/controls/toggle/toggle-control.tsx@@ -1,4 +1,4 @@-import { ToggleGroup, Tooltip } from "@webstudio-is/design-system";+import { Flex, ToggleGroup, Tooltip } from "@webstudio-is/design-system";export type ToggleGroupControlProps = {value: string;@@ -20,8 +20,8 @@ export const ToggleGroupControl = ({{items.map(({ child, label, value }, index) => {return (<ToggleGroup.Item key={index} value={value}>- <Tooltip content={label} delayDuration={0}>- {child}+ <Tooltip content={"label"} delayDuration={0}>+ <Flex>{child}</Flex></Tooltip></ToggleGroup.Item>);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 af4ee0658e..aaff896993 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,15 +1,5 @@import { useState } from "react";-import {- Text,- Flex,- Grid,- Popover,- PopoverTrigger,- PopoverContent,- PopoverHeader,- PopoverPortal,- IconButton,-} from "@webstudio-is/design-system";+import { Text, Flex, Grid, ModalPopover } from "@webstudio-is/design-system";import type { RenderCategoryProps } from "../../style-sections";import { ToggleGroupControl } from "../../controls";import { PropertyName } from "../../shared/property-name";@@ -28,38 +18,6 @@ import {EllipsesIcon,} from "@webstudio-is/icons";-// @todo abstract to design-system component-export const MorePopover = ({- title,- content,- children,-}: {- title: string;- content: JSX.Element;- children: JSX.Element;-}) => {- const [isOpen, setIsOpen] = useState(false);-- return (- <Popover open={isOpen} onOpenChange={setIsOpen} modal>- <PopoverTrigger- asChild- onClick={() => {- setIsOpen(true);- }}- >- {children}- </PopoverTrigger>- <PopoverPortal>- <PopoverContent sideOffset={220} side="right" hideArrow>- <PopoverHeader title={title} />- {content}- </PopoverContent>- </PopoverPortal>- </Popover>- );-};-export const FlexChildSection = ({setProperty,createBatchUpdate,@@ -179,17 +137,46 @@ export const FlexChildSection = ({},{child: (- <MorePopover+ <ModalPopovertitle="Sizing"content={- <>- <TextControl {...sectionStyle.flexGrow} />- <TextControl {...sectionStyle.flexShrink} />- </>+ <Grid+ css={{+ gridTemplateColumns: "1.5fr 1fr 1fr",+ gap: "$3",+ padding: "$3",+ }}+ >+ <Grid css={{ gridTemplateColumns: "auto", gap: "$1" }}>+ <PropertyName+ property={+ sectionStyle.flexBasis?.styleConfig.property+ }+ label="Basis"+ />+ <TextControl {...sectionStyle.flexBasis} />+ </Grid>+ <Grid css={{ gridTemplateColumns: "auto", gap: "$1" }}>+ <PropertyName+ property={sectionStyle.flexGrow?.styleConfig.property}+ label="Grow"+ />+ <TextControl {...sectionStyle.flexGrow} />+ </Grid>+ <Grid css={{ gridTemplateColumns: "auto", gap: "$1" }}>+ <PropertyName+ property={+ sectionStyle.flexShrink?.styleConfig.property+ }+ label="Shrink"+ />+ <TextControl {...sectionStyle.flexShrink} />+ </Grid>+ </Grid>}><EllipsesIcon />- </MorePopover>+ </ModalPopover>),label: "More sizing options",value: "",@@ -232,16 +219,22 @@ export const FlexChildSection = ({},{child: (- <MorePopover+ <ModalPopovertitle="Order"content={- <>- <TextControl {...sectionStyle.order} />- </>+ <Grid css={{ padding: "$3" }}>+ <Grid css={{ gridTemplateColumns: "4fr 6fr" }}>+ <PropertyName+ property={sectionStyle.order?.styleConfig.property}+ label="Order"+ />+ <TextControl {...sectionStyle.order} />+ </Grid>+ </Grid>}><EllipsesIcon />- </MorePopover>+ </ModalPopover>),label: "Customize order",value: "",diff --git a/packages/design-system/src/components/popover.tsx b/packages/design-system/src/components/popover.tsxindex 1e7bf750f0..7582c862e8 100644--- a/packages/design-system/src/components/popover.tsx+++ b/packages/design-system/src/components/popover.tsx@@ -1,4 +1,4 @@-import React from "react";+import React, { useState } from "react";import { Cross1Icon } from "@webstudio-is/icons";import * as PopoverPrimitive from "@radix-ui/react-popover";import { Box } from "./box";@@ -74,7 +74,15 @@ export const PopoverHeader = ({ title }: PopoverHeaderProps) => {><Text variant="title">{title}</Text><PopoverClose asChild>- <IconButton size="1" css={{ marginRight: "$2" }} aria-label="Close">+ <IconButton+ size="1"+ css={{+ marginRight: "$2",+ "&:not(:hover):focus": { background: "none" },+ }}+ aria-label="Close"+ autoFocus={false}+ ><Cross1Icon /></IconButton></PopoverClose>@@ -87,3 +95,39 @@ export const PopoverHeader = ({ title }: PopoverHeaderProps) => {export const PopoverTrigger = PopoverPrimitive.Trigger;export const PopoverClose = PopoverPrimitive.Close;export const PopoverPortal = PopoverPrimitive.Portal;++export const ModalPopover = ({+ title,+ content,+ children,+}: {+ title: string;+ content: JSX.Element;+ children: JSX.Element;+}) => {+ const [isOpen, setIsOpen] = useState(false);++ return (+ <Popover open={isOpen} onOpenChange={setIsOpen} modal>+ <PopoverTrigger+ asChild+ onClick={() => {+ setIsOpen(true);+ }}+ >+ {children}+ </PopoverTrigger>+ <PopoverPortal>+ <PopoverContent+ sideOffset={220}+ side="right"+ hideArrow+ css={{ backgroundColor: "$loContrast" }}+ >+ <PopoverHeader title={title} />+ {content}+ </PopoverContent>+ </PopoverPortal>+ </Popover>+ );+};