Skip to content

Commit

Permalink
feat: add sliding arrow button component (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfofdalalst authored Oct 17, 2024
1 parent 85058d8 commit f0323f5
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
22 changes: 22 additions & 0 deletions animata/button/slide-arrow-button.stories.tsx
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",
},
};
33 changes: 33 additions & 0 deletions animata/button/slide-arrow-button.tsx
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>
);
}
9 changes: 9 additions & 0 deletions content/docs/button/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ExternalLinkButton from "@/animata/button/external-link-button";
import AlgoliaButtonWhite from "@/animata/button/algolia-white-button";
import AlgoliaButtonBlue from "@/animata/button/algolia-blue-button";
import Duolingo from "@/animata/button/duolingo";
import SlideArrowButton from "@/animata/button/slide-arrow-button";

<ComponentList>
<ComponentListItem copyId="work-button">
Expand Down Expand Up @@ -100,4 +101,12 @@ import Duolingo from "@/animata/button/duolingo";
````

</ComponentListItem>

<ComponentListItem copyId="slide-arrow-button" lazy>
<SlideArrowButton text="Get Started"/>
```tsx file=<rootDir>/animata/button/slide-arrow-button.tsx copyId="slide-arrow-button"

````

</ComponentListItem>
</ComponentList>
39 changes: 39 additions & 0 deletions content/docs/button/slide-arrow-button.mdx
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)

0 comments on commit f0323f5

Please sign in to comment.