From de4521f9f95006823285ce84067511fd497be4a3 Mon Sep 17 00:00:00 2001 From: Jann Idar Hillestad Date: Mon, 29 Jul 2024 23:56:20 +0200 Subject: [PATCH] Stage 20: Setup tags --- components/ui/badge.tsx | 36 ++++++++++++++++++++++++++++++++++++ package-lock.json | 2 +- package.json | 1 + velite.config.ts | 1 + 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 components/ui/badge.tsx diff --git a/components/ui/badge.tsx b/components/ui/badge.tsx new file mode 100644 index 0000000..f000e3e --- /dev/null +++ b/components/ui/badge.tsx @@ -0,0 +1,36 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const badgeVariants = cva( + "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", + secondary: + "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", + destructive: + "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", + outline: "text-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +export interface BadgeProps + extends React.HTMLAttributes, + VariantProps {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ( +
+ ) +} + +export { Badge, badgeVariants } diff --git a/package-lock.json b/package-lock.json index 8215f83..8ef84c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@radix-ui/react-slot": "^1.1.0", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", + "github-slugger": "^2.0.0", "lucide-react": "^0.408.0", "next": "14.2.5", "next-themes": "^0.3.0", @@ -4378,7 +4379,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz", "integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==", - "dev": true, "license": "ISC" }, "node_modules/glob": { diff --git a/package.json b/package.json index 6eda97f..89d7dfa 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@radix-ui/react-slot": "^1.1.0", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", + "github-slugger": "^2.0.0", "lucide-react": "^0.408.0", "next": "14.2.5", "next-themes": "^0.3.0", diff --git a/velite.config.ts b/velite.config.ts index 90d4cd0..d4f59b2 100644 --- a/velite.config.ts +++ b/velite.config.ts @@ -18,6 +18,7 @@ const posts = defineCollection({ description: s.string().max(999).optional(), date: s.isodate(), published: s.boolean().default(true), + tags: s.array(s.string()).optional(), body: s.mdx(), }) .transform(computedFields),