Skip to content

Commit 70d5122

Browse files
authored
experimental: Text Animation storybook (#4938)
# Description This PR introduces prototypes for a set of versatile animation components: • AnimateProxy: A wrapper component supporting staggered animations and integrations with third-party animation engines. • AnimateTextProgress: Demonstrates per-character staggered text animations. 👉 [View Storybook Preview](https://6382151c8b47d4399fb9fc69-uyomckzwfj.chromatic.com/iframe.html?args=&globals=&id=sdk-components-animation-animate-proxy--in-out&viewMode=story) Features • Added Storybook examples showcasing text animation capabilities. • Supports custom CSS properties within keyframes for enhanced animation flexibility. Upcoming PRs Future PRs will introduce more specialized animation components utilizing the AnimateProxy: ```jsx // Example usage of AnimateText <AnimateProxy> {($progress, getStylesAt) => ( <AnimateTextProgress $progress={$progress} getStylesAt={getStylesAt} charWindow={50} easing="easeInQuart" > {children} </AnimateTextProgress> )} </AnimateProxy> // Example usage of AnimateStager <AnimateProxy> {($progress, getStylesAt) => ( <Stager $progress={$progress} getStylesAt={getStylesAt} // Additional props... /> )} </AnimateProxy> // Example usage of AnimateLottie <AnimateProxy> {($progress, getStylesAt) => ( <Lottie $progress={$progress} getStylesAt={getStylesAt} // Additional props... /> )} </AnimateProxy> ``` See corresponding PR: (link to be added) ## 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 68cce11 commit 70d5122

File tree

12 files changed

+99
-4
lines changed

12 files changed

+99
-4
lines changed

apps/builder/app/builder/features/components/components.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ const $metas = computed(
6666
continue;
6767
}
6868

69+
if (
70+
isFeatureEnabled("animation") === false &&
71+
name.endsWith(":AnimateText")
72+
) {
73+
continue;
74+
}
6975
// only set available components from component meta
7076
availableComponents.add(name);
7177
if (

packages/sdk-components-animation/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@
5959
"@webstudio-is/react-sdk": "workspace:*",
6060
"@webstudio-is/sdk": "workspace:*",
6161
"change-case": "^5.4.4",
62+
"nanostores": "^0.11.3",
6263
"react-error-boundary": "^5.0.0",
63-
"scroll-timeline-polyfill": "^1.1.0"
64+
"scroll-timeline-polyfill": "^1.1.0",
65+
"shallow-equal": "^3.1.0"
6466
},
6567
"devDependencies": {
6668
"@types/react": "^18.2.70",

packages/sdk-components-animation/src/__generated__/animate-children.props.ts

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sdk-components-animation/src/__generated__/animate-text.props.ts

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { forwardRef, type ElementRef } from "react";
2+
3+
const easings = {
4+
linear: true,
5+
easeIn: true,
6+
easeInCubic: true,
7+
easeInQuart: true,
8+
easeOut: true,
9+
easeOutCubic: true,
10+
easeOutQuart: true,
11+
ease: true,
12+
easeInOutCubic: true,
13+
easeInOutQuart: true,
14+
};
15+
16+
type AnimateChildrenProps = {
17+
charWindow: number;
18+
easing: keyof typeof easings;
19+
children: React.ReactNode;
20+
};
21+
22+
export const AnimateText = forwardRef<ElementRef<"div">, AnimateChildrenProps>(
23+
({ charWindow: _, easing: __, ...props }, ref) => {
24+
return <div ref={ref} {...props} />;
25+
}
26+
);
27+
28+
const displayName = "AnimateText";
29+
AnimateText.displayName = displayName;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { TextIcon } from "@webstudio-is/icons/svg";
2+
import type { WsComponentMeta, WsComponentPropsMeta } from "@webstudio-is/sdk";
3+
import { props } from "./__generated__/animate-text.props";
4+
5+
export const meta: WsComponentMeta = {
6+
category: "general",
7+
type: "container",
8+
description: "Animate Text",
9+
icon: TextIcon,
10+
order: 6,
11+
label: "Animate Text",
12+
};
13+
14+
export const propsMeta: WsComponentPropsMeta = {
15+
props,
16+
initialProps: ["charWindow", "easing"],
17+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { AnimateChildren } from "./animate-children";
2+
export { AnimateText } from "./animate-text";
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export { meta as AnimateChildren } from "./scroll.ws";
1+
export { meta as AnimateChildren } from "./animate-children.ws";
2+
export { meta as AnimateText } from "./animate-text.ws";

0 commit comments

Comments
 (0)