Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
experimental: Text Animation storybook (#4938)
Ivan Starkov70d51221b364
diff --git a/apps/builder/app/builder/features/components/components.tsx b/apps/builder/app/builder/features/components/components.tsxindex b80ee79465..b10751aa8e 100644--- a/apps/builder/app/builder/features/components/components.tsx+++ b/apps/builder/app/builder/features/components/components.tsx@@ -66,6 +66,12 @@ const $metas = computed(continue;}+ if (+ isFeatureEnabled("animation") === false &&+ name.endsWith(":AnimateText")+ ) {+ continue;+ }// only set available components from component metaavailableComponents.add(name);if (diff --git a/packages/sdk-components-animation/package.json b/packages/sdk-components-animation/package.jsonindex b7b01681de..0413b93d73 100644--- a/packages/sdk-components-animation/package.json+++ b/packages/sdk-components-animation/package.json@@ -59,8 +59,10 @@"@webstudio-is/react-sdk": "workspace:*","@webstudio-is/sdk": "workspace:*","change-case": "^5.4.4",+ "nanostores": "^0.11.3","react-error-boundary": "^5.0.0",- "scroll-timeline-polyfill": "^1.1.0"+ "scroll-timeline-polyfill": "^1.1.0",+ "shallow-equal": "^3.1.0"},"devDependencies": {"@types/react": "^18.2.70",diff --git a/packages/sdk-components-animation/private-src b/packages/sdk-components-animation/private-srcindex c1053aa05f..45acad5a6c 160000--- a/packages/sdk-components-animation/private-src+++ b/packages/sdk-components-animation/private-src@@ -1 +1 @@-Subproject commit c1053aa05f2d5986e3c75a3061281dc8e282ce6f+Subproject commit 45acad5a6caf111e92f62d93ac0cd07310a82e6ddiff --git a/packages/sdk-components-animation/src/__generated__/animate-children.props.ts b/packages/sdk-components-animation/src/__generated__/animate-children.props.tsnew file mode 100644index 0000000000..fdadfcf1d2--- /dev/null+++ b/packages/sdk-components-animation/src/__generated__/animate-children.props.ts@@ -0,0 +1,10 @@+import type { PropMeta } from "@webstudio-is/sdk";++export const props: Record<string, PropMeta> = {+ debug: {+ required: false,+ control: "boolean",+ type: "boolean",+ defaultValue: false,+ },+};diff --git a/packages/sdk-components-animation/src/__generated__/animate-text.props.ts b/packages/sdk-components-animation/src/__generated__/animate-text.props.tsnew file mode 100644index 0000000000..d6479f71fe--- /dev/null+++ b/packages/sdk-components-animation/src/__generated__/animate-text.props.ts@@ -0,0 +1,22 @@+import type { PropMeta } from "@webstudio-is/sdk";++export const props: Record<string, PropMeta> = {+ charWindow: { required: true, control: "number", type: "number" },+ easing: {+ required: true,+ control: "select",+ type: "string",+ options: [+ "linear",+ "easeIn",+ "easeInCubic",+ "easeInQuart",+ "easeOut",+ "easeOutCubic",+ "easeOutQuart",+ "ease",+ "easeInOutCubic",+ "easeInOutQuart",+ ],+ },+};diff --git a/packages/sdk-components-animation/src/scroll.ws.ts b/packages/sdk-components-animation/src/animate-children.ws.tssimilarity index 100%rename from packages/sdk-components-animation/src/scroll.ws.tsrename to packages/sdk-components-animation/src/animate-children.ws.tsdiff --git a/packages/sdk-components-animation/src/animate-text.tsx b/packages/sdk-components-animation/src/animate-text.tsxnew file mode 100644index 0000000000..6721483b5f--- /dev/null+++ b/packages/sdk-components-animation/src/animate-text.tsx@@ -0,0 +1,29 @@+import { forwardRef, type ElementRef } from "react";++const easings = {+ linear: true,+ easeIn: true,+ easeInCubic: true,+ easeInQuart: true,+ easeOut: true,+ easeOutCubic: true,+ easeOutQuart: true,+ ease: true,+ easeInOutCubic: true,+ easeInOutQuart: true,+};++type AnimateChildrenProps = {+ charWindow: number;+ easing: keyof typeof easings;+ children: React.ReactNode;+};++export const AnimateText = forwardRef<ElementRef<"div">, AnimateChildrenProps>(+ ({ charWindow: _, easing: __, ...props }, ref) => {+ return <div ref={ref} {...props} />;+ }+);++const displayName = "AnimateText";+AnimateText.displayName = displayName;diff --git a/packages/sdk-components-animation/src/animate-text.ws.ts b/packages/sdk-components-animation/src/animate-text.ws.tsnew file mode 100644index 0000000000..833eb573bd--- /dev/null+++ b/packages/sdk-components-animation/src/animate-text.ws.ts@@ -0,0 +1,17 @@+import { TextIcon } from "@webstudio-is/icons/svg";+import type { WsComponentMeta, WsComponentPropsMeta } from "@webstudio-is/sdk";+import { props } from "./__generated__/animate-text.props";++export const meta: WsComponentMeta = {+ category: "general",+ type: "container",+ description: "Animate Text",+ icon: TextIcon,+ order: 6,+ label: "Animate Text",+};++export const propsMeta: WsComponentPropsMeta = {+ props,+ initialProps: ["charWindow", "easing"],+};diff --git a/packages/sdk-components-animation/src/components.ts b/packages/sdk-components-animation/src/components.tsindex ab47b1c289..ee855f0ad1 100644--- a/packages/sdk-components-animation/src/components.ts+++ b/packages/sdk-components-animation/src/components.ts@@ -1 +1,2 @@export { AnimateChildren } from "./animate-children";+export { AnimateText } from "./animate-text";diff --git a/packages/sdk-components-animation/src/metas.ts b/packages/sdk-components-animation/src/metas.tsindex 3f70a4394c..1f24252cfc 100644--- a/packages/sdk-components-animation/src/metas.ts+++ b/packages/sdk-components-animation/src/metas.ts@@ -1 +1,2 @@-export { meta as AnimateChildren } from "./scroll.ws";+export { meta as AnimateChildren } from "./animate-children.ws";+export { meta as AnimateText } from "./animate-text.ws";diff --git a/packages/sdk-components-animation/src/props.ts b/packages/sdk-components-animation/src/props.tsindex 677fd7a91a..9f32425fcc 100644--- a/packages/sdk-components-animation/src/props.ts+++ b/packages/sdk-components-animation/src/props.ts@@ -1 +1,2 @@-export { propsMeta as AnimateChildren } from "./scroll.ws";+export { propsMeta as AnimateChildren } from "./animate-children.ws";+export { propsMeta as AnimateText } from "./animate-text.ws";diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 293a3b1e73..c3574c2c75 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1865,12 +1865,18 @@ importers:change-case:specifier: ^5.4.4version: 5.4.4+ nanostores:+ specifier: ^0.11.3+ version: 0.11.3react-error-boundary:specifier: ^5.0.0version: 5.0.0([email protected])scroll-timeline-polyfill:specifier: ^1.1.0version: 1.1.0(patch_hash=i4g3vdpump4efgy2hri5l5rsfm)+ shallow-equal:+ specifier: ^3.1.0+ version: 3.1.0devDependencies:'@types/react':specifier: ^18.2.70