Skip to content

Commit

Permalink
chore: merge main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Nov 19, 2024
2 parents 597a7dc + c42fea7 commit 64859bd
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 1 deletion.
35 changes: 35 additions & 0 deletions src/app/components/ui/Badge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { type VariantProps, cva } from "class-variance-authority";
import { cn } from "lib/cn";
import { type ElementRef, type HTMLAttributes, forwardRef } from "react";

export const badgeVariants = cva(
"inline-flex items-center rounded-md px-2 transition-colors focus:outline-none focus-visible:ring-4 focus:ring-ring font-medium max-w-max gap-1.5 bg-badge-background text-badge-foreground",
{
variants: {
size: {
sm: "text-xs h-5",
md: "text-sm h-6",
lg: "text-base h-8",
},
},
defaultVariants: {
size: "md",
},
},
);

export interface BadgeProps
extends HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}

const Badge = forwardRef<ElementRef<"div">, BadgeProps>(
({ className, size, ...props }, ref) => (
<div
ref={ref}
className={cn(badgeVariants({ size }), className)}
{...props}
/>
),
);

export { Badge };
18 changes: 18 additions & 0 deletions src/app/components/ui/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { cn } from "lib/cn";
import { type HTMLAttributes, forwardRef } from "react";

const Card = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"overflow-hidden rounded-2xl bg-card text-foreground shadow-md",
className,
)}
{...props}
/>
),
);
Card.displayName = "Card";

export { Card };
32 changes: 32 additions & 0 deletions src/app/explorer/components/GuildCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ImageSquare, Users } from "@phosphor-icons/react/dist/ssr";
import { Badge } from "app/components/ui/Badge";
import { Card } from "app/components/ui/Card";
import Link from "next/link";

export const GuildCard = () => {
return (
<Link href="#" className="rounded-2xl outline-none focus-visible:ring-4">
<Card className="relative grid grid-cols-[theme(space.12)_1fr] grid-rows-2 items-center gap-x-4 gap-y-0.5 overflow-hidden rounded-2xl px-6 py-7 shadow-md before:absolute before:inset-0 before:bg-black/5 before:opacity-0 before:transition-opacity before:duration-200 before:content-[''] hover:before:opacity-55 active:before:opacity-85 dark:before:bg-white/5">
<div className="row-span-2 grid size-12 place-items-center rounded-full bg-image text-white">
<ImageSquare weight="duotone" className="size-6" />
</div>

<h3 className="line-clamp-1 font-black font-display text-lg">
Sample guild
</h3>
<div className="flex flex-wrap gap-1">
<Badge>
<Users className="size-4" />
<span>
{new Intl.NumberFormat("en", {
notation: "compact",
}).format(125244)}
</span>
</Badge>

<Badge>5 groups</Badge>
</div>
</Card>
</Link>
);
};
11 changes: 11 additions & 0 deletions src/app/explorer/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { GuildCard } from "./components/GuildCard";

const Explorer = () => {
return (
<main className="container mx-auto grid max-w-screen-lg gap-4 px-4 py-8 sm:grid-cols-2 lg:grid-cols-3">
<GuildCard />
</main>
);
};

export default Explorer;
7 changes: 6 additions & 1 deletion src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ html {
--button-success-foreground: #fff;
--button-success-subtle: var(--green-300);
--button-success-subtle-foreground: var(--green-500);

--badge-background: rgba(0, 0, 0, 0.06);
--badge-foreground: var(--foreground);
}

.dark {
Expand Down Expand Up @@ -135,13 +138,15 @@ html {
--button-success-foreground: #fff;
--button-success-subtle: var(--green-300);
--button-success-subtle-foreground: var(--green-500);

--badge-background: rgba(255, 255, 255, 0.06);
--badge-foreground: var(--foreground);
}

.dark video,
.dark img {
@apply brightness-90 contrast-125;
}

body {
@apply bg-background text-foreground font-sans min-h-screen antialiased selection:bg-foreground selection:text-background;
}
25 changes: 25 additions & 0 deletions src/stories/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Meta, StoryObj } from "@storybook/react";
import { Badge, type BadgeProps } from "app/components/ui/Badge";

const meta: Meta<typeof Badge> = {
title: "Design system/Badge",
component: Badge,
};

export default meta;

type Story = StoryObj<typeof Badge>;

export const Default: Story = {
args: {
children: "Default",
size: "md",
},
argTypes: {
size: {
type: "string",
control: "select",
options: ["sm", "md", "lg"] satisfies BadgeProps["size"][],
},
},
};
4 changes: 4 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const config = {
card: "var(--card)",
image: "var(--image)",
skeleton: "var(--skeleton)",
badge: {
background: "var(--badge-background)",
foreground: "var(--badge-foreground)"
}
},
},
},
Expand Down

0 comments on commit 64859bd

Please sign in to comment.