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.

text control icon only for flex section atm, sort units instead of cut of

Sultan3530433d25b6
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 6977ffb435..62f46fcc17 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
@@ -17,6 +17,14 @@ import { type StyleValue, type Unit, units } from "@webstudio-is/react-sdk";
import { ChevronDownIcon } from "@webstudio-is/icons";
import { PropertyName } from "../../shared/property-name";
+const commonUnitsSubset = units
+ .slice(0)
+ .sort((v) =>
+ ["%", "px", "rem", "em", "ch", "vh", "vw", "hv", "vmin", "vmax"].includes(v)
+ ? -1
+ : 1
+ );
+
const CSSGridLeft = {
"& ~ input": {
paddingLeft: "calc($sizes$6 + 6px)",
@@ -76,7 +84,7 @@ export const TextControl = ({
// @todo setValue has a latency issue when updating a value fast(i.e keyboard arrows/scrub control)
const setValue = setProperty(styleConfig.property);
- const Icon = iconConfigs[styleConfig.property]?.normal;
+ let Icon;
const { label, property } = styleConfig;
@@ -86,9 +94,10 @@ export const TextControl = ({
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} />}
@@ -139,22 +148,10 @@ export const TextControl = ({
{value.type === "unit" ? (
<Units
value={value.unit}
- items={units
- .filter((v) =>
- [
- "%",
- "px",
- "rem",
- "em",
- "ch",
- "vh",
- "vw",
- "hv",
- "vmin",
- "vmax",
- ].includes(v)
- )
- .map((unit) => ({ name: unit, label: unit }))}
+ items={commonUnitsSubset.map((unit) => ({
+ name: unit,
+ label: unit,
+ }))}
onChange={(unit) => setValue(value.value + unit)}
/>
) : (
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 c55280c547..39f58c6b4a 100644
--- a/packages/design-system/src/components/icon-button-with-menu.tsx
+++ b/packages/design-system/src/components/icon-button-with-menu.tsx
@@ -5,7 +5,7 @@ import { Tooltip } from "./tooltip";
const StyledContent = styled(DropdownMenuPrimitive.Content, {
width: 192,
- maxHeight: 320,
+ maxHeight: 238,
overflow: "auto",
backgroundColor: "$colors$slate4",
borderRadius: "$radii$1",