Skip to content

Commit 678dde8

Browse files
authored
experimental: Animation axis Icons change (#5060)
## Description <img width="255" alt="image" src="https://github.com/user-attachments/assets/dffc4f96-f669-4f65-883c-1acafecea4c2" /> ## 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 52f1745 commit 678dde8

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

apps/builder/app/builder/features/settings-panel/props-section/animation/animation-section.tsx

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
insetUnitValueSchema,
2626
RANGE_UNITS,
2727
} from "@webstudio-is/sdk";
28-
import { RepeatColumnIcon, RepeatRowIcon } from "@webstudio-is/icons";
28+
import { ArrowDownIcon, ArrowRightIcon } from "@webstudio-is/icons";
2929
import { AnimationsSelect } from "./animations-select";
3030
import { SubjectSelect } from "./subject-select";
3131
import { toValue, type StyleValue } from "@webstudio-is/css-engine";
@@ -51,35 +51,52 @@ const defaultActionValue: AnimationAction = {
5151
};
5252

5353
const animationAxisDescription: Record<
54-
NonNullable<AnimationAction["axis"]>,
54+
Exclude<NonNullable<AnimationAction["axis"]>, "block" | "inline">,
5555
{ icon: React.ReactNode; label: string; description: React.ReactNode }
5656
> = {
57+
/*
58+
// We decided to not support block and inline axis, as mostly not used
5759
block: {
58-
icon: <RepeatColumnIcon />,
60+
icon: <ArrowDownIcon />,
5961
label: "Block axis",
6062
description:
6163
"Uses the scroll progress along the block axis (depends on writing mode, usually vertical in English).",
6264
},
6365
inline: {
64-
icon: <RepeatRowIcon />,
66+
icon: <ArrowRightIcon />,
6567
label: "Inline axis",
6668
description:
6769
"Uses the scroll progress along the inline axis (depends on writing mode, usually horizontal in English).",
6870
},
71+
*/
72+
6973
y: {
7074
label: "Y axis",
71-
icon: <RepeatColumnIcon />,
72-
description:
73-
"Always maps to the vertical scroll direction, regardless of writing mode.",
75+
icon: <ArrowDownIcon />,
76+
description: "The scrollbar on the vertical axis of the scroller element.",
7477
},
7578
x: {
7679
label: "X axis",
77-
icon: <RepeatRowIcon />,
80+
icon: <ArrowRightIcon />,
7881
description:
79-
"Always maps to the horizontal scroll direction, regardless of writing mode.",
82+
"The scrollbar on the horizontal axis of the scroller element.",
8083
},
8184
};
8285

86+
/**
87+
* Support for block and inline axis is removed, as it is not widely used.
88+
*/
89+
const convertAxisToXY = (axis: NonNullable<AnimationAction["axis"]>) => {
90+
switch (axis) {
91+
case "block":
92+
return "y";
93+
case "inline":
94+
return "x";
95+
default:
96+
return axis;
97+
}
98+
};
99+
83100
const animationSourceDescriptions: Record<
84101
NonNullable<AnimationActionScroll["source"]>,
85102
string
@@ -217,7 +234,7 @@ export const AnimationSection = ({
217234
return;
218235
}
219236

220-
toast.error("Schemas are incompatible, try fix");
237+
toast.error("Invalid animation schema.");
221238
};
222239

223240
return (
@@ -280,10 +297,13 @@ export const AnimationSection = ({
280297
<Grid gap={1} align={"center"} css={{ gridTemplateColumns: "1fr 1fr" }}>
281298
<Label>Axis</Label>
282299
<ToggleGroup
300+
css={{
301+
justifySelf: "end",
302+
}}
283303
type="single"
284-
value={value.axis ?? ("block" as const)}
285-
onValueChange={(axis) => {
286-
handleChange({ ...value, axis }, false);
304+
value={convertAxisToXY(value.axis ?? ("y" as const))}
305+
onValueChange={(axis: keyof typeof animationAxisDescription) => {
306+
handleChange({ ...value, axis: convertAxisToXY(axis) }, false);
287307
}}
288308
>
289309
{Object.entries(animationAxisDescription).map(

0 commit comments

Comments
 (0)