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.

«first steps

Sara Vieiraebfa87205342
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/thumbnail.tsx b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/thumbnail.tsx
index 6ec9751a9e..df80168c78 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/thumbnail.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/thumbnail.tsx
@@ -1,11 +1,32 @@
import { useEffect, useState } from "react";
-import { Box, Button, Flex, Tooltip } from "@webstudio-is/design-system";
+import {
+ Box,
+ Button,
+ Flex,
+ IconButton,
+ Text,
+ Tooltip,
+ Separator,
+ Grid,
+} from "@webstudio-is/design-system";
import placeholderImage from "~/shared/images/image-placeholder.svg";
import brokenImage from "~/shared/images/broken-image-placeholder.svg";
import { useSubmit } from "@remix-run/react";
import { Asset } from "~/designer/features/sidebar-left/types";
-import { Cross2Icon } from "@radix-ui/react-icons";
import { UploadingAnimation } from "./uploading-animation";
+import {
+ CloudIcon,
+ AspectRatioIcon,
+ Cross1Icon,
+ GearIcon,
+ SizeIcon,
+ TrashIcon,
+} from "@webstudio-is/icons";
+import {
+ getAspectRatio,
+ getStartAndEndOfString,
+ getHumanReadableFileSize,
+} from "./utils";
const useImageWithFallback = ({ path }: { path: string }) => {
const [src, setSrc] = useState(placeholderImage);
@@ -24,6 +45,9 @@ export const AssetManagerThumbnail = ({
path,
alt,
status,
+ size,
+ width,
+ height,
name,
id,
}: Asset) => {
@@ -76,18 +100,65 @@ export const AssetManagerThumbnail = ({
multiline
onEscapeKeyDown={closeTooltip}
onPointerDownOutside={closeTooltip}
+ css={{ width: 240, maxWidth: 240 }}
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>
+ <>
+ <Flex
+ css={{ height: 40, paddingLeft: "$3" }}
+ align="center"
+ justify="between"
+ >
+ <Text size="1" css={{ fontWeight: "bold" }}>
+ Asset Details
+ </Text>
+
+ <IconButton
+ onClick={() => setTolltipOpen(false)}
+ size="1"
+ css={{ marginRight: "$2" }}
+ aria-label="Close"
+ >
+ <Cross1Icon />
+ </IconButton>
+ </Flex>
+ <Separator />
+ <Box css={{ p: "$2 $3" }}>
+ <Grid columns={2}>
+ <Text size="1">{getStartAndEndOfString(name)}</Text>
+ <Flex align="center" css={{ gap: "$1" }}>
+ <CloudIcon />
+ <Text size="1">{getHumanReadableFileSize(size)}</Text>
+ </Flex>
+ </Grid>
+ </Box>
+ <Box css={{ p: "$2 $3" }}>
+ <Grid columns={2}>
+ <Flex align="center" css={{ gap: "$1" }}>
+ <SizeIcon />
+ <Text size="1">
+ {width} x {height}
+ </Text>
+ </Flex>{" "}
+ <Flex align="center" css={{ gap: "$1" }}>
+ <AspectRatioIcon />
+ <Text size="1">{getAspectRatio(width, height)}</Text>
+ </Flex>
+ </Grid>
+ </Box>
+ <Box css={{ p: "$2 $3" }}>
+ <Button variant="red" size="2" onClick={deleteAsset}>
+ <Flex align="center" css={{ gap: "$1" }}>
+ <TrashIcon />
+ Delete
+ </Flex>
+ </Button>
+ </Box>
+ </>
}
>
<Button
variant="raw"
- title="Delete asset"
+ title="Options"
onClick={() => setTolltipOpen(true)}
css={{
position: "absolute",
@@ -97,7 +168,7 @@ export const AssetManagerThumbnail = ({
color: "$highContrast",
}}
>
- <Cross2Icon />
+ <GearIcon />
</Button>
</Tooltip>
)}
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/utils.ts b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/utils.ts
new file mode 100644
index 0000000000..b29a81bcae
--- /dev/null
+++ b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/utils.ts
@@ -0,0 +1,22 @@
+export const getHumanReadableFileSize = (size: number) => {
+ const i = Math.floor(Math.log(size) / Math.log(1024));
+ const types = ["B", "kB", "MB", "GB", "TB"];
+ return `${(size / Math.pow(1024, i)).toFixed(2)} ${types[i]}`;
+};
+
+export const getStartAndEndOfString = (str: string) => {
+ if (str.length > 20) {
+ return str.substr(0, 10) + "..." + str.split(".").pop();
+ }
+ return str;
+};
+
+export const gcd = (a: number, b: number): number => {
+ return b ? gcd(b, a % b) : a;
+};
+
+export const getAspectRatio = (width: number, height: number) => {
+ const divisor = gcd(width, height);
+
+ return `${width / divisor}:${height / divisor}`;
+};
diff --git a/packages/design-system/src/components/button.tsx b/packages/design-system/src/components/button.tsx
index fd384bbd87..19c85ef6d3 100644
--- a/packages/design-system/src/components/button.tsx
+++ b/packages/design-system/src/components/button.tsx
@@ -5,6 +5,7 @@ export const Button = styled("button", {
all: "unset",
alignItems: "center",
boxSizing: "border-box",
+ border: "none",
userSelect: "none",
"&::before": {
boxSizing: "border-box",
@@ -129,12 +130,13 @@ export const Button = styled("button", {
color: "$red11",
"@hover": {
"&:hover": {
- boxShadow: "inset 0 0 0 1px $colors$slate8",
+ background: "$red11",
+ color: "$loContrast",
},
},
"&:active": {
- backgroundColor: "$red3",
- boxShadow: "inset 0 0 0 1px $colors$red8",
+ backgroundColor: "$red11",
+ color: "$loContrast",
},
"&:focus": {
boxShadow: "inset 0 0 0 1px $colors$red8, 0 0 0 1px $colors$red8",
diff --git a/packages/icons/src/aspect-ratio.tsx b/packages/icons/src/aspect-ratio.tsx
new file mode 100644
index 0000000000..c47e3333f7
--- /dev/null
+++ b/packages/icons/src/aspect-ratio.tsx
@@ -0,0 +1,31 @@
+import * as React from "react";
+import { IconProps } from "./types";
+
+export const AspectRatioIcon = React.forwardRef<SVGSVGElement, IconProps>(
+ ({ color = "currentColor", ...props }, forwardedRef) => {
+ return (
+ <svg
+ width={15}
+ height={15}
+ viewBox="0 0 15 15"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ ref={forwardedRef}
+ >
+ <path
+ d="M10.85 10.503a.625.625 0 100-1.25v1.25zM4.975 3.378a.625.625 0 10-1.25 0h1.25zm-.072 6.394l.275-.561-.275.561zm-.443-.426l.552-.292-.552.292zm6.39-.093H5.972v1.25h4.878v-1.25zM4.975 8.32V3.38h-1.25v4.94h1.25zm.997.934c-.294 0-.478 0-.617-.01a.524.524 0 01-.177-.032l-.55 1.123c.21.102.423.138.63.154.198.016.44.015.714.015v-1.25zM3.725 8.32c0 .262 0 .498.016.693.017.203.056.418.167.627l1.104-.585c0-.001-.004-.008-.009-.028a.803.803 0 01-.017-.12 7.858 7.858 0 01-.011-.587h-1.25zm1.453.892a.37.37 0 01-.166-.157l-1.104.585c.16.303.414.545.72.695l.55-1.123z"
+ fill={color}
+ />
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M4.349 6.067c.345 0 .625-.28.625-.625V3.466l1.428 1.429a.625.625 0 10.884-.884L4.791 1.515a.625.625 0 00-.884 0L1.412 4.011a.625.625 0 10.884.884l1.428-1.429v1.976c0 .345.28.625.625.625zM7.769 9.878c0 .345.28.625.625.625h1.975l-1.428 1.429a.625.625 0 10.884.883l2.495-2.495a.625.625 0 000-.883L9.825 6.94a.625.625 0 10-.884.884l1.428 1.428H8.394a.625.625 0 00-.625.625z"
+ fill={color}
+ />
+ </svg>
+ );
+ }
+);
+
+AspectRatioIcon.displayName = "AspectRatioIcon";
diff --git a/packages/icons/src/cloud.tsx b/packages/icons/src/cloud.tsx
new file mode 100644
index 0000000000..cb4cd9a9a4
--- /dev/null
+++ b/packages/icons/src/cloud.tsx
@@ -0,0 +1,28 @@
+import * as React from "react";
+import { IconProps } from "./types";
+
+export const CloudIcon = React.forwardRef<SVGSVGElement, IconProps>(
+ ({ color = "currentColor", ...props }, forwardedRef) => {
+ return (
+ <svg
+ width={16}
+ height={16}
+ viewBox="0 0 16 16"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ ref={forwardedRef}
+ >
+ <path
+ d="M3.433 11.4A2.333 2.333 0 014.57 7.473a2.918 2.918 0 115.705-1.222 2.917 2.917 0 11.058 5.832h-5.25a2.333 2.333 0 01-1.65-.683z"
+ stroke={color}
+ strokeWidth={1.25}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ );
+ }
+);
+
+CloudIcon.displayName = "CloudIcon";
diff --git a/packages/icons/src/index.ts b/packages/icons/src/index.ts
index 1443d38433..eda66051f6 100644
--- a/packages/icons/src/index.ts
+++ b/packages/icons/src/index.ts
@@ -10,3 +10,6 @@ export * from "./devices";
export * from "./tablet";
export * from "./body";
export * from "./types";
+export { AspectRatioIcon } from "./aspect-ratio";
+export * from "./cloud";
+export { TrashIcon } from "./trash";
diff --git a/packages/icons/src/trash.tsx b/packages/icons/src/trash.tsx
new file mode 100644
index 0000000000..fbd189a0d5
--- /dev/null
+++ b/packages/icons/src/trash.tsx
@@ -0,0 +1,35 @@
+import * as React from "react";
+import { IconProps } from "./types";
+
+export const TrashIcon = React.forwardRef<SVGSVGElement, IconProps>(
+ ({ color = "currentColor", ...props }, forwardedRef) => {
+ return (
+ <svg
+ width={16}
+ height={16}
+ viewBox="0 0 16 16"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ ref={forwardedRef}
+ >
+ <path
+ d="M3.556 5.222h8.889m-.556 0l-.482 6.746A1.111 1.111 0 0110.3 13H5.701a1.111 1.111 0 01-1.108-1.032L4.11 5.222h7.778zm-2.222 0V3.556A.556.556 0 009.11 3H6.89a.556.556 0 00-.556.556v1.666h3.334z"
+ stroke={color}
+ strokeWidth={1.25}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ <path
+ d="M6.889 7.405v3.333M9.11 7.405v3.333"
+ stroke={color}
+ strokeWidth={1.1}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ );
+ }
+);
+
+TrashIcon.displayName = "TrashIcon";