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.

review refactor

Sultan976e2de0105b
diff --git a/apps/designer/app/designer/features/footer/breadcrumbs.tsx b/apps/designer/app/designer/features/footer/breadcrumbs.tsx
index ba6b13702c..e300013aa8 100644
--- a/apps/designer/app/designer/features/footer/breadcrumbs.tsx
+++ b/apps/designer/app/designer/features/footer/breadcrumbs.tsx
@@ -1,5 +1,5 @@
import { ChevronRightIcon } from "@webstudio-is/icons";
-import { Button, Flex, __DEPRECATED__Text } from "@webstudio-is/design-system";
+import { Button, Flex, Text } from "@webstudio-is/design-system";
import { useSelectedInstancePath } from "~/designer/shared/instance/use-selected-instance-path";
import { type Publish, type Instance } from "@webstudio-is/react-sdk";
import { useSelectedInstanceData } from "~/designer/shared/nano-states";
@@ -41,7 +41,7 @@ export const Breadcrumbs = ({ publish }: BreadcrumbsProps) => {
<Flex align="center" css={{ height: "100%" }}>
{selectedInstancePath.length === 0 ? (
<Breadcrumb>
- <__DEPRECATED__Text size="1">No instance selected</__DEPRECATED__Text>
+ <Text size="1">No instance selected</Text>
</Breadcrumb>
) : (
selectedInstancePath.map((instance) => (
diff --git a/apps/designer/app/designer/features/inspector/inspector.tsx b/apps/designer/app/designer/features/inspector/inspector.tsx
index 3253352fa9..0412fa834f 100644
--- a/apps/designer/app/designer/features/inspector/inspector.tsx
+++ b/apps/designer/app/designer/features/inspector/inspector.tsx
@@ -1,6 +1,6 @@
import type { Publish } from "@webstudio-is/react-sdk";
import {
- __DEPRECATED__Text,
+ Text,
Tabs,
TabsList,
TabsTrigger,
@@ -43,14 +43,14 @@ export const Inspector = ({ publish }: InspectorProps) => {
<Tabs defaultValue="style" css={{ width: "100%" }}>
<TabsList>
<TabsTrigger value="style">
- <__DEPRECATED__Text>Style</__DEPRECATED__Text>
+ <Text>Style</Text>
</TabsTrigger>
{/* @note: events would be part of props */}
<TabsTrigger value="props">
- <__DEPRECATED__Text>Props</__DEPRECATED__Text>
+ <Text>Props</Text>
</TabsTrigger>
<TabsTrigger value="inspect">
- <__DEPRECATED__Text>Inspect</__DEPRECATED__Text>
+ <Text>Inspect</Text>
</TabsTrigger>
</TabsList>
<TabsContent value="style" css={contentStyle}>
diff --git a/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx b/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx
index efa8b04ece..853fb94883 100644
--- a/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx
@@ -25,46 +25,62 @@ const commonUnitsSubset = units
: 1
);
-const CSSGridLeft = {
+const gridTemplateStyle = {
+ gridTemplateColumns: "$sizes$6 auto $sizes$6",
+ gridTemplateRows: "repeat(1, 1fr)",
+};
+
+const gridLeftStyle = {
"& ~ input": {
- paddingLeft: "calc($sizes$6 + 6px)",
+ paddingLeft: "calc($sizes$6 + $nudge$3)",
},
gridArea: "1 / 1 / 2 / 2",
};
-const CSSGridRight = {
+const gridRightStyle = {
gridArea: "-1 / -1 / -2 / -2",
"& ~ input": {
- paddingRight: "calc($sizes$5 + 6px)",
+ paddingRight: "calc($sizes$5 + $nudge$3)",
},
};
-const CSSIconButton = {
+const iconButtonStyle = {
zIndex: 1,
borderRadius: 2,
- height: "calc($sizes$6 - 6px)",
- width: "calc($sizes$6 - 6px)",
+ height: "calc($sizes$6 - $nudge$3)",
+ width: "calc($sizes$6 - $nudge$3)",
transform: "translate(3px, 3px)",
"&:focus": {
boxShadow: "none",
},
};
-const CSSTextUnit = {
- fontSize: "$1",
- cursor: "default",
+const iconButtonActiveStyle = {
+ bc: "$colors$blue4",
+ "&:not(:hover)": {
+ color: "$colors$blue11",
+ },
+};
+
+const iconButtonGridLeftStyle = {
+ ...gridLeftStyle,
+ ...iconButtonStyle,
+};
+
+const iconButtonGridRightStyle = {
+ ...gridRightStyle,
+ "& button": { ...iconButtonStyle },
};
-const CSSTextField = {
+const textFieldStyle = {
height: "$6",
fontWeight: "500",
- paddingLeft: "calc($sizes$1 + 6px)",
+ paddingLeft: "calc($sizes$1 + $nudge$3)",
gridArea: "1 / 1 / -1 / -1",
cursor: "default",
};
export const TextControl = ({
- category,
currentStyle,
inheritedStyle,
setProperty,
@@ -82,32 +98,14 @@ export const TextControl = ({
if (value === undefined) return null;
- // @todo setValue has a latency issue when updating a value fast(i.e keyboard arrows/scrub control)
const setValue = setProperty(styleConfig.property);
- let Icon;
+ const Icon = iconConfigs[styleConfig.property]?.normal;
- const { label, property } = styleConfig;
-
- // @todo this silo's the flex section
- let multiColumn = true;
- if (
- category === "layout" &&
- property.includes("Gap") &&
- (currentStyle.display?.value as string).includes("flex")
- ) {
- Icon = iconConfigs[styleConfig.property]?.normal;
- multiColumn = false;
- }
return (
- <Grid columns={multiColumn ? 2 : 1}>
- {multiColumn && <PropertyName property={property} label={label} />}
- <Grid
- css={{
- gridTemplateColumns: "$sizes$6 auto $sizes$6",
- gridTemplateRows: "repeat(1, 1fr)",
- }}
- >
+ <Grid columns={2}>
+ <PropertyName property={styleConfig.property} label={styleConfig.label} />
+ <Grid css={gridTemplateStyle}>
{Icon && (
<Tooltip
content={styleConfig.label}
@@ -140,14 +138,8 @@ export const TextControl = ({
variant="ghost"
size="1"
css={{
- ...CSSGridLeft,
- ...CSSIconButton,
- ...(isCurrentBreakpoint && {
- bc: "$colors$blue4",
- "&:not(:hover)": {
- color: "$colors$blue11",
- },
- }),
+ ...iconButtonGridLeftStyle,
+ ...(isCurrentBreakpoint && iconButtonActiveStyle),
}}
>
{Icon && <Icon />}
@@ -172,7 +164,7 @@ export const TextControl = ({
)}
<TextField
ref={textFieldRef}
- css={CSSTextField}
+ css={textFieldStyle}
spellCheck={false}
defaultValue={value.value}
onFocus={(event: FocusEvent<HTMLInputElement>) =>
@@ -224,18 +216,17 @@ const Units = ({
onChange?: (value: string) => void;
}) => {
return (
- <Box
- css={{
- ...CSSGridRight,
- button: { ...CSSIconButton },
- }}
- >
+ <Box css={iconButtonGridRightStyle}>
<IconButtonWithMenu
- icon={<Text css={CSSTextUnit}>{value === "number" ? "—" : value}</Text>}
+ icon={
+ <Text css={{ cursor: "default" }}>
+ {value === "number" ? "—" : value}
+ </Text>
+ }
items={items}
value={String(value)}
onChange={onChange}
- ></IconButtonWithMenu>
+ />
</Box>
);
};
@@ -251,12 +242,7 @@ const Items = ({
}) => {
if (!items?.length) return null;
return (
- <Box
- css={{
- ...CSSGridRight,
- button: { ...CSSIconButton },
- }}
- >
+ <Box css={iconButtonGridRightStyle}>
<IconButtonWithMenu
icon={<ChevronDownIcon />}
items={items}
diff --git a/apps/designer/app/designer/features/style-panel/sections/layout/layout.tsx b/apps/designer/app/designer/features/style-panel/sections/layout/layout.tsx
index 11324821b4..d8e2e091ec 100644
--- a/apps/designer/app/designer/features/style-panel/sections/layout/layout.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/layout/layout.tsx
@@ -1,10 +1,10 @@
import { Grid } from "@webstudio-is/design-system";
import type { RenderCategoryProps } from "../../style-sections";
-import { FlexGrid } from "../../shared/flex-grid";
-import { Lock } from "../../shared/lock";
+import { FlexGrid } from "./shared/flex-grid";
+import { Lock } from "./shared/lock";
import { ShowMore } from "../../shared/show-more";
-const CSSLayoutSection = {
+const layoutSectionStyle = {
alignItems: "center",
gap: "$space$styleSection",
"& > [data-type=iconbuttonwithmenu]": {
@@ -15,8 +15,8 @@ const CSSLayoutSection = {
},
};
-const CSSLayoutSectionFlex = {
- ...CSSLayoutSection,
+const layoutSectionFlexStyle = {
+ ...layoutSectionStyle,
gridTemplateColumns: "repeat(12, 1fr)",
gridTemplateRows: "auto 0px auto auto 0px auto",
gridTemplateAreas: `
@@ -31,6 +31,14 @@ const CSSLayoutSectionFlex = {
"& > [data-property=justifyItems]": {
display: "none",
},
+ "& [data-control=text]": {
+ "& > :first-child": {
+ gridTemplateColumns: "repeat(1, 1fr)",
+ "& > :first-child": {
+ display: "none",
+ },
+ },
+ },
};
const LayoutSectionFlex = ({
@@ -40,7 +48,7 @@ const LayoutSectionFlex = ({
}: RenderCategoryProps) => {
const batchUpdate = createBatchUpdate();
return (
- <Grid css={CSSLayoutSectionFlex}>
+ <Grid css={layoutSectionFlexStyle}>
{styleConfigsByCategory}
<Lock
name="lock"
diff --git a/apps/designer/app/designer/features/style-panel/shared/flex-grid.tsx b/apps/designer/app/designer/features/style-panel/sections/layout/shared/flex-grid.tsx
similarity index 96%
rename from apps/designer/app/designer/features/style-panel/shared/flex-grid.tsx
rename to apps/designer/app/designer/features/style-panel/sections/layout/shared/flex-grid.tsx
index c4b75050c1..077958a68e 100644
--- a/apps/designer/app/designer/features/style-panel/shared/flex-grid.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/layout/shared/flex-grid.tsx
@@ -1,8 +1,8 @@
import { Flex, Grid, IconButton } from "@webstudio-is/design-system";
import { DotFilledIcon } from "@webstudio-is/icons";
-import { useIsFromCurrentBreakpoint } from "./use-is-from-current-breakpoint";
+import { useIsFromCurrentBreakpoint } from "../../../shared/use-is-from-current-breakpoint";
import type { Style } from "@webstudio-is/react-sdk";
-import type { CreateBatchUpdate } from "./use-style-data";
+import type { CreateBatchUpdate } from "../../../shared/use-style-data";
export const FlexGrid = ({
name,
diff --git a/apps/designer/app/designer/features/style-panel/shared/lock.tsx b/apps/designer/app/designer/features/style-panel/sections/layout/shared/lock.tsx
similarity index 95%
rename from apps/designer/app/designer/features/style-panel/shared/lock.tsx
rename to apps/designer/app/designer/features/style-panel/sections/layout/shared/lock.tsx
index 6fb9964107..3b55ef674f 100644
--- a/apps/designer/app/designer/features/style-panel/shared/lock.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/layout/shared/lock.tsx
@@ -2,7 +2,7 @@ import { useState, useEffect } from "react";
import { IconButton, Tooltip } from "@webstudio-is/design-system";
import { LockOpenIcon, LockCloseIcon } from "@webstudio-is/icons";
import type { Style } from "@webstudio-is/react-sdk";
-import type { CreateBatchUpdate } from "./use-style-data";
+import type { CreateBatchUpdate } from "../../../shared/use-style-data";
export const Lock = ({
name,
diff --git a/apps/designer/app/designer/shared/inspector/collapsible-section.tsx b/apps/designer/app/designer/shared/inspector/collapsible-section.tsx
index 4487be650c..fa27f5a4ab 100644
--- a/apps/designer/app/designer/shared/inspector/collapsible-section.tsx
+++ b/apps/designer/app/designer/shared/inspector/collapsible-section.tsx
@@ -1,10 +1,5 @@
import { createValueContainer, useValue } from "react-nano-state";
-import {
- Box,
- Flex,
- __DEPRECATED__Text,
- Collapsible,
-} from "@webstudio-is/design-system";
+import { Box, Flex, Text, Collapsible } from "@webstudio-is/design-system";
import { ChevronLeftIcon, ChevronRightIcon } from "@webstudio-is/icons";
type CollapsibleSectionProps = {
@@ -58,16 +53,11 @@ export const CollapsibleSection = ({
cursor: "default",
}}
>
- <__DEPRECATED__Text
- size="1"
- css={{ fontWeight: "500", flexGrow: 1 }}
- >
- {label}
- </__DEPRECATED__Text>
+ <Text css={{ fontWeight: "500", flexGrow: 1 }}>{label}</Text>
<Flex
align="center"
justify="center"
- css={{ marginRight: -5, opacity: ".4" }}
+ css={{ marginRight: "-$space$1", opacity: "$opacity$1" }}
>
{isOpenFinal ? <ChevronLeftIcon /> : <ChevronRightIcon />}
</Flex>
diff --git a/apps/designer/app/designer/shared/inspector/component-info.tsx b/apps/designer/app/designer/shared/inspector/component-info.tsx
index 44091b8f8d..421168a928 100644
--- a/apps/designer/app/designer/shared/inspector/component-info.tsx
+++ b/apps/designer/app/designer/shared/inspector/component-info.tsx
@@ -1,5 +1,5 @@
import { components } from "@webstudio-is/react-sdk";
-import { Flex, __DEPRECATED__Text } from "@webstudio-is/design-system";
+import { Flex, Text } from "@webstudio-is/design-system";
import type { SelectedInstanceData } from "~/shared/canvas-components";
export const ComponentInfo = ({
@@ -9,15 +9,13 @@ export const ComponentInfo = ({
}) => {
return (
<Flex justify="between" align="center">
- <__DEPRECATED__Text
+ <Text
css={{
fontSize: "$2",
color: "$colors$slate11",
fontWeight: "500",
}}
- >{`Selected: ${
- components[selectedInstanceData.component].label
- }`}</__DEPRECATED__Text>
+ >{`Selected: ${components[selectedInstanceData.component].label}`}</Text>
</Flex>
);
};
diff --git a/packages/design-system/src/components/icon-button-with-menu.tsx b/packages/design-system/src/components/icon-button-with-menu.tsx
index 39f58c6b4a..3a4ec5cd06 100644
--- a/packages/design-system/src/components/icon-button-with-menu.tsx
+++ b/packages/design-system/src/components/icon-button-with-menu.tsx
@@ -2,6 +2,7 @@ import { CheckIcon, IconComponent } from "@webstudio-is/icons";
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
import { styled } from "../stitches.config";
import { Tooltip } from "./tooltip";
+import { IconButton } from "./icon-button";
const StyledContent = styled(DropdownMenuPrimitive.Content, {
width: 192,
@@ -55,21 +56,23 @@ const StyledArrow = styled(DropdownMenuPrimitive.Arrow, {
},
});
-const IconButton = styled("button", {
- all: "unset",
- fontFamily: "inherit",
- borderRadius: "calc($radii$1 / 2)",
+const iconButtonStyle = {
width: "$6",
height: "$6",
- display: "inline-flex",
- alignItems: "center",
- justifyContent: "center",
color: "$colors$gray12",
backgroundColor: "$colors$loContrast",
"&:hover": {
backgroundColor: "$colors$gray3",
},
-});
+};
+
+const iconButtonActiveStyle = {
+ color: "$colors$blue11",
+ backgroundColor: "$colors$blue4",
+ "&:hover": {
+ backgroundColor: "$colors$blue4",
+ },
+};
export const IconButtonWithMenu = ({
icon: Icon,
@@ -99,17 +102,12 @@ export const IconButtonWithMenu = ({
>
<DropdownMenuPrimitive.Trigger asChild>
<IconButton
- css={
- isActive
- ? {
- color: "$colors$blue11",
- backgroundColor: "$colors$blue4",
- "&:hover": {
- backgroundColor: "$colors$blue4",
- },
- }
- : {}
- }
+ css={{
+ ...iconButtonStyle,
+ ...(isActive && {
+ iconButtonActiveStyle,
+ }),
+ }}
>
{Icon}
</IconButton>
diff --git a/packages/design-system/src/components/tabs.tsx b/packages/design-system/src/components/tabs.tsx
index fc37963a28..29be80aad5 100644
--- a/packages/design-system/src/components/tabs.tsx
+++ b/packages/design-system/src/components/tabs.tsx
@@ -1,7 +1,7 @@
import React from "react";
import { styled, CSS } from "../stitches.config";
import * as TabsPrimitive from "@radix-ui/react-tabs";
-import { __DEPRECATED__Text } from "./__DEPRECATED__/text";
+import { Text } from "./text";
export const Tabs = styled(TabsPrimitive.Root, {
display: "flex",
@@ -28,7 +28,7 @@ export const TabsTrigger = styled(TabsPrimitive.Trigger, {
["&:first-child"]: {
paddingLeft: "$3",
},
- [`& > ${__DEPRECATED__Text}`]: {
+ [`& > ${Text}`]: {
color: "$gray9",
fontSize: "$fontSizes$1",
fontWeight: "500",
@@ -40,7 +40,7 @@ export const TabsTrigger = styled(TabsPrimitive.Trigger, {
},
'&[data-state="active"]': {
- [`& > ${__DEPRECATED__Text}`]: {
+ [`& > ${Text}`]: {
color: "$hiContrast",
},
},
diff --git a/packages/design-system/src/stitches.config.ts b/packages/design-system/src/stitches.config.ts
index f019f40877..cec9a822fe 100644
--- a/packages/design-system/src/stitches.config.ts
+++ b/packages/design-system/src/stitches.config.ts
@@ -211,6 +211,14 @@ export const {
sans: "Inter, -apple-system, system-ui, sans-serif",
mono: "Roboto, menlo, monospace",
},
+ opacity: {
+ 1: "0.4",
+ },
+ nudge: {
+ 1: "1px",
+ 2: "3px",
+ 3: "6px",
+ },
space: {
1: "4px",
2: "8px",