-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { expect, within } from "@storybook/test"; | ||
|
||
import { StatusBadge } from "./StatusBadge"; | ||
|
||
const meta: Meta<typeof StatusBadge> = { | ||
title: "Primitives/StatusBadge", | ||
|
||
component: StatusBadge, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof StatusBadge>; | ||
|
||
export const InProgress: Story = { | ||
args: { | ||
status: "In Progress", | ||
}, | ||
}; | ||
|
||
export const Ended: Story = { | ||
args: { | ||
status: "Ended", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as React from "react"; | ||
import { cva, type VariantProps } from "class-variance-authority"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
|
||
type Status = "In Progress" | "Ended" | "default" | undefined | null; | ||
|
||
interface StatusBadgeProps { | ||
status: Status; | ||
} | ||
|
||
export const StatusBadge = ({ status = "default" }: StatusBadgeProps) => { | ||
return <Badge variant={status?.replace(" ", "") as Status}>{status} </Badge>; | ||
}; | ||
|
||
const badgeVariants = cva( | ||
"ui-inline-flex ui-items-center ui-rounded-full ui-border ui-px-2.5 ui-py-0.5 ui-font-sans ui-text-xs ui-font-semibold ", | ||
// ui-border-neutral-200 ui-transition-colors focus:ui-outline-none focus:ui-ring-2 focus:ui-ring-neutral-950 focus:ui-ring-offset-2 dark:ui-border-neutral-800 dark:focus:ui-ring-neutral-300 | ||
{ | ||
variants: { | ||
variant: { | ||
default: | ||
"ui-border-transparent ui-bg-neutral-900 ui-text-neutral-50 hover:ui-bg-neutral-900/80 dark:ui-bg-neutral-50 dark:ui-text-neutral-900 dark:hover:ui-bg-neutral-50/80", | ||
// secondary: | ||
// "ui-border-transparent ui-bg-neutral-100 ui-text-neutral-900 hover:ui-bg-neutral-100/80 dark:ui-bg-neutral-800 dark:ui-text-neutral-50 dark:hover:ui-bg-neutral-800/80", | ||
// destructive: | ||
// "ui-border-transparent ui-bg-red-500 ui-text-neutral-50 hover:ui-bg-red-500/80 dark:ui-bg-red-900 dark:ui-text-neutral-50 dark:hover:ui-bg-red-900/80", | ||
// outline: "ui-text-neutral-950 dark:ui-text-neutral-50", | ||
|
||
"In Progress": "ui-border-red-800", | ||
Ended: "ui-border-blue-800", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
}, | ||
}, | ||
); | ||
|
||
export interface BadgeProps | ||
extends React.HTMLAttributes<HTMLDivElement>, | ||
VariantProps<typeof badgeVariants> {} | ||
|
||
function Badge({ className, variant, ...props }: BadgeProps) { | ||
return <div className={cn(badgeVariants({ variant }), className)} {...props} />; | ||
} | ||
|
||
export { Badge, badgeVariants }; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.