Skip to content

Commit 8bc2ec8

Browse files
committed
docs: add sparkle button
1 parent 297754c commit 8bc2ec8

File tree

14 files changed

+50
-117
lines changed

14 files changed

+50
-117
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Sparkle button
33
description: A beautiful sparkle animation button
4-
thumbnail: https://h2rsi9anqnqbkvkf.public.blob.vercel-storage.com/EQocBJl-zK05DNFBYpzBdrpZUABq1OfNjUwYtz.mp4
4+
video: /previews/components/sparkle-button.mp4
55
---
66

77
<ComponentPreview name="components/sparkle-button/demo" />

content/components/marketing/hero-section.mdx

-7
This file was deleted.

content/pages/pricing.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Pricing page
3-
thumbnail: /images/lib/pages/pricing.png
3+
thumbnail: /previews/pages/pricing.png
44
---
55

66
<ComponentPreview name="pages/pricing" aspect="page" centered={false} />

content/templates/taxonomy.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Taxonomy
33
description: An open source application built using the new router, server components and everything new in Next.js 13.
4-
thumbnail: /images/lib/templates/taxonomy.png
4+
thumbnail: /previews/templates/taxonomy.png
55
keywords:
66
- Next.js
77
- Stripe

content/templates/turbocharger.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Turbocharger
33
description: A SaaS starter built with Turborepo, Next.js, TailwindCSS, Prisma, and Stripe.
4-
thumbnail: /images/lib/templates/turbocharger.png
4+
thumbnail: /previews/templates/turbocharger.png
55
keywords:
66
- Turborepo
77
- Next.js
-569 KB
Binary file not shown.
147 KB
Binary file not shown.

src/app/[...slug]/page.tsx

