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.

Update permission level tooltips to reflect recent changes (#2243)

Ivan Starkov5c3af9daec27
diff --git a/apps/builder/app/builder/features/topbar/share.tsx b/apps/builder/app/builder/features/topbar/share.tsx
index a7aa57d45f..49aef46e87 100644
--- a/apps/builder/app/builder/features/topbar/share.tsx
+++ b/apps/builder/app/builder/features/topbar/share.tsx
@@ -42,7 +42,6 @@ export const ShareButton = ({ projectId }: { projectId: Project["id"] }) => {
sideOffset={parseFloat(rawTheme.spacing[8])}
css={{
marginRight: theme.spacing[3],
- zIndex: theme.zIndices[1],
}}
>
<ShareProjectContainer projectId={projectId} />
diff --git a/apps/builder/app/shared/share-project/share-project.tsx b/apps/builder/app/shared/share-project/share-project.tsx
index 9851e02d20..ea9e7a4f20 100644
--- a/apps/builder/app/shared/share-project/share-project.tsx
+++ b/apps/builder/app/shared/share-project/share-project.tsx
@@ -10,21 +10,23 @@ import {
rawTheme,
Separator,
Switch,
- DeprecatedTextField,
theme,
Tooltip,
useId,
Collapsible,
keyframes,
+ Text,
+ InputField,
+ PopoverPortal,
} from "@webstudio-is/design-system";
-import { CopyIcon, InfoIcon, MenuIcon, PlusIcon } from "@webstudio-is/icons";
+import { CopyIcon, MenuIcon, PlusIcon, HelpIcon } from "@webstudio-is/icons";
import { Fragment, useState, type ComponentProps } from "react";
import { isFeatureEnabled } from "@webstudio-is/feature-flags";
const Item = (props: ComponentProps<typeof Flex>) => (
<Flex
direction="column"
- css={{ padding: theme.spacing[7] }}
+ css={{ px: theme.spacing[7], py: theme.spacing[5] }}
gap="1"
{...props}
/>
@@ -44,12 +46,19 @@ const Permission = ({
}: PermissionProps) => {
const id = useId();
+ const tooltipContent = (
+ <Flex direction="column" gap="2" css={{ maxWidth: theme.spacing[28] }}>
+ <Text variant="titles">{title}</Text>
+ <Text>{info}</Text>
+ </Flex>
+ );
+
return (
<Flex align="center" gap="1">
<Switch checked={checked} id={id} onCheckedChange={onCheckedChange} />
<Label htmlFor={id}>{title}</Label>
- <Tooltip content={info} variant="wrapped">
- <InfoIcon color={rawTheme.colors.foregroundSubtle} tabIndex={0} />
+ <Tooltip content={tooltipContent} variant="wrapped">
+ <HelpIcon color={rawTheme.colors.foregroundSubtle} tabIndex={0} />
</Tooltip>
</Flex>
);
@@ -86,32 +95,41 @@ const Menu = ({
aria-label="Menu Button for options"
></Button>
</PopoverTrigger>
- <PopoverContent css={{ zIndex: theme.zIndices[1] }}>
- <Item>
- <Label>Name</Label>
- <DeprecatedTextField
- autoFocus
- value={name}
- onChange={(event) => {
- onChangeName(event.target.value);
- }}
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- setIsOpen(false);
- }
- }}
- />
- </Item>
- <Separator />
- <Item>
- <Label>Permissions</Label>
- <Permission
- checked={relation === "viewers"}
- onCheckedChange={handleCheckedChange("viewers")}
- title="View"
- info="Recipients can only view the site"
- />
- {/*
+ <PopoverPortal>
+ <PopoverContent
+ css={{
+ padding: 0,
+ width: theme.spacing[24],
+ }}
+ sideOffset={0}
+ >
+ <Item>
+ <Label>Name</Label>
+ <InputField
+ value={name}
+ onChange={(event) => {
+ onChangeName(event.target.value);
+ }}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") {
+ setIsOpen(false);
+ }
+ }}
+ placeholder="Breakpoint name"
+ name="Name"
+ autoFocus
+ />
+ </Item>
+ <Separator />
+ <Item>
+ <Label>Permissions</Label>
+ <Permission
+ checked={relation === "viewers"}
+ onCheckedChange={handleCheckedChange("viewers")}
+ title="View"
+ info="Recipients can only view the site"
+ />
+ {/*
Hide temporarily until we have a way to allow edit content but not edit tree, etc.
<Permission
@@ -121,35 +139,36 @@ const Menu = ({
info="Recipients can view the site and edit content like text and images, but they will not be able to change the styles or structure of your site."
/>
*/}
- <Permission
- onCheckedChange={handleCheckedChange("builders")}
- checked={relation === "builders"}
- title="Build"
- info="Recipients can make any changes but can not publish the site."
- />
-
- {isFeatureEnabled("adminRole") && (
<Permission
- onCheckedChange={handleCheckedChange("administrators")}
- checked={relation === "administrators"}
- title="Admin"
- info="Recipients can make any changes and can also publish the site."
+ onCheckedChange={handleCheckedChange("builders")}
+ checked={relation === "builders"}
+ title="Build"
+ info="Recipients can make any changes but can not publish the site."
/>
- )}
- </Item>
- <Separator />
- <Item>
- {/* @todo need a menu item that looks like one from dropdown but without DropdownMenu */}
- <Button
- color="destructive"
- onClick={() => {
- onDelete();
- }}
- >
- Delete Link
- </Button>
- </Item>
- </PopoverContent>
+
+ {isFeatureEnabled("adminRole") && (
+ <Permission
+ onCheckedChange={handleCheckedChange("administrators")}
+ checked={relation === "administrators"}
+ title="Admin"
+ info="Recipients can make any changes and can also publish the site."
+ />
+ )}
+ </Item>
+ <Separator />
+ <Item>
+ {/* @todo need a menu item that looks like one from dropdown but without DropdownMenu */}
+ <Button
+ color="destructive"
+ onClick={() => {
+ onDelete();
+ }}
+ >
+ Delete Link
+ </Button>
+ </Item>
+ </PopoverContent>
+ </PopoverPortal>
</Popover>
);
};
diff --git a/packages/design-system/src/components/popover.tsx b/packages/design-system/src/components/popover.tsx
index 790159f6c7..b98fa567df 100644
--- a/packages/design-system/src/components/popover.tsx
+++ b/packages/design-system/src/components/popover.tsx
@@ -43,6 +43,7 @@ export const PopoverContent = forwardRef(
className,
css,
hideArrow,
+ sideOffset,
...props
}: ComponentProps<typeof Primitive.Content> & {
hideArrow?: boolean;
@@ -52,7 +53,7 @@ export const PopoverContent = forwardRef(
) => (
<Primitive.Portal>
<Primitive.Content
- sideOffset={4}
+ sideOffset={sideOffset ?? 4}
collisionPadding={4}
className={contentStyle({ className, css })}
{...props}