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.

fix: Make all small icon buttons clickable area bigger than they visually are (#3178)

Oleg Isonenab712652c5f2
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/pages.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/pages.tsx
index 6068e42854..7dcfeb6817 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/pages.tsx
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/pages.tsx
@@ -1,17 +1,15 @@
import { useCallback, useEffect, useMemo, useRef } from "react";
import { useStore } from "@nanostores/react";
import {
- DeprecatedIconButton,
TreeItemLabel,
TreeItemBody,
TreeNode,
type TreeItemRenderProps,
type ItemSelector,
- styled,
Tooltip,
Box,
Button,
- theme,
+ SmallIconButton,
} from "@webstudio-is/design-system";
import {
ChevronRightIcon,
@@ -47,19 +45,6 @@ import { ROOT_FOLDER_ID, type Folder } from "@webstudio-is/sdk";
import { atom } from "nanostores";
import { isPathnamePattern } from "~/builder/shared/url-pattern";
-const MenuButton = styled(DeprecatedIconButton, {
- color: theme.colors.hint,
- "&:hover, &:focus-visible": { color: theme.colors.hiContrast },
- variants: {
- isParentSelected: {
- true: {
- color: theme.colors.loContrast,
- "&:hover, &:focus-visible": { color: theme.colors.slate7 },
- },
- },
- },
-});
-
const ItemSuffix = ({
isParentSelected,
itemId,
@@ -101,14 +86,14 @@ const ItemSuffix = ({
return (
<Tooltip content={menuLabel} disableHoverableContent>
- <MenuButton
+ <SmallIconButton
aria-label={menuLabel}
- isParentSelected={isParentSelected}
+ state={isParentSelected ? "open" : undefined}
onClick={() => onEdit(isEditing ? undefined : itemId)}
ref={buttonRef}
- >
- {isEditing ? <ChevronRightIcon /> : <EllipsesIcon />}
- </MenuButton>
+ icon={isEditing ? <ChevronRightIcon /> : <EllipsesIcon />}
+ variant={isParentSelected ? "contrast" : "normal"}
+ />
</Tooltip>
);
};
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
index 633468b045..39a697fa93 100644
--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
@@ -610,6 +610,7 @@ export const CssValueInput = ({
{...getToggleButtonProps()}
data-state={isOpen ? "open" : "closed"}
tabIndex={-1}
+ size={size}
/>
);
diff --git a/packages/design-system/src/components/nested-input-button.tsx b/packages/design-system/src/components/nested-input-button.tsx
index b919adde6f..ff0344a0c2 100644
--- a/packages/design-system/src/components/nested-input-button.tsx
+++ b/packages/design-system/src/components/nested-input-button.tsx
@@ -57,7 +57,7 @@ const style = css({
},
},
},
- defaultVariants: { size: 1 },
+ defaultVariants: { size: 2 },
});
export const NestedInputButton = forwardRef(
diff --git a/packages/design-system/src/components/primitives/small-button.tsx b/packages/design-system/src/components/primitives/small-button.tsx
index 5803845dfc..eecb5c8868 100644
--- a/packages/design-system/src/components/primitives/small-button.tsx
+++ b/packages/design-system/src/components/primitives/small-button.tsx
@@ -59,6 +59,13 @@ const style = css({
all: "unset",
width: theme.spacing[9],
height: theme.spacing[9],
+ position: "relative",
+ // We want to bleed outside of the 16px icon size because its too small
+ "&::after": {
+ content: '""',
+ position: "absolute",
+ inset: `-${theme.spacing[4]}`,
+ },
"&:disabled, &[data-disabled]": {
color: theme.colors.foregroundDisabled,
},
diff --git a/packages/design-system/src/components/small-icon-button.tsx b/packages/design-system/src/components/small-icon-button.tsx
index 7939ac5ffb..ef6a3c84b0 100644
--- a/packages/design-system/src/components/small-icon-button.tsx
+++ b/packages/design-system/src/components/small-icon-button.tsx
@@ -9,7 +9,6 @@ import {
type ComponentProps,
type ReactNode,
} from "react";
-import type { CSS } from "../stitches.config";
import { SmallButton, smallButtonVariants } from "./primitives/small-button";
@@ -24,13 +23,11 @@ export const smallIconButtonStates = ["open"] as const;
type Props = {
icon: ReactNode;
- variant?: (typeof smallIconButtonVariants)[number];
state?: (typeof smallIconButtonStates)[number];
focused?: boolean;
- css?: CSS;
// might be set when <SmallIconButton> is asChild
"data-state"?: (typeof smallIconButtonStates)[number];
-} & Omit<ComponentProps<"button">, "children">;
+} & Omit<ComponentProps<typeof SmallButton>, "children">;
export const SmallIconButton = forwardRef(
(
diff --git a/packages/design-system/src/components/tree/tree-node.tsx b/packages/design-system/src/components/tree/tree-node.tsx
index 94f2df8913..cec45b1f43 100644
--- a/packages/design-system/src/components/tree/tree-node.tsx
+++ b/packages/design-system/src/components/tree/tree-node.tsx
@@ -52,7 +52,7 @@ const getItemButtonCssVars = ({
};
}
return {
- [itemButtonVars.paddingRight]: `${ITEM_PADDING_RIGHT}px`,
+ [itemButtonVars.paddingRight]: ITEM_PADDING_RIGHT,
};
};
const ItemButton = styled("button", {
@@ -145,7 +145,7 @@ const getSuffixContainerCssVars = ({
const SuffixContainer = styled(Flex, {
position: "absolute",
alignItems: "center",
- right: `${ITEM_PADDING_RIGHT}px`,
+ right: ITEM_PADDING_RIGHT,
top: 0,
bottom: 0,
defaultVariants: { align: "center" },