From 73b275e45dde501063ef6a3631e1b2599815ac6f Mon Sep 17 00:00:00 2001 From: istarkov Date: Mon, 14 Apr 2025 16:46:55 +0300 Subject: [PATCH 1/2] experimental: Ranges animation control Add border animation Move vars Try ranges --- .../animation-panel-content.stories.tsx | 43 ++-- .../animation/animation-panel-content.tsx | 229 +++++++++++------- .../animation/animation-ranges.stories.tsx | 102 ++++++++ .../animation/animation-ranges.tsx | 216 +++++++++++++++++ packages/sdk/src/index.ts | 2 + packages/sdk/src/schema/animation-schema.ts | 2 + 6 files changed, 484 insertions(+), 110 deletions(-) create mode 100644 apps/builder/app/builder/features/settings-panel/props-section/animation/animation-ranges.stories.tsx create mode 100644 apps/builder/app/builder/features/settings-panel/props-section/animation/animation-ranges.tsx diff --git a/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.stories.tsx b/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.stories.tsx index 5b66afd4e424..027aa2e09d9b 100644 --- a/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.stories.tsx +++ b/apps/builder/app/builder/features/settings-panel/props-section/animation/animation-panel-content.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from "@storybook/react"; import { AnimationPanelContent } from "./animation-panel-content"; -import { theme } from "@webstudio-is/design-system"; +import { Box, theme } from "@webstudio-is/design-system"; import { useState } from "react"; import type { ScrollAnimation, ViewAnimation } from "@webstudio-is/sdk"; @@ -26,13 +26,19 @@ const ScrollAnimationTemplate: Story["render"] = ({ value: initialValue }) => { const [value, setValue] = useState(initialValue); return ( - { - setValue(newValue as ScrollAnimation); - }} - /> + + { + if (isEphemeral) { + return; + } + + setValue(newValue as ScrollAnimation); + }} + /> + ); }; @@ -40,13 +46,18 @@ const ViewAnimationTemplate: Story["render"] = ({ value: initialValue }) => { const [value, setValue] = useState(initialValue); return ( - { - setValue(newValue as ViewAnimation); - }} - /> + + { + if (isEphemeral) { + return; + } + setValue(newValue as ViewAnimation); + }} + /> + ); }; @@ -82,7 +93,7 @@ export const ViewAnimationStory: Story = { name: "view-animation", timing: { rangeStart: ["entry", { type: "unit", value: 0, unit: "%" }], - rangeEnd: ["exit", { type: "unit", value: 100, unit: "%" }], + rangeEnd: ["entry", { type: "unit", value: 100, unit: "%" }], }, keyframes: [ { 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 4075251e63d7..11222f9aaac6 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 @@ -40,6 +40,7 @@ import { Keyframes } from "./animation-keyframes"; import { humanizeString } from "~/shared/string-utils"; import { Link2Icon, Link2UnlinkedIcon } from "@webstudio-is/icons"; import { $availableUnitVariables } from "~/builder/features/style-panel/shared/model"; +import { AnimationRanges } from "./animation-ranges"; const fillModeDescriptions: Record< NonNullable, @@ -469,22 +470,46 @@ export const AnimationPanelContent = ({ }} /> + - -
-