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.

feat: Plus button hover polygon and menu icons (#4487)

Ivan Starkov974f6137f934
diff --git a/apps/builder/app/builder/features/workspace/canvas-tools/outline/editable-block-instance-outline.tsx b/apps/builder/app/builder/features/workspace/canvas-tools/outline/editable-block-instance-outline.tsx
index 40bcf712e2..10d69e357b 100644
--- a/apps/builder/app/builder/features/workspace/canvas-tools/outline/editable-block-instance-outline.tsx
+++ b/apps/builder/app/builder/features/workspace/canvas-tools/outline/editable-block-instance-outline.tsx
@@ -3,6 +3,7 @@ import {
$editableBlockChildOutline,
$instances,
$isContentMode,
+ $registeredComponentMetas,
type EditableBlockChildOutline,
} from "~/shared/nano-states";
import {
@@ -20,11 +21,13 @@ import {
toast,
Kbd,
Text,
+ iconButtonSize,
} from "@webstudio-is/design-system";
import { EditableBlockChildAddButtonOutline } from "./outline";
import { applyScale } from "./apply-scale";
import { $scale } from "~/builder/shared/nano-states";
-import { BoxIcon, PlusIcon } from "@webstudio-is/icons";
+import { PlusIcon } from "@webstudio-is/icons";
+import { BoxIcon } from "@webstudio-is/icons/svg";
import { useRef, useState } from "react";
import { isFeatureEnabled } from "@webstudio-is/feature-flags";
import type { DroppableTarget, InstanceSelector } from "~/shared/tree-utils";
@@ -42,6 +45,7 @@ import {
updateWebstudioData,
} from "~/shared/instance-utils";
import { shallowEqual } from "shallow-equal";
+import { MetaIcon } from "~/builder/shared/meta-icon";
export const findEditableBlockSelector = (
anchor: InstanceSelector,
@@ -182,6 +186,7 @@ const TemplatesMenu = ({
anchor: InstanceSelector;
}) => {
const instances = useStore($instances);
+ const metas = useStore($registeredComponentMetas);
const optionPointerDownTime = useRef(0);
const isMenuOpenedWithOption = useRef(false);
@@ -197,7 +202,7 @@ const TemplatesMenu = ({
const menuItems = templates?.map(([template, templateSelector]) => ({
id: template.id,
- icon: <BoxIcon />,
+ icon: <MetaIcon icon={metas.get(template.component)?.icon ?? BoxIcon} />,
title: template.label ?? template.component,
value: templateSelector,
}));
@@ -352,8 +357,8 @@ export const EditableBlockChildHoveredInstanceOutline = () => {
<Flex
css={{
width: "min-content",
- height: "min-content",
pointerEvents: isMenuOpen ? "none" : "all",
+ clipPath: `polygon(0% 0%, 100% 0%, 100% 100%, 0% ${iconButtonSize})`,
}}
onMouseEnter={() => {
clearTimeout(timeoutRef.current);
@@ -385,6 +390,7 @@ export const EditableBlockChildHoveredInstanceOutline = () => {
<IconButton
variant={"local"}
css={{
+ mr: theme.spacing[4],
borderStyle: "solid",
borderColor: `oklch(from ${theme.colors.backgroundPrimary} l c h / 0.7)`,
}}
@@ -392,13 +398,6 @@ export const EditableBlockChildHoveredInstanceOutline = () => {
<PlusIcon />
</IconButton>
</TemplatesMenu>
- <Box
- css={{
- width: theme.spacing[4],
- // For easier hover
- height: theme.spacing[12],
- }}
- ></Box>
</Flex>
</EditableBlockChildAddButtonOutline>
);
diff --git a/apps/builder/app/builder/features/workspace/canvas-tools/outline/outline.tsx b/apps/builder/app/builder/features/workspace/canvas-tools/outline/outline.tsx
index b1a96ea3d3..548af4d928 100644
--- a/apps/builder/app/builder/features/workspace/canvas-tools/outline/outline.tsx
+++ b/apps/builder/app/builder/features/workspace/canvas-tools/outline/outline.tsx
@@ -89,15 +89,11 @@ export const EditableBlockChildAddButtonOutline = ({
>
<div
style={{
- height: 0,
width: 0,
display: "grid",
- alignContent: "start",
+ alignContent: "stretch",
justifyContent: "end",
-
- justifySelf: "start",
- alignSelf: "start",
}}
>
{children}
diff --git a/packages/design-system/src/components/icon-button.tsx b/packages/design-system/src/components/icon-button.tsx
index 53786515f3..256dc45aeb 100644
--- a/packages/design-system/src/components/icon-button.tsx
+++ b/packages/design-system/src/components/icon-button.tsx
@@ -20,6 +20,8 @@ const disabledVariantStyles = {
},
};
+export const iconButtonSize = theme.spacing[11];
+
export const IconButton = styled("button", {
// reset styles
boxSizing: "border-box",
@@ -33,8 +35,8 @@ export const IconButton = styled("button", {
alignItems: "center",
// prevent shrinking inside flex box
flexShrink: 0,
- width: theme.spacing[11],
- height: theme.spacing[11],
+ width: iconButtonSize,
+ height: iconButtonSize,
borderRadius: theme.borderRadius[3],
minWidth: 0,
outline: "none",