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.

encapsulate filename with truncation into a component

Oleg Isonendf831f580ce3
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-info.tsx b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-info.tsx
index e25d7e96a5..b7fcf61f86 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-info.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager/asset-info.tsx
@@ -18,24 +18,33 @@ import { useSubmit } from "@remix-run/react";
import prettyBytes from "pretty-bytes";
import { Header } from "../../lib/header";
-const truncatedText = {
- position: "relative",
- maxWidth: "70%",
-
- div: {
- whiteSpace: "nowrap",
- textOverflow: "ellipsis",
- overflow: "hidden",
-
- "&::after": {
- content: "attr(data-extension)",
- position: "absolute",
- left: "100%",
- top: 0,
- whiteSpace: "nowrap",
- },
- },
-};
+const Filename = ({ name }: { name: string }) => (
+ <Box
+ css={{
+ position: "relative",
+ maxWidth: "70%",
+ }}
+ >
+ <Text
+ size="1"
+ data-extension={name.split(".").pop()}
+ css={{
+ whiteSpace: "nowrap",
+ textOverflow: "ellipsis",
+ overflow: "hidden",
+ "&::after": {
+ content: "attr(data-extension)",
+ position: "absolute",
+ left: "100%",
+ top: 0,
+ whiteSpace: "nowrap",
+ },
+ }}
+ >
+ {name}
+ </Text>
+ </Box>
+);
type AssetInfoProps = Asset & {
onClose: () => void;
@@ -68,11 +77,7 @@ export const AssetInfo = ({
<Box css={{ p: "$2 $3" }}>
<Grid columns={2} align="center">
<Box css={{ width: 100 }}>
- <Box css={truncatedText}>
- <Text size="1" data-extension={name.split(".").pop()}>
- {name}
- </Text>
- </Box>
+ <Filename name={name} />
</Box>
<Flex align="center" css={{ gap: "$1" }}>
<CloudIcon />