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.

Use user-select: none by default (#1642)

Oleg Isonen25a110b778ec
diff --git a/apps/builder/app/builder/shared/assets/not-found.tsx b/apps/builder/app/builder/shared/assets/not-found.tsx
index 30351ae0b9..599a7143c3 100644
--- a/apps/builder/app/builder/shared/assets/not-found.tsx
+++ b/apps/builder/app/builder/shared/assets/not-found.tsx
@@ -1,9 +1,9 @@
-import { Flex } from "@webstudio-is/design-system";
+import { Flex, Text } from "@webstudio-is/design-system";
export const NotFound = () => {
return (
<Flex align="center" justify="center" css={{ height: 100 }}>
- No matching assets
+ <Text>No matching assets</Text>
</Flex>
);
};
diff --git a/apps/builder/app/dashboard/projects/project-card.tsx b/apps/builder/app/dashboard/projects/project-card.tsx
index 7fae3168b8..2e2d6ecd42 100644
--- a/apps/builder/app/dashboard/projects/project-card.tsx
+++ b/apps/builder/app/dashboard/projects/project-card.tsx
@@ -216,7 +216,7 @@ export const ProjectCard = ({
className={footerStyle()}
>
<Flex direction="column" justify="around">
- <Text variant="titles" truncate>
+ <Text variant="titles" truncate css={{ userSelect: "auto" }}>
{title}
</Text>
{isPublished ? (
diff --git a/apps/builder/app/dashboard/projects/project-dialogs.tsx b/apps/builder/app/dashboard/projects/project-dialogs.tsx
index caa48a0964..a9495e2428 100644
--- a/apps/builder/app/dashboard/projects/project-dialogs.tsx
+++ b/apps/builder/app/dashboard/projects/project-dialogs.tsx
@@ -67,7 +67,7 @@ const DialogContent = ({
<Text as="p">{description}</Text>
</DialogDescription>
)}
- <Label>{label}</Label>
+ {typeof label === "string" ? <Label>{label}</Label> : label}
<DeprecatedTextField
placeholder={placeholder}
name="title"
@@ -292,13 +292,18 @@ export const DeleteProjectDialog = ({
onChange={handleChange}
errors={errors}
label={
- <>
- Confirm by typing{" "}
- <Text as="span" color="destructive" variant="labelsSentenceCase">
- {title}
- </Text>{" "}
+ <Label css={{ userSelect: "auto" }}>
+ Confirm by typing
+ <Text
+ as="span"
+ color="destructive"
+ variant="labelsSentenceCase"
+ css={{ userSelect: "auto" }}
+ >
+ {` ${title} `}
+ </Text>
below
- </>
+ </Label>
}
description="This project and its styles, pages and images will be deleted permanently."
primaryButton={
diff --git a/apps/builder/app/dashboard/projects/thumbnail-link.tsx b/apps/builder/app/dashboard/projects/thumbnail-link.tsx
index b7c61fead0..1e17d1521b 100644
--- a/apps/builder/app/dashboard/projects/thumbnail-link.tsx
+++ b/apps/builder/app/dashboard/projects/thumbnail-link.tsx
@@ -11,7 +11,6 @@ const thumbnailStyle = css(textVariants.brandThumbnailLargeDefault, {
WebkitBackgroundClip: "text",
backgroundClip: "text",
color: "transparent",
- userSelect: "none",
outline: "none",
"&:hover, &:focus": {
...textVariants.brandThumbnailLargeHover,
diff --git a/packages/design-system/src/components/label.tsx b/packages/design-system/src/components/label.tsx
index d011dd318a..0434c3f12c 100644
--- a/packages/design-system/src/components/label.tsx
+++ b/packages/design-system/src/components/label.tsx
@@ -18,6 +18,7 @@ const StyledLabel = styled(RadixLabel, {
WebkitFontSmoothing: "antialiased",
display: "block",
cursor: "default",
+ userSelect: "none",
boxSizing: "border-box",
flexShrink: 0,
diff --git a/packages/design-system/src/components/text.ts b/packages/design-system/src/components/text.ts
index b8c49ae52d..877b351376 100644
--- a/packages/design-system/src/components/text.ts
+++ b/packages/design-system/src/components/text.ts
@@ -1,7 +1,23 @@
import { css, theme, styled } from "../stitches.config";
-import { typography as textVariants } from "../__generated__/figma-design-tokens";
+import { typography } from "../__generated__/figma-design-tokens";
-export { textVariants };
+const normalize = {
+ userSelect: "none",
+ cursor: "default",
+} as const;
+
+type Variant = keyof typeof typography;
+type VariantStyle = typeof normalize & (typeof typography)[Variant];
+
+export const textVariants = {} as { [Key in Variant]: VariantStyle };
+
+let variant: Variant;
+for (variant in typography) {
+ textVariants[variant] = {
+ ...typography[variant as Variant],
+ ...normalize,
+ };
+}
export const textStyle = css({
margin: 0, // in case it's used with <p>
@@ -36,6 +52,14 @@ export const textStyle = css({
flexGrow: 1,
},
},
+ userSelect: {
+ auto: {
+ userSelect: "auto",
+ },
+ none: {
+ userSelect: "none",
+ },
+ },
},
defaultVariants: { variant: "regular" },
});
diff --git a/packages/design-system/src/components/toolbar.tsx b/packages/design-system/src/components/toolbar.tsx
index d65c185700..8e1eba8999 100644
--- a/packages/design-system/src/components/toolbar.tsx
+++ b/packages/design-system/src/components/toolbar.tsx
@@ -5,7 +5,7 @@
import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
import { css, styled, theme } from "../stitches.config";
import { separatorStyle } from "./separator";
-import { typography } from "../__generated__/figma-design-tokens";
+import { textVariants } from "./text";
export const Toolbar = styled(ToolbarPrimitive.Root, {
display: "flex",
@@ -34,7 +34,7 @@ const toolbarItemFocusRing = {
},
};
-export const toggleItemStyle = css(typography.labelsTitleCase, {
+export const toggleItemStyle = css(textVariants.labelsTitleCase, {
// reset styles
boxSizing: "border-box",
position: "relative",