feat: Additional way to reset in spacing (#4924)

## Description

closes https://github.com/webstudio-is/webstudio/issues/4844

As a user when I don't know about option+click shorthand, and try to
reset spacing, only other way is to wait for the tooltip to come. If you
click, like you do on other labels - input will come but no way to
reset.

Solution: show a label next to the input.

## Steps for reproduction

1. click on any spacing value
2. see label next to input
3. test usual label functionality

## 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
This commit is contained in:
Oleg Isonen authored and GitHub committed 2025-03-02 20:17:44 +01:00
1 parent ddc425cd40
commit 75b82d69a2
1 file changed
+20 -8
@@ -5,17 +5,21 @@ import {
Popover,
PopoverTrigger,
PopoverContent,
Flex,
theme,
} from "@webstudio-is/design-system";
import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";
import { propertyDescriptions } from "@webstudio-is/css-data";
import {
CssValueInput,
type IntermediateStyleValue,
} from "../../shared/css-value-input";
import { createBatchUpdate } from "../../shared/use-style-data";
import { theme } from "@webstudio-is/design-system";
import type { StyleValueSourceColor } from "~/shared/style-object-model";
import { $availableUnitVariables } from "../../shared/model";
import type { Modifiers } from "../../shared/modifier-keys";
import { PropertyLabel } from "../../property-label";
import { humanizeString } from "~/shared/string-utils";
const slideUpAndFade = keyframes({
"0%": { opacity: 0, transform: "scale(0.8)" },
@@ -120,9 +124,10 @@ const Input = ({
const Trigger = styled("div", { position: "absolute", width: 0, height: 0 });
const PopoverContentStyled = styled(PopoverContent, {
flexDirection: "row",
gap: theme.spacing[5],
minWidth: 0,
minHeight: 0,
width: theme.spacing[20],
border: `1px solid ${theme.colors.borderMain}`,
borderRadius: theme.borderRadius[7],
background: theme.colors.backgroundPanel,
@@ -166,13 +171,20 @@ export const InputPopover = ({
// and closing popover before applying changes
onClick={(event) => event.stopPropagation()}
>
<Input
styleSource={styleSource}
value={value}
property={property}
getActiveProperties={getActiveProperties}
onClosePopover={onClose}
<PropertyLabel
label={humanizeString(property)}
description={propertyDescriptions[property]}
properties={[property]}
/>
<Flex css={{ width: theme.spacing[20] }}>
<Input
styleSource={styleSource}
value={value}
property={property}
getActiveProperties={getActiveProperties}
onClosePopover={onClose}
/>
</Flex>
</PopoverContentStyled>
</Popover>
);