Skip to content

Commit

Permalink
docs(Badge): add documentation for Badge component
Browse files Browse the repository at this point in the history
  • Loading branch information
ruru-m07 committed Jul 24, 2024
1 parent 163afbf commit d759d3c
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 9 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

205 changes: 204 additions & 1 deletion apps/www/components/preview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ReactNode } from "react";
import dynamic from "next/dynamic";
import { Wrapper } from "./wrapper";
import { Avatar, AvatarWithBadge } from "ruru-ui/components/avatar";
import { CubeIcon } from "@radix-ui/react-icons";

const Button = dynamic(() =>
import("ruru-ui/components/button").then((m) => m.Button),
Expand All @@ -11,6 +11,14 @@ const Spinner = dynamic(() =>
import("ruru-ui/components/spinner").then((m) => m.Spinner),
);

const Badge = dynamic(() =>
import("ruru-ui/components/badge").then((m) => m.Badge),
);

const Avatar = dynamic(() =>
import("ruru-ui/components/avatar").then((m) => m.Avatar),
);

export default {
button: (
<Wrapper>
Expand Down Expand Up @@ -39,4 +47,199 @@ export default {
</div>
</Wrapper>
),
badge: (
<Wrapper>
<div className="flex items-center justify-center">
<div className="space-y-2">
<div className="space-x-2">
<Badge variant="gray" size="lg" icon={<CubeIcon />}>
gray
</Badge>
<Badge variant="gray" size="md" icon={<CubeIcon />}>
gray
</Badge>
<Badge variant="gray" size="sm" icon={<CubeIcon />}>
gray
</Badge>

<Badge variant="gray-subtle" size="sm" icon={<CubeIcon />}>
gray-subtle
</Badge>
<Badge variant="gray-subtle" size="md" icon={<CubeIcon />}>
gray-subtle
</Badge>
<Badge variant="gray-subtle" size="lg" icon={<CubeIcon />}>
gray-subtle
</Badge>
</div>

<div className="space-x-2">
<Badge variant="blue" size="lg" icon={<CubeIcon />}>
blue
</Badge>
<Badge variant="blue" size="md" icon={<CubeIcon />}>
blue
</Badge>
<Badge variant="blue" size="sm" icon={<CubeIcon />}>
blue
</Badge>

<Badge variant="blue-subtle" size="sm" icon={<CubeIcon />}>
blue-subtle
</Badge>
<Badge variant="blue-subtle" size="md" icon={<CubeIcon />}>
blue-subtle
</Badge>
<Badge variant="blue-subtle" size="lg" icon={<CubeIcon />}>
blue-subtle
</Badge>
</div>

<div className="space-x-2">
<Badge variant="purple" size="lg" icon={<CubeIcon />}>
purple
</Badge>
<Badge variant="purple" size="md" icon={<CubeIcon />}>
purple
</Badge>
<Badge variant="purple" size="sm" icon={<CubeIcon />}>
purple
</Badge>

<Badge variant="purple-subtle" size="sm" icon={<CubeIcon />}>
purple-subtle
</Badge>
<Badge variant="purple-subtle" size="md" icon={<CubeIcon />}>
purple-subtle
</Badge>
<Badge variant="purple-subtle" size="lg" icon={<CubeIcon />}>
purple-subtle
</Badge>
</div>

<div className="space-x-2">
<Badge variant="amber" size="lg" icon={<CubeIcon />}>
amber
</Badge>
<Badge variant="amber" size="md" icon={<CubeIcon />}>
amber
</Badge>
<Badge variant="amber" size="sm" icon={<CubeIcon />}>
amber
</Badge>

<Badge variant="amber-subtle" size="sm" icon={<CubeIcon />}>
amber-subtle
</Badge>
<Badge variant="amber-subtle" size="md" icon={<CubeIcon />}>
amber-subtle
</Badge>
<Badge variant="amber-subtle" size="lg" icon={<CubeIcon />}>
amber-subtle
</Badge>
</div>

<div className="space-x-2">
<Badge variant="red" size="lg" icon={<CubeIcon />}>
red
</Badge>
<Badge variant="red" size="md" icon={<CubeIcon />}>
red
</Badge>
<Badge variant="red" size="sm" icon={<CubeIcon />}>
red
</Badge>

<Badge variant="red-subtle" size="sm" icon={<CubeIcon />}>
red-subtle
</Badge>
<Badge variant="red-subtle" size="md" icon={<CubeIcon />}>
red-subtle
</Badge>
<Badge variant="red-subtle" size="lg" icon={<CubeIcon />}>
red-subtle
</Badge>
</div>

<div className="space-x-2">
<Badge variant="pink" size="lg" icon={<CubeIcon />}>
pink
</Badge>
<Badge variant="pink" size="md" icon={<CubeIcon />}>
pink
</Badge>
<Badge variant="pink" size="sm" icon={<CubeIcon />}>
pink
</Badge>

<Badge variant="pink-subtle" size="sm" icon={<CubeIcon />}>
pink-subtle
</Badge>
<Badge variant="pink-subtle" size="md" icon={<CubeIcon />}>
pink-subtle
</Badge>
<Badge variant="pink-subtle" size="lg" icon={<CubeIcon />}>
pink-subtle
</Badge>
</div>

<div className="space-x-2">
<Badge variant="green" size="lg" icon={<CubeIcon />}>
green
</Badge>
<Badge variant="green" size="md" icon={<CubeIcon />}>
green
</Badge>
<Badge variant="green" size="sm" icon={<CubeIcon />}>
green
</Badge>

<Badge variant="green-subtle" size="sm" icon={<CubeIcon />}>
green-subtle
</Badge>
<Badge variant="green-subtle" size="md" icon={<CubeIcon />}>
green-subtle
</Badge>
<Badge variant="green-subtle" size="lg" icon={<CubeIcon />}>
green-subtle
</Badge>
</div>

<div className="space-x-2">
<Badge variant="teal" size="lg" icon={<CubeIcon />}>
teal
</Badge>
<Badge variant="teal" size="md" icon={<CubeIcon />}>
teal
</Badge>
<Badge variant="teal" size="sm" icon={<CubeIcon />}>
teal
</Badge>

<Badge variant="teal-subtle" size="sm" icon={<CubeIcon />}>
teal-subtle
</Badge>
<Badge variant="teal-subtle" size="md" icon={<CubeIcon />}>
teal-subtle
</Badge>
<Badge variant="teal-subtle" size="lg" icon={<CubeIcon />}>
teal-subtle
</Badge>
</div>

<div className="space-x-2">
<Badge variant="inverted" size="lg" icon={<CubeIcon />}>
inverted
</Badge>
<Badge variant="inverted" size="md" icon={<CubeIcon />}>
inverted
</Badge>
<Badge variant="inverted" size="sm" icon={<CubeIcon />}>
inverted
</Badge>
</div>
</div>
</div>
</Wrapper>
),
} as Record<string, ReactNode>;
165 changes: 165 additions & 0 deletions apps/www/content/docs/components/badge.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
title: Badge
description: The Badge component is used to represent a user or entity.
preview: badge
---

import { Badge } from "ruru-ui/components/badge";
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
import { CubeIcon } from "@radix-ui/react-icons";

## Usage

<Tabs items={["Preview", "Code"]}>
<Tab className={"flex justify-center"} value="Preview" >
<Badge variant="green-subtle" size="md" >green-subtle</Badge>
</Tab>
<Tab className={"-mt-8"} value="Code">
```tsx
import { Badge } from "ruru-ui/components/badge";

export function BadgeDemo() {
return (
<Badge variant="green-subtle" size="md" >green-subtle</Badge>
)
}
```
</Tab>

</Tabs>

## Examples

### variant

The variant of the badge (e.g., "gray", "red", etc...).

<Tabs items={["Preview", "Code"]}>
<Tab className={"flex flex-wrap space-x-2 space-y-2"} value="Preview" >
<div />
<Badge variant="gray" size="md" >gray</Badge>
<Badge variant="gray-subtle" size="md" >gray-subtle</Badge>
<Badge variant="blue" size="md" >blue</Badge>
<Badge variant="blue-subtle" size="md" >blue-subtle</Badge>
<Badge variant="purple" size="md" >purple</Badge>
<Badge variant="purple-subtle" size="md" >purple-subtle</Badge>
<Badge variant="amber" size="md" >amber</Badge>
<Badge variant="amber-subtle" size="md" >amber-subtle</Badge>
<Badge variant="red" size="md" >red</Badge>
<Badge variant="red-subtle" size="md" >red-subtle</Badge>
<Badge variant="pink" size="md" >pink</Badge>
<Badge variant="pink-subtle" size="md" >pink-subtle</Badge>
<Badge variant="green" size="md" >green</Badge>
<Badge variant="green-subtle" size="md" >Green-Subtle</Badge>
<Badge variant="teal" size="md" >teal</Badge>
<Badge variant="teal-subtle" size="md" >teal-subtle</Badge>
<Badge variant="inverted" size="md" >inverted</Badge>
</Tab>
<Tab className={"-mt-8"} value="Code">
```tsx
import { Badge } from "ruru-ui/components/badge";

export function BadgeDemo() {
return (
<div>
<Badge variant="gray" size="md" >gray</Badge>
<Badge variant="gray-subtle" size="md" >gray-subtle</Badge>
<Badge variant="blue" size="md" >blue</Badge>
<Badge variant="blue-subtle" size="md" >blue-subtle</Badge>
<Badge variant="purple" size="md" >purple</Badge>
<Badge variant="purple-subtle" size="md" >purple-subtle</Badge>
<Badge variant="amber" size="md" >amber</Badge>
<Badge variant="amber-subtle" size="md" >amber-subtle</Badge>
<Badge variant="red" size="md" >red</Badge>
<Badge variant="red-subtle" size="md" >red-subtle</Badge>
<Badge variant="pink" size="md" >pink</Badge>
<Badge variant="pink-subtle" size="md" >pink-subtle</Badge>
<Badge variant="green" size="md" >green</Badge>
<Badge variant="green-subtle" size="md" >Green-Subtle</Badge>
<Badge variant="teal" size="md" >teal</Badge>
<Badge variant="teal-subtle" size="md" >teal-subtle</Badge>
<Badge variant="inverted" size="md" >inverted</Badge>
</div>
)
}
```
</Tab>

</Tabs>

### size

The size of the badge (e.g., "sm", "md", "lg").

<Tabs items={["Preview", "Code"]}>
<Tab className={"flex justify-between"} value="Preview" >
<Badge variant="gray-subtle" size="sm" >gray</Badge>
<Badge variant="gray-subtle" size="md" >gray</Badge>
<Badge variant="gray-subtle" size="lg" >gray</Badge>
</Tab>
<Tab className={"-mt-8"} value="Code">
```tsx
import { Badge } from "ruru-ui/components/badge";

export function BadgeDemo() {
return (
<div className={"flex justify-between"}>
<Badge variant="green-subtle" size="sm">
sm
</Badge>
<Badge variant="green-subtle" size="md">
md
</Badge>
<Badge variant="green-subtle" size="lg">
lg
</Badge>
</div>
)
}
```
</Tab>

</Tabs>

### icon

An optional icon to display before the badge content.

<Tabs items={["Preview", "Code"]}>
<Tab className={"flex justify-between"} value="Preview" >
<Badge variant="gray-subtle" size="sm" icon={<CubeIcon />} >gray</Badge>
<Badge variant="gray-subtle" size="md" icon={<CubeIcon />} >gray</Badge>
<Badge variant="gray-subtle" size="lg" icon={<CubeIcon />} >gray</Badge>
</Tab>
<Tab className={"-mt-8"} value="Code">
```tsx
import { Badge } from "ruru-ui/components/badge";

export function BadgeDemo() {
return (
<div className={"flex justify-between"}>
<Badge variant="gray-subtle" size="sm">
sm
</Badge>
<Badge variant="gray-subtle" size="md">
md
</Badge>
<Badge variant="gray-subtle" size="lg">
lg
</Badge>
</div>
)
}
```
</Tab>

</Tabs>

## Props

| Name | Type | Default | Description |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------------------------- |
| **variant** | **green-subtle** \| **gray** \| **gray-subtle** \| **blue** \| **blue-subtle** \| **purple** \| **purple-subtle** \| **amber** \| **amber-subtle** \| **red** \| **red-subtle** \| **pink** \| **pink-subtle** \| **green** \| **green-subtle** \| **teal** \| **teal-subtle** \| **inverted** | "gray" | The color variant of the badge. |
| **size** | **sm** \| **md** \| **lg** | "md" | The size of the badge. |
| **icon** | React.ReactNode | null | The icon to display in the badge. |
| **children** | React.ReactNode | null | The content of the badge. |
Loading

0 comments on commit d759d3c

Please sign in to comment.