Skip to content

Commit

Permalink
folders and badge
Browse files Browse the repository at this point in the history
  • Loading branch information
gnomadic committed Oct 23, 2024
1 parent 68d49e5 commit 7202833
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/features/project/components/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { match, P } from "ts-pattern";
import { UseQueryResult } from "@tanstack/react-query";

import { Project } from "@/features/project/types/types";
import { BannerImage } from "@/primitives/BannerImage";
import { Avatar } from "@/primitives/Avatar";
import { BannerImage } from "@/primitives/BannerImage/BannerImage";
import { Avatar } from "@/primitives/Avatar/Avatar";
import { Skeleton } from "@/ui-shadcn/skeleton";

interface ProjectCardProps {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { expect, within } from "@storybook/test";
import { Avatar } from "./Avatar";

const meta: Meta<typeof Avatar> = {
title: "Primitives/Avatar",
component: Avatar,
};

Expand Down
File renamed without changes.
25 changes: 25 additions & 0 deletions src/primitives/Badge/StatusBadge.stories.tsx
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",
},
};
48 changes: 48 additions & 0 deletions src/primitives/Badge/StatusBadge.tsx
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.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { expect, within } from "@storybook/test";
import { BannerImage } from "./BannerImage";

const meta: Meta<typeof BannerImage> = {
title: "Primitives/BannerImage",
component: BannerImage,
};

Expand Down
File renamed without changes.

0 comments on commit 7202833

Please sign in to comment.