Skip to content

Commit 19fd987

Browse files
authored
experimental: Animate Text Split (webstudio-is#5048)
## Description New Split By option Animated Text 2nd example https://p-1ada14ed-beb3-4910-8af1-dacaa550310b-dot-anim-txt.staging.webstudio.is/?authToken=1e621fc4-dfb0-4189-a9b0-4fe2e189ec93&mode=preview https://animations.wstd.work/text-animations <img width="258" alt="image" src="https://github.com/user-attachments/assets/b007ec9a-11fd-4a20-969b-a8451f599eeb" /> See 2nd animated per word ![Screen Recording 2025-03-26 at 10 30 31](https://github.com/user-attachments/assets/f6f5e364-d290-4bfb-98c0-9046c85281c7) ## 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 9d298cc commit 19fd987

File tree

8 files changed

+43
-25
lines changed

8 files changed

+43
-25
lines changed

fixtures/webstudio-features/.webstudio/data.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"build": {
3-
"id": "342a7c73-ed72-441d-8a69-8b2659639e93",
3+
"id": "3a8c8a9c-cfd9-46b8-a8bf-30d48250bc1b",
44
"projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d",
5-
"version": 543,
6-
"createdAt": "2025-03-10T13:33:47.683+00:00",
7-
"updatedAt": "2025-03-10T13:33:47.683+00:00",
5+
"version": 554,
6+
"createdAt": "2025-03-26T12:23:17.308+00:00",
7+
"updatedAt": "2025-03-26T12:23:17.308+00:00",
88
"pages": {
99
"meta": {
1010
"siteName": "KittyGuardedZone",
@@ -3805,11 +3805,11 @@
38053805
}
38063806
],
38073807
[
3808-
"WXm4SG4hn0GOxQzlx1onL",
3808+
"PkOUxrUpSNIkRV8MuLSQh",
38093809
{
3810-
"id": "WXm4SG4hn0GOxQzlx1onL",
3810+
"id": "PkOUxrUpSNIkRV8MuLSQh",
38113811
"instanceId": "GRj9UMUzk-HAWRctEcfFH",
3812-
"name": "charWindow",
3812+
"name": "slidingWindow",
38133813
"type": "number",
38143814
"value": 20
38153815
}

fixtures/webstudio-features/app/__generated__/$resources.sitemap.xml.ts

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

fixtures/webstudio-features/app/__generated__/[animations]._index.tsx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/webstudio-features/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dev": "react-router dev",
77
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
88
"fixtures:link": "pnpm cli link --link https://p-cddc1d44-af37-4cb6-a430-d300cf6f932d-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=1cdc6026-dd5b-4624-b89b-9bd45e9bcc3d'",
9-
"fixtures:sync": "pnpm cli sync --buildId 342a7c73-ed72-441d-8a69-8b2659639e93 && pnpm prettier --write ./.webstudio/",
9+
"fixtures:sync": "pnpm cli sync --buildId 3a8c8a9c-cfd9-46b8-a8bf-30d48250bc1b && pnpm prettier --write ./.webstudio/",
1010
"fixtures:build": "pnpm cli build --template react-router --template ./.template && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
1111
},
1212
"private": true,

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

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

packages/sdk-components-animation/src/animate-text.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,25 @@ const easings = {
1313
easeInOutQuart: true,
1414
};
1515

16+
const split = {
17+
char: true,
18+
space: true,
19+
'symbol "#"': true,
20+
'symbol "~"': true,
21+
};
22+
1623
type AnimateChildrenProps = {
17-
charWindow?: number;
24+
slidingWindow?: number;
1825
easing?: keyof typeof easings;
1926
children: React.ReactNode;
27+
splitBy?: keyof typeof split;
2028
};
2129

2230
export const AnimateText = forwardRef<ElementRef<"div">, AnimateChildrenProps>(
23-
({ charWindow = 5, easing = "linear", ...props }, ref) => {
31+
(
32+
{ slidingWindow = 5, easing = "linear", splitBy = "char", ...props },
33+
ref
34+
) => {
2435
return <div ref={ref} {...props} />;
2536
}
2637
);

packages/sdk-components-animation/src/animate-text.ws.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ export const meta: WsComponentMeta = {
2020

2121
export const propsMeta: WsComponentPropsMeta = {
2222
props,
23-
initialProps: ["charWindow", "easing"],
23+
initialProps: ["slidingWindow", "easing", "splitBy"],
2424
};

0 commit comments

Comments
 (0)