-
Notifications
You must be signed in to change notification settings - Fork 196
release circular text #419
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1291701
chore(deps): bump undici from 5.28.5 to 5.29.0 in the npm_and_yarn gr…
dependabot[bot] 2f6ebd4
chore(deps): bump the npm_and_yarn group across 1 directory with 3 up…
dependabot[bot] a90caa0
chore(deps): bump the npm_and_yarn group across 1 directory with 4 up…
dependabot[bot] 5e66949
feat: add circular text (#416)
P-Sanjana dbb676a
chore(deps): bump the npm_and_yarn group across 1 directory with 8 up…
dependabot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import CircularText from "@/animata/text/circular-text"; | ||
| import { Meta, StoryObj } from "@storybook/react"; | ||
|
|
||
| const meta = { | ||
| title: "Text/Circular Text", | ||
| component: CircularText, | ||
| parameters: { | ||
| layout: "centered", | ||
| }, | ||
| tags: ["autodocs"], | ||
| argTypes: {}, | ||
| } satisfies Meta<typeof CircularText>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Primary: Story = { | ||
| args: { | ||
| text: "CIRCULAR•TEXT•COMPONENT•", | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { useMemo } from "react"; | ||
| import { motion } from "framer-motion"; | ||
|
|
||
| import { cn } from "@/lib/utils"; | ||
|
|
||
| export default function CircularText({ | ||
| text, | ||
| spinDuration = 30, | ||
| radius = 5, | ||
| className = "", | ||
| }: { | ||
| text: string; | ||
| spinDuration?: number; | ||
| radius?: number; | ||
| className?: string; | ||
| }) { | ||
| const characters = useMemo(() => [...text], [text]); | ||
| return ( | ||
| <motion.div | ||
| key={spinDuration} | ||
| className={cn( | ||
| "relative mx-auto flex h-[200px] w-[200px] origin-center cursor-pointer items-center justify-center rounded-full text-center font-bold text-foreground", | ||
| className, | ||
| )} | ||
| initial={{ rotate: 0 }} | ||
| animate={{ rotate: 360 }} | ||
| transition={{ | ||
| ease: "linear", | ||
| duration: spinDuration, | ||
| repeat: Infinity, | ||
| }} | ||
| > | ||
| {characters.map((char, index) => { | ||
| const angle = (360 / characters.length) * index; | ||
| const transform = `rotate(${angle}deg) translateY(-${radius}px)`; | ||
| return ( | ||
| <span | ||
| key={`${char}-${index}`} | ||
| style={{ transform, WebkitTransform: transform }} | ||
| className="absolute inset-0 inline-block font-medium" | ||
| > | ||
| {char} | ||
| </span> | ||
| ); | ||
| })} | ||
| </motion.div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| --- | ||
| title: Circular Text | ||
| description: Displays text arranged in a rotating circular path with customizable speed. | ||
| author: Sanj__P | ||
| --- | ||
|
|
||
| <ComponentPreview name="text-circular-text--docs" /> | ||
|
|
||
| ## Installation | ||
|
|
||
| <Steps> | ||
| <Step>Install dependencies</Step> | ||
|
|
||
| ```bash | ||
| npm install framer-motion | ||
| ``` | ||
|
|
||
| <Step>Run the following command</Step> | ||
|
|
||
| It will create a new file `circular-text.tsx` inside the `components/animata/text` directory. | ||
|
|
||
| ```bash | ||
| mkdir -p components/animata/text && touch components/animata/text/circular-text.tsx | ||
| ``` | ||
|
|
||
| <Step>Paste the code</Step>{" "} | ||
|
|
||
| Open the newly created file and paste the following code: | ||
|
|
||
| ```jsx file=<rootDir>/animata/text/circular-text.tsx | ||
|
|
||
| ``` | ||
|
|
||
| </Steps> | ||
|
|
||
| ## Credits | ||
|
|
||
| Built by [Sanjana Podduturi](https://github.com/P-Sanjana) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Default radius value too small for visible circle
High Severity
The default
radius = 5is far too small for the 200x200px container. WithtranslateY(-5px), all characters will be positioned only 5 pixels from the center, causing them to overlap and the circular text effect to be essentially invisible. For a 200px container, the radius should be closer to 80-100px to properly display text in a circle.