-
Notifications
You must be signed in to change notification settings - Fork 194
feat: add circular text #416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds a new CircularText React component (rotating characters arranged on a circle), a Storybook story for it, and an MDX documentation page. Files added: Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@animata/text/circular-text.tsx`:
- Around line 39-42: The Tailwind class in the className string of the
CircularText component is misspelled as "origins-center" so the transform-origin
isn't applied; update the className value (where cn(...) is called in
circular-text.tsx) to use "origin-center" instead of "origins-center" so the
element correctly uses center transform-origin while keeping the surrounding
classes and the cn(...) composition unchanged.
- Around line 47-61: The character positioning uses a tiny numeric offset;
replace the current offset logic in the characters.map block with a proper
radius-based translation: introduce a radius constant (e.g., radius) and build
transform as rotate(angle) translateX(radius) rotate(-angle) (so each character
is rotated into place around the circle but stays upright) by updating the
transform variable used in the span returned from characters.map; also correct
the Tailwind easing class name in className from ease-[cubic-bezier(0_0_0_1)] to
ease-[cubic-bezier(0,0,0,1)] so commas are used instead of underscores.
- Around line 26-36: The rotation MotionValue created in useMotionValue is never
updated by controls.start so rotation.get() always returns 0; fix by driving the
rotation value directly instead of only animating controls: replace the
controls.start call inside the useEffect with an animation that targets the
MotionValue (e.g. using animate(rotation, rotation.get() + 360, {
...createRotation(spinDuration, rotation.get()) })) or call controls.start and
also subscribe to the element's rotate updates (via onUpdate or controls.set) to
keep rotation in sync; update references to rotation, controls.start,
createRotation, spinDuration and characters accordingly so the "continue from
current position" logic uses the actual MotionValue value.
- Around line 6-15: The createRotation helper currently places invalid
transition keys `from` and `to` inside the transition object; update
createRotation so it returns an object separating the rotation animation target
and its transition (i.e., provide the rotate target values as animation props
like initial/animate or a rotate key with numeric start and end values, and put
only timing keys — duration, ease, repeat, type — inside a nested transition
object). Locate createRotation in circular-text.tsx and refactor its returned
structure so the rotation target values are not inside transition but are
applied via the component's initial/animate or a rotate animation target while
keeping duration/ease/repeat/type in the transition field.
🧹 Nitpick comments (1)
animata/text/circular-text.stories.tsx (1)
4-21: Consider adding argTypes and additional story variants.The story is functional but could be enhanced for better documentation and testing:
- Add
argTypesto provide better control descriptions in Storybook- Consider adding additional stories to showcase different
spinDurationvalues✨ Optional enhancement
const meta = { title: "Text/Circular Text", component: CircularText, parameters: { layout: "centered", }, tags: ["autodocs"], - argTypes: {}, + argTypes: { + text: { description: "Text to display around the circle" }, + spinDuration: { + description: "Duration in seconds for one full rotation", + control: { type: "number" }, + }, + className: { description: "Additional CSS classes" }, + }, } satisfies Meta<typeof CircularText>; export default meta; type Story = StoryObj<typeof meta>; export const Primary: Story = { args: { text: "CIRCULAR•TEXT•COMPONENT•", }, }; + +export const SlowSpin: Story = { + args: { + text: "SCROLL • EXPLORE • DISCOVER •", + spinDuration: 60, + }, +}; + +export const FastSpin: Story = { + args: { + text: "FAST • ROTATION •", + spinDuration: 5, + }, +};
|
🚀 Preview deployed to: https://e6cdb9e1.animata.pages.dev |
|
@P-Sanjana please review the comments |
|
🚀 Preview deployed to: https://c3881158.animata.pages.dev |
|
🚀 Preview deployed to: https://38d5526a.animata.pages.dev |
Summary
This PR introduces a reusable CircularText React component that renders text laid out along a circular path and smoothly rotates it using Framer Motion. The component is designed for interactive UI elements such as hero sections, loaders, badges, or call-to-action highlights.
Key Features
spinDurationprop and circle radius viaradiuspropclassNameuseMemoImplementation Details
CSSfor smooth, continuous rotationProps
Example Usage
Demo
Screen.Recording.2026-01-23.113217.mp4
Checklist
Summary by CodeRabbit
New Features
Storybook
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.