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 grid & make sure we close tooltip on esc and click outside

Sara Vieira814202c09ef1
diff --git a/apps/designer/app/designer/features/inspector/inspector.tsx b/apps/designer/app/designer/features/inspector/inspector.tsx
index 02973722b9..8ad637b2b4 100644
--- a/apps/designer/app/designer/features/inspector/inspector.tsx
+++ b/apps/designer/app/designer/features/inspector/inspector.tsx
@@ -28,9 +28,9 @@ export const Inspector = ({ publish }: InspectorProps) => {
if (selectedInstanceData === undefined) {
return (
- <Box css={{ p: "$2" }}>
+ <Box css={{ p: "$2", flexBasis: "100%" }}>
{/* @todo: use this space for something more usefull: a-la figma's no instance selected sate, maybe create an issue with a more specific proposal? */}
- <Card css={{ p: "$3", mt: "$3" }}>
+ <Card css={{ p: "$3", mt: "$3", width: "100%" }}>
<Paragraph>Select an instance on the canvas</Paragraph>
</Card>
</Box>
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx
index f7919c18ca..aed969acd6 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx
@@ -42,7 +42,7 @@ export const TabContent = ({
const { assets, onUploadAsset } = useAssetsState(baseAssets);
return (
<Flex gap="3" direction="column" css={{ padding: "$1" }}>
- <Flex justify="between">
+ <Flex justify="between" align="center">
<Heading>Assets</Heading>
<AddAnAssetForm onSubmit={onUploadAsset} />
</Flex>
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/components/image.tsx b/apps/designer/app/designer/features/sidebar-left/panels/components/image.tsx
index 4df97f776b..ccafb32e4f 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/components/image.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/components/image.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import {
Box,
Button,
@@ -6,7 +6,7 @@ import {
ProgressBar,
Tooltip,
} from "~/shared/design-system";
-import { useInterval } from "react-use";
+import { useClickAway, useInterval, useKey } from "react-use";
import placeholderImage from "~/shared/images/image-placeholder.svg";
import brokenImage from "~/shared/images/broken-image-placeholder.svg";
import { useSubmit } from "@remix-run/react";
@@ -32,6 +32,11 @@ export const AssetManagerImage = ({ path, alt, status, name, id }: Asset) => {
const src = useImageWithFallback({ path });
const [isToolTipOpen, setTolltipOpen] = useState(false);
const [progressBarPercentage, setProgressBarPercentage] = useState(0);
+ const tooltipRef = useRef(null);
+ useClickAway(tooltipRef, () => {
+ setTolltipOpen(false);
+ });
+ useKey("Escape", () => setTolltipOpen(false));
// @todo rewrite this fake indication to show real progress
useInterval(
@@ -77,33 +82,35 @@ export const AssetManagerImage = ({ path, alt, status, name, id }: Asset) => {
}}
></Box>
{!isUploading && (
- <Tooltip
- css={{ maxWidth: "$10" }}
- open={isToolTipOpen}
- multiline
- content={
- <Flex direction="column" gap={1} align="center" justify="center">
- Are you sure you want to delete this asset?
- <Button variant="red" onClick={deleteAsset}>
- Delete
- </Button>
- </Flex>
- }
- >
- <Button
- variant="raw"
- onClick={() => setTolltipOpen(true)}
- css={{
- position: "absolute",
- top: "$1",
- right: "$1",
- cursor: "pointer",
- color: "$highContrast",
- }}
+ <Box ref={tooltipRef}>
+ <Tooltip
+ css={{ maxWidth: "$13" }}
+ open={isToolTipOpen}
+ multiline
+ content={
+ <Flex direction="column" gap={1} align="center" justify="center">
+ Are you sure you want to delete this asset?
+ <Button variant="red" onClick={deleteAsset}>
+ Delete
+ </Button>
+ </Flex>
+ }
>
- <Cross2Icon />
- </Button>
- </Tooltip>
+ <Button
+ variant="raw"
+ onClick={() => setTolltipOpen(true)}
+ css={{
+ position: "absolute",
+ top: "$1",
+ right: "$1",
+ cursor: "pointer",
+ color: "$highContrast",
+ }}
+ >
+ <Cross2Icon />
+ </Button>
+ </Tooltip>
+ </Box>
)}
{isUploading && (
<ProgressBar
diff --git a/apps/designer/app/shared/design-system/stitches.config.ts b/apps/designer/app/shared/design-system/stitches.config.ts
index 9947714ec4..90259bdb0c 100644
--- a/apps/designer/app/shared/design-system/stitches.config.ts
+++ b/apps/designer/app/shared/design-system/stitches.config.ts
@@ -118,6 +118,22 @@ import {
import type * as Stitches from "@stitches/react";
export type { VariantProps } from "@stitches/react";
+const commonSpace = {
+ 1: "4px",
+ 2: "8px",
+ 3: "16px",
+ 4: "24px",
+ 5: "32px",
+ 6: "48px",
+ 7: "56px",
+ 8: "64px",
+ 9: "72px",
+ 10: "80px",
+ 11: "88px",
+ 12: "96px",
+ 13: "104px",
+};
+
export const {
styled,
css,
@@ -210,28 +226,10 @@ export const {
mono: "Söhne Mono, menlo, monospace",
},
space: {
- 1: "5px",
- 2: "10px",
- 3: "15px",
- 4: "20px",
- 5: "25px",
- 6: "35px",
- 7: "45px",
- 8: "65px",
- 9: "80px",
- 10: "105px",
+ ...commonSpace,
},
sizes: {
- 1: "5px",
- 2: "10px",
- 3: "15px",
- 4: "20px",
- 5: "25px",
- 6: "35px",
- 7: "45px",
- 8: "65px",
- 9: "80px",
- 10: "105px",
+ ...commonSpace,
},
// space: {
// 1: '4px',