From 14b9590b727cc70b737a0123e4572cb970820814 Mon Sep 17 00:00:00 2001 From: anibal-alpizar Date: Mon, 20 May 2024 14:58:35 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Open=20in=20new=20tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/card-form.tsx | 49 +++++++++++++++++++++++------------- src/components/ui/badge.tsx | 36 ++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 src/components/ui/badge.tsx diff --git a/src/components/card-form.tsx b/src/components/card-form.tsx index 19a5822..e7d0f5d 100644 --- a/src/components/card-form.tsx +++ b/src/components/card-form.tsx @@ -1,6 +1,7 @@ "use client"; import { useLink } from "@/app/hooks/useLink"; +import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, @@ -10,14 +11,15 @@ import { CardHeader, CardTitle, } from "@/components/ui/card"; -import { Switch } from "@/components/ui/switch"; import { useToast } from "@/components/ui/use-toast"; import { cn } from "@/lib/utils"; import { isValidHttpUrl as validateUrl } from "@/lib/validation"; import { ToastAction } from "@radix-ui/react-toast"; -import { BellRing, Check } from "lucide-react"; +import { Check } from "lucide-react"; import * as React from "react"; import { AiOutlineLoading3Quarters } from "react-icons/ai"; +import { MdOutlineOpenInNew } from "react-icons/md"; + import { Input } from "./ui/input"; type CardProps = React.ComponentProps; @@ -119,28 +121,41 @@ export function CardDemo({ className, ...props }: CardProps) { onChange={(e) => setOriginalUrl(e.target.value)} /> - {/* -
- -
-

Copy to clipboard

-
- -
-
*/} + + + {shortenedLink ? ( + + + Open in new tab + + + + ) : ( + +

+ Open in new tab + +

+
+ )} +
); diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx new file mode 100644 index 0000000..9ec9a1a --- /dev/null +++ b/src/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 };