diff --git a/animata/text/jumping-text-instagram.stories.tsx b/animata/text/jumping-text-instagram.stories.tsx new file mode 100644 index 00000000..7d824b57 --- /dev/null +++ b/animata/text/jumping-text-instagram.stories.tsx @@ -0,0 +1,21 @@ +import JumpingTextInstagram from "@/animata/text/jumping-text-instagram"; +import { Meta, StoryObj } from "@storybook/react"; + +const meta = { + title: "Text/Jumping Text Instagram", + component: JumpingTextInstagram, + parameters: { + layout: "centered", + }, + tags: ["autodocs"], + argTypes: {}, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Primary: Story = { + args: { + text: "This is a jumping text effect", + }, +}; diff --git a/animata/text/jumping-text-instagram.tsx b/animata/text/jumping-text-instagram.tsx new file mode 100644 index 00000000..75c09f46 --- /dev/null +++ b/animata/text/jumping-text-instagram.tsx @@ -0,0 +1,51 @@ +import { motion } from "framer-motion"; + +const splitText = (text: string, word = false) => { + if (word) { + return String(text).split(/(?:\b)/u); + } + return String(text).split(/(?:)/u); +}; + +export default function JumpingTextInstagram({ + text = "This is a jumping text effect", + mode = "word", + className, +}: { + text: string; + className?: string; + mode?: "word" | "character"; +}) { + const isWordMode = mode === "word"; + const nodes = splitText(text, isWordMode); + return ( +
+ {nodes.map((node, index) => ( + + {node === " " ? "\u00A0" : node} + + ))} + {text} +
+ ); +} diff --git a/animata/text/text-explode-imessage.tsx b/animata/text/text-explode-imessage.tsx index df4ee39b..45fdfbd4 100644 --- a/animata/text/text-explode-imessage.tsx +++ b/animata/text/text-explode-imessage.tsx @@ -166,6 +166,7 @@ export default function TextExplodeIMessage({ {char === " " ? "\u00A0" : char} ))} + {text} ); } diff --git a/content/docs/text/jumping-text-instagram.mdx b/content/docs/text/jumping-text-instagram.mdx new file mode 100644 index 00000000..a7771da4 --- /dev/null +++ b/content/docs/text/jumping-text-instagram.mdx @@ -0,0 +1,38 @@ +--- +title: Jumping Text (Instagram) +description: Jumping text effect similar to the one seen in Instagram's text effects +author: harimanok_ +--- + + + +## Installation + + +Install dependencies + +```bash +npm install framer-motion +``` + +Run the following command + +It will create a new file `jumping-text-instagram.tsx` inside the `components/animata/text` directory. + +```bash +mkdir -p components/animata/text && touch components/animata/text/jumping-text-instagram.tsx +``` + +Paste the code{" "} + +Open the newly created file and paste the following code: + +```jsx file=/animata/text/jumping-text-instagram.tsx + +``` + + + +## Credits + +Built by [hari](https://github.com/hari)