File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import CircularText from "@/animata/text/circular-text" ;
2+ import { Meta , StoryObj } from "@storybook/react" ;
3+
4+ const meta = {
5+ title : "Text/Circular Text" ,
6+ component : CircularText ,
7+ parameters : {
8+ layout : "centered" ,
9+ } ,
10+ tags : [ "autodocs" ] ,
11+ argTypes : { } ,
12+ } satisfies Meta < typeof CircularText > ;
13+
14+ export default meta ;
15+ type Story = StoryObj < typeof meta > ;
16+
17+ export const Primary : Story = {
18+ args : {
19+ text : "CIRCULAR•TEXT•COMPONENT•" ,
20+ } ,
21+ } ;
Original file line number Diff line number Diff line change 1+ import { useMemo } from "react" ;
2+ import { motion } from "framer-motion" ;
3+
4+ import { cn } from "@/lib/utils" ;
5+
6+ export default function CircularText ( {
7+ text,
8+ spinDuration = 30 ,
9+ radius = 5 ,
10+ className = "" ,
11+ } : {
12+ text : string ;
13+ spinDuration ?: number ;
14+ radius ?: number ;
15+ className ?: string ;
16+ } ) {
17+ const characters = useMemo ( ( ) => [ ...text ] , [ text ] ) ;
18+ return (
19+ < motion . div
20+ key = { spinDuration }
21+ className = { cn (
22+ "relative mx-auto flex h-[200px] w-[200px] origin-center cursor-pointer items-center justify-center rounded-full text-center font-bold text-foreground" ,
23+ className ,
24+ ) }
25+ initial = { { rotate : 0 } }
26+ animate = { { rotate : 360 } }
27+ transition = { {
28+ ease : "linear" ,
29+ duration : spinDuration ,
30+ repeat : Infinity ,
31+ } }
32+ >
33+ { characters . map ( ( char , index ) => {
34+ const angle = ( 360 / characters . length ) * index ;
35+ const transform = `rotate(${ angle } deg) translateY(-${ radius } px)` ;
36+ return (
37+ < span
38+ key = { `${ char } -${ index } ` }
39+ style = { { transform, WebkitTransform : transform } }
40+ className = "absolute inset-0 inline-block font-medium"
41+ >
42+ { char }
43+ </ span >
44+ ) ;
45+ } ) }
46+ </ motion . div >
47+ ) ;
48+ }
Original file line number Diff line number Diff line change 1+ ---
2+ title : Circular Text
3+ description : Displays text arranged in a rotating circular path with customizable speed.
4+ author : Sanj__P
5+ ---
6+
7+ <ComponentPreview name = " text-circular-text--docs" />
8+
9+ ## Installation
10+
11+ <Steps >
12+ <Step >Install dependencies</Step >
13+
14+ ``` bash
15+ npm install framer-motion
16+ ```
17+
18+ <Step >Run the following command</Step >
19+
20+ It will create a new file ` circular-text.tsx ` inside the ` components/animata/text ` directory.
21+
22+ ``` bash
23+ mkdir -p components/animata/text && touch components/animata/text/circular-text.tsx
24+ ```
25+
26+ <Step >Paste the code</Step >{ " " }
27+
28+ Open the newly created file and paste the following code:
29+
30+ ``` jsx file=<rootDir>/animata/text/circular-text.tsx
31+
32+ ```
33+
34+ </Steps >
35+
36+ ## Credits
37+
38+ Built by [ Sanjana Podduturi] ( https://github.com/P-Sanjana )
Original file line number Diff line number Diff line change 4646 "lodash.startcase" : " ^4.4.0" ,
4747 "lucide-react" : " ^0.390.0" ,
4848 "mdast-util-toc" : " ^7.1.0" ,
49- "next" : " 14.2.26 " ,
49+ "next" : " 14.2.35 " ,
5050 "next-contentlayer" : " ^0.3.4" ,
5151 "next-themes" : " ^0.3.0" ,
5252 "ora" : " ^8.0.1" ,
108108 "prettier" : " ^3.3.2" ,
109109 "prettier-plugin-tailwindcss" : " ^0.6.5" ,
110110 "react-docgen" : " ^7.0.3" ,
111- "storybook" : " ^8.1.6 " ,
111+ "storybook" : " ^8.6.15 " ,
112112 "storybook-dark-mode" : " ^4.0.1" ,
113113 "tailwindcss" : " ^3.4.1" ,
114114 "typescript" : " ^5" ,
115- "wrangler" : " ^3.79.0 "
115+ "wrangler" : " ^3.114.17 "
116116 },
117117 "packageManager" : " yarn@4.2.2" ,
118118 "lint-staged" : {
You can’t perform that action at this time.
0 commit comments