-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat]: New Component - Animated Scroll Progress (#177)
* feat: Added new Component - ScrollProgess * chore: Added credits section and changed the date in MDX page * fix: lint and mdx fix --------- Co-authored-by: Dipesh <dtamangt582@gmail.com> Co-authored-by: Arghya Das <arghyadasproject@gmail.com>
- Loading branch information
1 parent
e163f07
commit e1c6709
Showing
10 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,50 @@ | ||
--- | ||
title: Scroll Progress | ||
date: 2024-12-19 | ||
description: Animated Scroll Progress for your pages | ||
author: dipesh_the_dev | ||
published: true | ||
--- | ||
|
||
<ComponentPreview name="scroll-progress-demo" /> | ||
|
||
## Installation | ||
|
||
<Tabs defaultValue="cli"> | ||
<TabsList> | ||
<TabsTrigger value="cli">CLI</TabsTrigger> | ||
<TabsTrigger value="manual">Manual</TabsTrigger> | ||
</TabsList> | ||
<TabsContent value="cli"> | ||
|
||
```bash | ||
npx shadcn@latest add "https://magicui.design/r/scroll-progress" | ||
``` | ||
|
||
</TabsContent> | ||
|
||
<TabsContent value="manual"> | ||
|
||
<Steps> | ||
|
||
<Step>Copy and paste the following code into your project.</Step> | ||
|
||
<ComponentSource name="scroll-progress" /> | ||
|
||
</Steps> | ||
|
||
</TabsContent> | ||
|
||
</Tabs> | ||
|
||
## Props | ||
|
||
| Prop | Type | Description | Default | | ||
| --------- | ------ | --------------------------------------------- | ------- | | ||
| className | string | The class name to be applied to the component | - | | ||
|
||
The `ScrollProgress` component also accepts all properties of the `HTMLDivElement` type. | ||
|
||
## Credits | ||
|
||
- Credit to [dipesh_the_dev](https://twitter.com/dipesh_the_dev) |
This file contains 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
This file contains 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
This file contains 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,15 @@ | ||
{ | ||
"name": "scroll-progress", | ||
"type": "registry:ui", | ||
"dependencies": [ | ||
"framer-motion" | ||
], | ||
"files": [ | ||
{ | ||
"path": "magicui/scroll-progress.tsx", | ||
"content": "import { cn } from \"@/lib/utils\";\nimport { motion, useScroll, useSpring } from \"framer-motion\";\n\ninterface ScrollProgressProps {\n className?: string;\n}\n\nexport default function ScrollProgress({ className }: ScrollProgressProps) {\n const { scrollYProgress } = useScroll();\n\n const scaleX = useSpring(scrollYProgress, {\n stiffness: 200,\n damping: 50,\n restDelta: 0.001,\n });\n\n return (\n <motion.div\n className={cn(\n \"fixed inset-x-0 top-0 z-[1000] h-1 origin-left bg-gradient-to-r from-[#A97CF8] via-[#F38CB8] to-[#FDCC92]\",\n className,\n )}\n style={{\n scaleX,\n }}\n />\n );\n}\n", | ||
"type": "registry:ui", | ||
"target": "" | ||
} | ||
] | ||
} |
This file contains 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,20 @@ | ||
import ScrollProgress from "@/registry/default/magicui/scroll-progress"; | ||
|
||
const ScrollProgressDemo = () => { | ||
return ( | ||
<div className="z-10 rounded-lg border border-gray-200 bg-white p-4"> | ||
<ScrollProgress className="top-[65px]" /> | ||
<h2 className="pb-4 font-bold"> | ||
Note: The scroll progress is shown below the navbar of the page. | ||
</h2> | ||
<p className="pb-4"> | ||
Magic UI is a collection of re-usable components that you can copy and | ||
paste into your web apps. It primarily features components, blocks, and | ||
templates geared towards creating landing pages and user-facing | ||
marketing materials. | ||
</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ScrollProgressDemo; |
This file contains 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,28 @@ | ||
import { cn } from "@/lib/utils"; | ||
import { motion, useScroll, useSpring } from "framer-motion"; | ||
|
||
interface ScrollProgressProps { | ||
className?: string; | ||
} | ||
|
||
export default function ScrollProgress({ className }: ScrollProgressProps) { | ||
const { scrollYProgress } = useScroll(); | ||
|
||
const scaleX = useSpring(scrollYProgress, { | ||
stiffness: 200, | ||
damping: 50, | ||
restDelta: 0.001, | ||
}); | ||
|
||
return ( | ||
<motion.div | ||
className={cn( | ||
"fixed inset-x-0 top-0 z-[1000] h-1 origin-left bg-gradient-to-r from-[#A97CF8] via-[#F38CB8] to-[#FDCC92]", | ||
className, | ||
)} | ||
style={{ | ||
scaleX, | ||
}} | ||
/> | ||
); | ||
} |
This file contains 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
This file contains 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