-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sliding arrow button component (#369)
- Loading branch information
1 parent
85058d8
commit f0323f5
Showing
4 changed files
with
103 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import SlideArrowButton from "@/animata/button/slide-arrow-button"; | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
const meta = { | ||
title: "Button/Slide Arrow Button", | ||
component: SlideArrowButton, | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
tags: ["autodocs"], | ||
argTypes: {}, | ||
} satisfies Meta<typeof SlideArrowButton>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
text: "Get Started", | ||
primaryColor: "#6f3cff", | ||
}, | ||
}; |
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,33 @@ | ||
import React from "react"; | ||
import { ArrowRight } from "lucide-react"; | ||
|
||
interface SlideArrowButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { | ||
text?: string; | ||
primaryColor?: string; | ||
} | ||
|
||
export default function SlideArrowButton({ | ||
text = "Get Started", | ||
primaryColor = "#6f3cff", | ||
className = "", | ||
...props | ||
}: SlideArrowButtonProps) { | ||
return ( | ||
<button | ||
className={`group relative rounded-full border border-white bg-white p-2 text-xl font-semibold ${className}`} | ||
{...props} | ||
> | ||
<div | ||
className="absolute left-0 top-0 flex h-full w-11 items-center justify-end rounded-full transition-all duration-200 ease-in-out group-hover:w-full" | ||
style={{ backgroundColor: primaryColor }} | ||
> | ||
<span className="mr-3 text-white transition-all duration-200 ease-in-out"> | ||
<ArrowRight size={20} /> | ||
</span> | ||
</div> | ||
<span className="relative left-4 z-10 whitespace-nowrap px-8 font-semibold text-black transition-all duration-200 ease-in-out group-hover:-left-3 group-hover:text-white"> | ||
{text} | ||
</span> | ||
</button> | ||
); | ||
} |
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,39 @@ | ||
--- | ||
title: Slide Arrow Button | ||
description: An arrow button which slides on hover | ||
author: wolfofdalalst | ||
labels: ["requires interaction", "hover"] | ||
--- | ||
|
||
<ComponentPreview name="button-slide-arrow-button--docs" /> | ||
|
||
## Installation | ||
|
||
<Steps> | ||
<Step>Install dependencies</Step> | ||
|
||
```bash | ||
npm install lucide-react | ||
``` | ||
|
||
<Step>Run the following command</Step> | ||
|
||
It will create a new file `slide-arrow-button.tsx` inside the `components/animata/button` directory. | ||
|
||
```bash | ||
mkdir -p components/animata/button && touch components/animata/button/slide-arrow-button.tsx | ||
``` | ||
|
||
<Step>Paste the code</Step>{" "} | ||
|
||
Open the newly created file and paste the following code: | ||
|
||
```jsx file=<rootDir>/animata/button/slide-arrow-button.tsx | ||
|
||
``` | ||
|
||
</Steps> | ||
|
||
## Credits | ||
|
||
Built by [Ayush Gupta](https://github.com/wolfofdalalst) |