Skip to content

Commit 1d9ae2a

Browse files
authored
feat: make spacing input autogrow (webstudio-is#5052)
## Description When user opens a long value in spacing we now show an input that can big much bigger, max size 240px for the input. On the other hand it will be small if value is small AND it will autogrow <img width="410" alt="image" src="https://github.com/user-attachments/assets/2ccbdc52-9eea-4f5b-bb44-b4e8d4f7b23f" /> ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent 0597c4f commit 1d9ae2a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

apps/builder/app/builder/features/style-panel/sections/shared/input-popover.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ const Input = ({
4545

4646
return (
4747
<CssValueInput
48+
minWidth="6ch"
4849
styleSource={styleSource}
4950
property={property}
5051
value={value}
5152
intermediateValue={intermediateValue}
5253
getOptions={() => $availableUnitVariables.get()}
54+
fieldSizing="content"
5355
onChange={(styleValue) => {
5456
setIntermediateValue(styleValue);
5557
const activeProperties = getActiveProperties();
@@ -176,7 +178,7 @@ export const InputPopover = ({
176178
description={propertyDescriptions[property]}
177179
properties={[property]}
178180
/>
179-
<Flex css={{ width: theme.spacing[20] }}>
181+
<Flex css={{ maxWidth: theme.spacing[30] }}>
180182
<Input
181183
styleSource={styleSource}
182184
value={value}

apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ type CssValueInputProps = Pick<
322322
unitOptions?: UnitOption[];
323323
id?: string;
324324
placeholder?: string;
325+
minWidth?: string;
325326
};
326327

327328
const initialValue: IntermediateStyleValue = {
@@ -399,6 +400,7 @@ export const CssValueInput = ({
399400
text,
400401
unitOptions,
401402
placeholder,
403+
minWidth = "2ch",
402404
...props
403405
}: CssValueInputProps) => {
404406
const value = props.intermediateValue ?? props.value ?? initialValue;
@@ -921,7 +923,7 @@ export const CssValueInput = ({
921923
}
922924
css={{
923925
cursor: "default",
924-
minWidth: "2em",
926+
minWidth,
925927
"&:hover": {
926928
[cssButtonDisplay]: "block",
927929
},

0 commit comments

Comments
 (0)