+14-16
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,20 @@ const DataGrid = ({ type, items }: { type: string; items: Item[] }) => {
148148
}
149149
)}
150150
>
151-
{item.metadata.thumbnail ? (
152-
item.metadata.thumbnail.includes("mp4") ? (
153-
<video
154-
src={item.metadata.thumbnail}
155-
muted
156-
loop
157-
autoPlay
158-
className="opacity-90 duration-150 group-hover:opacity-100"
159-
/>
160-
) : (
161-
<img
162-
src={item.metadata.thumbnail}
163-
alt={item.metadata.title}
164-
className="opacity-90 duration-150 group-hover:opacity-100"
165-
/>
166-
)
151+
{item.metadata.video ? (
152+
<video
153+
src={item.metadata.video}
154+
muted
155+
loop
156+
autoPlay
157+
className="opacity-90 duration-150 group-hover:opacity-100"
158+
/>
159+
) : item.metadata.thumbnail ? (
160+
<img
161+
src={item.metadata.thumbnail}
162+
alt={item.metadata.title}
163+
className="opacity-90 duration-150 group-hover:opacity-100"
164+
/>
167165
) : (
168166
<p className="text-muted-foreground">No thumbnail</p>
169167
)}

src/autogenerated/previews.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,7 @@ export const previews = {
88
code: [
99
{
1010
title: "demo.tsx",
11-
code: 'import { Button } from "@/lib/components/sparkle-button";\r\n\r\nexport default function SparkleButton() {\r\n return <Button variant="sparkle">Get started</Button>;\r\n}\r\n',
12-
},
13-
],
14-
},
15-
"components/hero-section": {
16-
component: React.lazy<React.FC>(() => import("@/lib/components/hero-section")),
17-
code: [
18-
{
19-
title: "hero-section.tsx",
20-
code: 'import React from "react";\r\nimport Link from "next/link";\r\nimport { ArrowRightIcon, SearchIcon, SparklesIcon } from "lucide-react";\r\nimport { badgeVariants } from "@/components/ui/badge";\r\nimport { Button } from "@/components/ui/button";\r\nimport { cn } from "@/utils/classes";\r\n\r\nexport default function Demo() {\r\n return (\r\n <section>\r\n <Link\r\n href="https://github.com/mehdibha/rcopy"\r\n target="_blank"\r\n className={cn(\r\n badgeVariants({ variant: "outline", size: "md" }),\r\n "cursor-pointer space-x-2 font-mono delay-75 duration-200 hover:bg-secondary"\r\n )}\r\n >\r\n <SparklesIcon size={18} />\r\n <span>Star us on GitHub</span> <ArrowRightIcon size={15} />\r\n </Link>\r\n <h1 className="mt-4 max-w-2xl font-display text-5xl font-bold leading-tight">\r\n Copy and paste components for you React App\r\n </h1>\r\n <h2 className="text-md mt-6 text-muted-foreground md:text-lg lg:text-xl">\r\n Copy the code, paste it, customize it, own it. Done.\r\n </h2>\r\n <div className="mt-10 flex space-x-4">\r\n <Button size="lg" variant="default">\r\n Explore components\r\n </Button>\r\n <Button size="lg" variant="outline">\r\n <SearchIcon size={20} className="mr-2" />\r\n Quick search\r\n </Button>\r\n </div>\r\n </section>\r\n );\r\n}\r\n',
11+
code: 'import { SparkleButton } from "@/lib/components/sparkle-button";\r\n\r\nexport default function Demo() {\r\n return <SparkleButton size="lg">Get started</SparkleButton>;\r\n}\r\n',
2112
},
2213
],
2314
},
@@ -48,7 +39,7 @@ export const previews = {
4839
},
4940
{
5041
title: "cta.tsx",
51-
code: 'import React from "react";\r\nimport Link from "next/link";\r\nimport { Button } from "@/components/ui/button";\r\nimport { cn } from "@/utils/classes";\r\n\r\ninterface CallToActionProps {\r\n headline: string;\r\n subheadline: string;\r\n cta: {\r\n label: string;\r\n href: string;\r\n };\r\n className?: string;\r\n}\r\n\r\nexport const CallToAction = (props: CallToActionProps) => {\r\n const { headline, subheadline, cta, className } = props;\r\n return (\r\n <section className={cn("mx-auto max-w-xl text-center", className)}>\r\n <h2 className="font-display text-4xl font-semibold tracking-tighter sm:text-5xl">{headline}</h2>\r\n <p className="mt-4 text-muted-foreground">{subheadline}</p>\r\n <Button asChild size="lg" className="mt-8">\r\n <Link href={cta.href}>{cta.label}</Link>\r\n </Button>\r\n </section>\r\n );\r\n};\r\n',
42+
code: 'import React from "react";\r\nimport Link from "next/link";\r\nimport { Button } from "@/components/ui/button";\r\nimport { cn } from "@/utils/classes";\r\n\r\ninterface CallToActionProps {\r\n headline: string;\r\n subheadline: string;\r\n cta: {\r\n label: string;\r\n href: string;\r\n };\r\n className?: string;\r\n}\r\n\r\nexport const CallToAction = (props: CallToActionProps) => {\r\n const { headline, subheadline, cta, className } = props;\r\n return (\r\n <section className={cn("mx-auto max-w-xl text-center", className)}>\r\n <h2 className="font-display text-4xl font-semibold tracking-tighter sm:text-5xl">\r\n {headline}\r\n </h2>\r\n <p className="mt-4 text-muted-foreground">{subheadline}</p>\r\n <Button asChild size="lg" className="mt-8">\r\n <Link href={cta.href}>{cta.label}</Link>\r\n </Button>\r\n </section>\r\n );\r\n};\r\n',
5243
},
5344
{
5445
title: "faq.tsx",

src/lib/components/hero-section.tsx

-39
This file was deleted.
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Button } from "@/lib/components/sparkle-button";
1+
import { SparkleButton } from "@/lib/components/sparkle-button";
22

3-
export default function SparkleButton() {
4-
return <Button variant="sparkle">Get started</Button>;
3+
export default function Demo() {
4+
return <SparkleButton size="lg">Get started</SparkleButton>;
55
}

src/lib/components/sparkle-button/index.tsx

+13-37
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import { Slot } from "@radix-ui/react-slot";
33
import { type VariantProps, cva, cn } from "@/utils/classes";
44

55
const buttonVariants = cva(
6-
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-80",
6+
"group relative grid overflow-hidden duration-300 inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-80 ",
77
{
88
variants: {
9-
variant: {
10-
sparkle: "",
11-
},
129
size: {
1310
default: "h-10 px-4 py-2",
1411
sm: "h-9 rounded-md px-3",
@@ -17,7 +14,6 @@ const buttonVariants = cva(
1714
},
1815
},
1916
defaultVariants: {
20-
variant: "sparkle",
2117
size: "default",
2218
},
2319
}
@@ -29,44 +25,24 @@ export interface ButtonProps
2925
asChild?: boolean;
3026
}
3127

32-
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
33-
({ className, variant, size, asChild = false, ...props }, ref) => {
28+
const SparkleButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
29+
({ className, size, asChild = false, ...props }, ref) => {
3430
const Comp = asChild ? Slot : "button";
35-
if (variant === "sparkle") {
36-
return (
37-
<button
38-
className={cn(
39-
"group relative grid overflow-hidden rounded-full duration-300",
40-
buttonVariants({ size, className })
41-
)}
42-
>
43-
<span>
44-
<span
45-
className={cn(
46-
"spark mask-gradient animate-flip before:animate-rotate absolute inset-0 h-[100%] w-[100%] overflow-hidden rounded-lg [mask:linear-gradient(white,_transparent_50%)] before:absolute before:aspect-square before:w-[200%] before:rotate-[-90deg] before:bg-[conic-gradient(from_0deg,transparent_0_340deg,white_360deg)] before:content-[''] before:[inset:0_auto_auto_50%] before:[translate:-50%_-15%]",
47-
{ "rounded-full": size === "sm" }
48-
)}
49-
/>
50-
</span>
31+
return (
32+
<Comp ref={ref} className={cn(buttonVariants({ size }), className)}>
33+
<span>
5134
<span
5235
className={cn(
53-
"backdrop absolute inset-[1px] rounded-md bg-secondary transition-colors duration-200 group-hover:bg-primary",
54-
{ "rounded-full": size === "sm" }
36+
"absolute inset-0 h-[100%] w-[100%] animate-flip overflow-hidden rounded-lg [mask:linear-gradient(white,_transparent_50%)] before:absolute before:aspect-square before:w-[200%] before:rotate-[-90deg] before:animate-rotate before:bg-[conic-gradient(from_0deg,transparent_0_340deg,white_360deg)] before:content-[''] before:[inset:0_auto_auto_50%] before:[translate:-50%_-15%]"
5537
)}
5638
/>
57-
<span className="z-10">{props.children}</span>
58-
</button>
59-
);
60-
}
61-
return (
62-
<Comp
63-
className={cn(buttonVariants({ variant, size, className }))}
64-
ref={ref}
65-
{...props}
66-
/>
39+
</span>
40+
<span className="backdrop absolute inset-[1px] rounded-md bg-secondary transition-colors duration-200" />
41+
<span className="z-10">{props.children}</span>
42+
</Comp>
6743
);
6844
}
6945
);
70-
Button.displayName = "Button";
46+
SparkleButton.displayName = "Button";
7147

72-
export { Button, buttonVariants };
48+
export { SparkleButton };

src/utils/docs.ts

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface DocFrontmatter {
1010
title: string;
1111
description?: string;
1212
thumbnail?: string;
13+
video?: string;
1314
keywords?: string[];
1415
externalLink?: string;
1516
}
@@ -20,6 +21,7 @@ export interface DocMetadata {
2021
breadcrumbs: { label: string; href: string }[];
2122
description?: string;
2223
thumbnail?: string;
24+
video?: string;
2325
}
2426

2527
export interface Category {

tailwind.config.ts

+12
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ const config = {
151151
opacity: "0",
152152
},
153153
},
154+
flip: {
155+
to: {
156+
transform: "rotate(360deg)",
157+
},
158+
},
159+
rotate: {
160+
to: {
161+
transform: "rotate(90deg)",
162+
},
163+
},
154164
},
155165
animation: {
156166
"accordion-down": "accordion-down 0.2s ease-out",
@@ -161,6 +171,8 @@ const config = {
161171
"gradient-foreground-2": "gradient-foreground-2 8s infinite",
162172
"gradient-background-3": "gradient-background-3 8s infinite",
163173
"gradient-foreground-3": "gradient-foreground-3 8s infinite",
174+
flip: "flip 6s infinite steps(2, end)",
175+
rotate: "rotate 3s linear infinite both",
164176
},
165177
},
166178
},

0 commit comments

Comments
 (0)