diff --git a/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.tsx b/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.tsx index 36810ffa9a..234e49e529 100644 --- a/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.tsx +++ b/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.tsx @@ -1,11 +1,13 @@ import { useState } from "react"; import { Box, + EnhancedTooltip, Flex, Grid, InputField, Label, Select, + SmallToggleButton, theme, toast, } from "@webstudio-is/design-system"; @@ -34,6 +36,7 @@ import { } from "@webstudio-is/css-engine"; import { Keyframes } from "./animation-keyframes"; import { humanizeString } from "~/shared/string-utils"; +import { Link2Icon, Link2UnlinkedIcon } from "@webstudio-is/icons"; const fillModeDescriptions: Record< NonNullable, @@ -215,11 +218,27 @@ type AnimationPanelContentProps = { ((value: undefined, isEphemeral: true) => void); }; +const defaultRangeStart = { + type: "unit", + value: 0, + unit: "%", +}; + +const defaultRangeEnd = { + type: "unit", + value: 100, + unit: "%", +}; + export const AnimationPanelContent = ({ onChange, value, type, }: AnimationPanelContentProps) => { + const [isLinked, setIsLinked] = useState( + value.timing.rangeStart?.[0] === value.timing.rangeEnd?.[0] + ); + const fieldIds = useIds([ "rangeStartName", "rangeStartValue", @@ -302,12 +321,13 @@ export const AnimationPanelContent = ({ gap={1} align={"center"} css={{ - gridTemplateColumns: "1fr 1fr", + gridTemplateColumns: "1fr 16px 1fr", paddingInline: theme.panel.paddingInline, flexShrink: 0, }} > +
+ + + { + setIsLinked(pressed); + if (pressed) { + handleChange( + { + ...value, + timing: { + ...value.timing, + rangeEnd: pressed + ? [ + value.timing.rangeStart?.[0] ?? "entry", + value.timing.rangeEnd?.[1] ?? defaultRangeEnd, + ] + : value.timing.rangeEnd, + }, + }, + false + ); + } + }} + variant="normal" + icon={isLinked ? : } + /> + + + ( - - { - timelineRangeDescriptions[ - timelineRangeName as keyof typeof timelineRangeDescriptions - ] - } - - )} - onItemHighlight={(timelineRangeName) => { - if (timelineRangeName === undefined) { - handleChange(undefined, true); - return; - } - handleChange( - { - ...value, - timing: { - ...value.timing, - rangeEnd: [ - timelineRangeName, - value.timing.rangeEnd?.[1] ?? { - type: "unit", - value: 0, - unit: "%", - }, - ], - }, - }, - true - ); - }} - onChange={(timelineRangeName) => { - handleChange( - { - ...value, - timing: { - ...value.timing, - rangeEnd: [ - timelineRangeName, - value.timing.rangeEnd?.[1] ?? { - type: "unit", - value: 0, - unit: "%", - }, - ], - }, - }, - false - ); - }} - /> +