Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
.accordion-trigger {
|
||||
@apply flex flex-1 items-center justify-between rounded-sm bg-primary p-4 text-[1.4rem] font-semibold text-white transition-all hover:underline data-[state=open]:rounded-b-none [&[data-state=open]>svg]:rotate-180;
|
||||
}
|
||||
.accordion-content {
|
||||
@apply overflow-hidden rounded-b-sm bg-secondary text-[1.3rem] text-secondary-foreground transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down;
|
||||
}
|
||||
.accordion-content > div {
|
||||
@apply p-4;
|
||||
}
|
||||
.secondary .accordion-trigger {
|
||||
@apply border border-border bg-secondary text-secondary-foreground;
|
||||
}
|
||||
.secondary .accordion-content {
|
||||
@apply border border-t-0 border-border bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import {
|
||||
Accordion,
|
||||
AccordionContent,
|
||||
AccordionItem,
|
||||
AccordionTrigger,
|
||||
} from ".";
|
||||
|
||||
const meta: Meta<typeof Accordion> = {
|
||||
title: "Elements/Accordion",
|
||||
component: Accordion,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/accordion)
|
||||
- [API Reference](https://www.radix-ui.com/primitives/docs/components/accordion#api-reference)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Accordion>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<Accordion type="single" collapsible className="flex w-96 flex-col gap-4">
|
||||
<AccordionItem value="item-1">
|
||||
<AccordionTrigger>Is it accessible?</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
Yes. It adheres to the WAI-ARIA design pattern.
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
<AccordionItem value="item-2">
|
||||
<AccordionTrigger>Is it styled?</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
Yes. It comes with default styles that matches the other
|
||||
components' aesthetic.
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
<AccordionItem value="item-3">
|
||||
<AccordionTrigger>Is it animated?</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
Yes. It's animated by default, but you can disable it if you
|
||||
prefer.
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
),
|
||||
};
|
||||
|
||||
export const Secondary: Story = {
|
||||
render: () => (
|
||||
<Accordion
|
||||
type="single"
|
||||
collapsible
|
||||
className="secondary flex w-96 flex-col gap-4"
|
||||
>
|
||||
<AccordionItem value="item-1">
|
||||
<AccordionTrigger>Is it accessible?</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
Yes. It adheres to the WAI-ARIA design pattern.
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
<AccordionItem value="item-2">
|
||||
<AccordionTrigger>Is it styled?</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
Yes. It comes with default styles that matches the other
|
||||
components' aesthetic.
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
<AccordionItem value="item-3">
|
||||
<AccordionTrigger>Is it animated?</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
Yes. It's animated by default, but you can disable it if you
|
||||
prefer.
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
"use client";
|
||||
|
||||
import "./accordion.css";
|
||||
|
||||
import * as React from "react";
|
||||
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
const Accordion = AccordionPrimitive.Root;
|
||||
|
||||
const AccordionItem = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
|
||||
>(({ ...props }, ref) => <AccordionPrimitive.Item ref={ref} {...props} />);
|
||||
AccordionItem.displayName = "AccordionItem";
|
||||
|
||||
const AccordionTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<AccordionPrimitive.Header className="flex">
|
||||
<AccordionPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn("accordion-trigger", className)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronDown className="size-6 shrink-0 transition-transform duration-200" />
|
||||
</AccordionPrimitive.Trigger>
|
||||
</AccordionPrimitive.Header>
|
||||
));
|
||||
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
||||
|
||||
const AccordionContent = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<AccordionPrimitive.Content
|
||||
ref={ref}
|
||||
className="accordion-content"
|
||||
{...props}
|
||||
>
|
||||
<div className={className}>{children}</div>
|
||||
</AccordionPrimitive.Content>
|
||||
));
|
||||
|
||||
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
||||
|
||||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
||||
@@ -0,0 +1,51 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
.badge {
|
||||
@apply inline-flex items-center rounded-[0.4rem] border font-normal text-white transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2;
|
||||
}
|
||||
.badge.default {
|
||||
@apply border-transparent bg-primary;
|
||||
}
|
||||
.badge.secondary {
|
||||
@apply border-transparent bg-secondary;
|
||||
}
|
||||
.badge.destructive {
|
||||
@apply border-transparent bg-destructive;
|
||||
}
|
||||
.badge.outline {
|
||||
}
|
||||
.badge.red {
|
||||
@apply bg-[#ff6354];
|
||||
}
|
||||
.badge.blue {
|
||||
@apply bg-[#1ba9ff];
|
||||
}
|
||||
.badge.yellow {
|
||||
@apply bg-[#fbc700];
|
||||
}
|
||||
.badge.orange {
|
||||
@apply bg-[#ff8a22];
|
||||
}
|
||||
.badge.smokyBlue {
|
||||
@apply bg-[#5b85ff];
|
||||
}
|
||||
.badge.purple {
|
||||
@apply bg-[#d85bff];
|
||||
}
|
||||
.badge.green {
|
||||
@apply bg-[#07bd9d];
|
||||
}
|
||||
.badge.gray {
|
||||
@apply bg-[#838383];
|
||||
}
|
||||
.badge.lightGray {
|
||||
@apply bg-[#b9b9b9];
|
||||
}
|
||||
.badge.base {
|
||||
@apply px-2.5 py-0.5 text-[1.1rem];
|
||||
}
|
||||
.badge.lg {
|
||||
@apply px-5 py-1 text-[1.3rem];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { Badge } from ".";
|
||||
|
||||
const meta: Meta<typeof Badge> = {
|
||||
title: "Elements/Badge",
|
||||
component: Badge,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/badge)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Badge>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<div className="flex gap-2">
|
||||
<Badge color="red">Red</Badge>
|
||||
<Badge color="blue">Blue</Badge>
|
||||
<Badge color="yellow">Yellow</Badge>
|
||||
<Badge color="orange">Orange</Badge>
|
||||
<Badge color="smokyBlue">Smoky Blue</Badge>
|
||||
<Badge color="purple">Purple</Badge>
|
||||
<Badge color="green">Green</Badge>
|
||||
<Badge color="gray">Gray</Badge>
|
||||
<Badge color="lightGray">Light Gray</Badge>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const Size: Story = {
|
||||
render: () => (
|
||||
<div className="flex gap-2">
|
||||
<Badge color="red" size="lg">
|
||||
Red
|
||||
</Badge>
|
||||
<Badge color="blue" size="lg">
|
||||
Blue
|
||||
</Badge>
|
||||
<Badge color="yellow" size="lg">
|
||||
Yellow
|
||||
</Badge>
|
||||
<Badge color="orange" size="lg">
|
||||
Orange
|
||||
</Badge>
|
||||
<Badge color="smokyBlue" size="lg">
|
||||
Smoky Blue
|
||||
</Badge>
|
||||
<Badge color="purple" size="lg">
|
||||
Purple
|
||||
</Badge>
|
||||
<Badge color="green" size="lg">
|
||||
Green
|
||||
</Badge>
|
||||
<Badge color="gray" size="lg">
|
||||
Gray
|
||||
</Badge>
|
||||
<Badge color="lightGray" size="lg">
|
||||
Light Gray
|
||||
</Badge>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
import "./badge.css";
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
export type BadgeProps = React.HTMLAttributes<HTMLDivElement> & {
|
||||
variant?: "default" | "secondary" | "destructive" | "outline";
|
||||
color?:
|
||||
| "red"
|
||||
| "blue"
|
||||
| "yellow"
|
||||
| "orange"
|
||||
| "smokyBlue"
|
||||
| "purple"
|
||||
| "green"
|
||||
| "gray"
|
||||
| "lightGray";
|
||||
size?: "base" | "lg";
|
||||
};
|
||||
|
||||
function Badge({
|
||||
className,
|
||||
variant = "default",
|
||||
color,
|
||||
size = "base",
|
||||
...props
|
||||
}: BadgeProps) {
|
||||
return (
|
||||
<div className={cn("badge", variant, color, size, className)} {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
export { Badge };
|
||||
@@ -0,0 +1,40 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
div[role="radiogroup"][data-variant="button"] {
|
||||
@apply gap-0 overflow-hidden rounded-sm;
|
||||
}
|
||||
div[role="radiogroup"][data-variant="button"] button {
|
||||
@apply aspect-auto h-auto w-auto rounded-none bg-none px-6 py-2 text-[1.3rem] font-medium transition-[background-color,color] duration-150;
|
||||
}
|
||||
|
||||
/* 버튼 색상 */
|
||||
div[role="radiogroup"][data-variant="button"][data-color="primary"] {
|
||||
@apply border border-primary dark:border-[#404040];
|
||||
}
|
||||
div[role="radiogroup"][data-variant="button"][data-color="primary"] button {
|
||||
@apply text-[#6f98bd] hover:bg-[#ecf3f9] hover:text-[#498bc7] data-[state=checked]:bg-primary data-[state=checked]:text-white dark:bg-[#505050] dark:text-[#aeb7bf] dark:hover:bg-[#525e69] dark:data-[state=checked]:bg-primary dark:data-[state=checked]:text-white;
|
||||
}
|
||||
div[role="radiogroup"][data-variant="button"][data-color="secondary"] {
|
||||
@apply border border-[#ababab] dark:border-[#808080];
|
||||
}
|
||||
div[role="radiogroup"][data-variant="button"][data-color="secondary"] button {
|
||||
@apply bg-[#f3f3f3] text-[#8a8a8a] hover:bg-[#ececec] hover:text-[#808080] data-[state=checked]:bg-[#848484] data-[state=checked]:text-white dark:bg-[#505050] dark:text-[#a5a5a5] dark:hover:bg-[#444444] dark:data-[state=checked]:bg-[#848484] dark:data-[state=checked]:text-white;
|
||||
}
|
||||
|
||||
/* 버튼 모양 */
|
||||
div[role="radiogroup"][data-variant="button"][data-shape="rounded"] {
|
||||
@apply rounded-full;
|
||||
}
|
||||
div[role="radiogroup"][data-variant="button"][data-color="primary"][data-shape="rounded"]
|
||||
button {
|
||||
@apply bg-[#70bcff] text-white hover:bg-[#6bb0ec] data-[state=checked]:bg-primary dark:bg-[#505050] dark:hover:bg-[#525e69] dark:data-[state=checked]:bg-primary;
|
||||
}
|
||||
div[role="radiogroup"][data-variant="button"][data-color="secondary"][data-shape="rounded"] {
|
||||
@apply border-[#7b7b7b];
|
||||
}
|
||||
div[role="radiogroup"][data-variant="button"][data-color="secondary"][data-shape="rounded"]
|
||||
button {
|
||||
@apply bg-[#b7b7b7] text-white hover:bg-[#a9a9a9] data-[state=checked]:bg-[#797979] dark:bg-[#505050] dark:hover:bg-[#444444] dark:data-[state=checked]:bg-[#797979];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import "./button-group.css";
|
||||
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
|
||||
import { RadioGroup, RadioGroupItem } from "../radio-group";
|
||||
|
||||
const meta: Meta<typeof RadioGroup> = {
|
||||
title: "Elements/ButtonGroup",
|
||||
component: RadioGroup,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
ButtonGroup 컴포넌트는 RadioGroup 컴포넌트를 기반으로 버튼 모양을 변형한 컴포넌트입니다.
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof RadioGroup>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable" variant="button">
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
),
|
||||
};
|
||||
|
||||
export const Secondary: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable" variant="button" color="secondary">
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
),
|
||||
};
|
||||
|
||||
export const Rounded: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable" variant="button" shape="rounded">
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
),
|
||||
};
|
||||
|
||||
export const SecondaryRounded: Story = {
|
||||
render: () => (
|
||||
<RadioGroup
|
||||
defaultValue="comfortable"
|
||||
variant="button"
|
||||
color="secondary"
|
||||
shape="rounded"
|
||||
>
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
button[role="button"] {
|
||||
@apply text-[1.3rem];
|
||||
}
|
||||
button[role="button"].primary {
|
||||
@apply bg-[rgba(32,148,250,1)] hover:bg-[rgba(32,148,250,0.9)];
|
||||
}
|
||||
button[role="button"].green {
|
||||
@apply bg-[rgba(31,208,120,1)] hover:bg-[rgba(31,208,120,0.9)];
|
||||
}
|
||||
button[role="button"].sky {
|
||||
@apply bg-[rgba(50,154,203,1)] hover:bg-[rgba(50,154,203,0.9)];
|
||||
}
|
||||
button[role="button"].yellow {
|
||||
@apply bg-[rgba(243,201,0,1)] hover:bg-[rgba(243,201,0,0.9)];
|
||||
}
|
||||
button[role="button"].orange {
|
||||
@apply bg-[rgba(255,149,0,1)] hover:bg-[rgba(255,149,0,0.9)];
|
||||
}
|
||||
button[role="button"].emerald {
|
||||
@apply bg-[rgba(90,200,250,1)] hover:bg-[rgba(90,200,250,0.9)];
|
||||
}
|
||||
button[role="button"].white {
|
||||
@apply border border-border bg-[rgba(255,255,255,1)] text-[#666] hover:bg-[rgba(255,255,255,0.9)];
|
||||
}
|
||||
button[role="button"].red {
|
||||
@apply bg-[rgba(232,93,85,1)] hover:bg-[rgba(232,93,85,0.9)];
|
||||
}
|
||||
button[role="button"].gray {
|
||||
@apply bg-[rgba(153,153,153,1)] hover:bg-[rgba(153,153,153,0.9)];
|
||||
}
|
||||
button[role="button"].lightGray {
|
||||
@apply bg-[rgba(235,235,235,1)] text-[#929292] hover:bg-[rgba(235,235,235,0.9)];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { Button } from ".";
|
||||
|
||||
const meta: Meta<typeof Button> = {
|
||||
title: "Elements/Button",
|
||||
component: Button,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/button)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Button>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<Button>Button</Button>
|
||||
<Button color="green">Button</Button>
|
||||
<Button color="sky">Button</Button>
|
||||
<Button color="yellow">Button</Button>
|
||||
<Button color="orange">Button</Button>
|
||||
<Button color="emerald">Button</Button>
|
||||
<Button color="white">Button</Button>
|
||||
<Button color="red">Button</Button>
|
||||
<Button color="gray">Button</Button>
|
||||
<Button color="lightGray">Button</Button>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const Sizes: Story = {
|
||||
render: () => (
|
||||
<div className="flex items-end gap-4">
|
||||
<Button size="xs">xsmall</Button>
|
||||
<Button size="sm">Small</Button>
|
||||
<Button>Default</Button>
|
||||
<Button size="lg">Large</Button>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const WithIcon: Story = {
|
||||
render: () => (
|
||||
<Button>
|
||||
<i className="diveicon di-account-circle text-2xl" />
|
||||
With Icon
|
||||
</Button>
|
||||
),
|
||||
};
|
||||
|
||||
export const Gradient: Story = {
|
||||
render: () => (
|
||||
<div className="flex items-end gap-4">
|
||||
<Button className="bg-gradient-blue hover:bg-gradient-blue-hover">
|
||||
Gradient Blue
|
||||
</Button>
|
||||
<Button className="bg-gradient-green hover:bg-gradient-green-hover">
|
||||
Gradient Green
|
||||
</Button>
|
||||
<Button className="bg-gradient-red hover:bg-gradient-red-hover">
|
||||
Gradient Red
|
||||
</Button>
|
||||
<Button className="bg-gradient-purple hover:bg-gradient-purple-hover">
|
||||
Gradient Purple
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
import "./button.css";
|
||||
|
||||
import * as React from "react";
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
const buttonVariants = cva(
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm text-[1.3rem] font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
||||
destructive:
|
||||
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
||||
outline:
|
||||
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||
ghost: "hover:bg-accent hover:text-accent-foreground",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default: "h-12 px-10",
|
||||
xs: "h-8 px-2 !text-[1.1rem]",
|
||||
sm: "h-10 px-4",
|
||||
lg: "h-16 px-12",
|
||||
icon: "h-10 w-10",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
export interface ButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
VariantProps<typeof buttonVariants> {
|
||||
asChild?: boolean;
|
||||
color?:
|
||||
| "primary"
|
||||
| "green"
|
||||
| "sky"
|
||||
| "yellow"
|
||||
| "orange"
|
||||
| "emerald"
|
||||
| "white"
|
||||
| "red"
|
||||
| "gray"
|
||||
| "lightGray";
|
||||
}
|
||||
|
||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
(
|
||||
{ className, variant, size, color = "primary", asChild = false, ...props },
|
||||
ref,
|
||||
) => {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
return (
|
||||
<Comp
|
||||
role="button"
|
||||
className={cn(buttonVariants({ variant, size, className }), color)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
Button.displayName = "Button";
|
||||
|
||||
export { Button, buttonVariants };
|
||||
@@ -0,0 +1,71 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import { ko } from "date-fns/locale";
|
||||
import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||
import { DayPicker } from "react-day-picker";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
import { buttonVariants } from "../button";
|
||||
|
||||
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
||||
|
||||
export function Calendar({
|
||||
className,
|
||||
classNames,
|
||||
showOutsideDays = true,
|
||||
...props
|
||||
}: CalendarProps) {
|
||||
return (
|
||||
<DayPicker
|
||||
locale={ko}
|
||||
showOutsideDays={showOutsideDays}
|
||||
className={cn("p-[1.2rem]", className)}
|
||||
classNames={{
|
||||
months:
|
||||
"flex flex-col sm:flex-row space-y-[1.6rem] sm:space-x-[1.6rem] sm:space-y-0",
|
||||
month: "space-y-[1.6rem]",
|
||||
caption: "flex justify-center pt-[0.4rem] relative items-center",
|
||||
caption_label: "text-[1.4rem] font-medium",
|
||||
nav: "space-x-[0.4rem] flex items-center",
|
||||
nav_button: cn(
|
||||
buttonVariants({ variant: "outline" }),
|
||||
"size-[2.8rem] bg-transparent p-0 opacity-50 hover:opacity-100",
|
||||
),
|
||||
nav_button_previous: "absolute left-[0.4rem]",
|
||||
nav_button_next: "absolute right-[0.4rem]",
|
||||
table: "w-full border-collapse space-y-[0.4rem]",
|
||||
head_row: "flex",
|
||||
head_cell:
|
||||
"text-muted-foreground rounded-md w-[3.6rem] font-normal text-[1.28rem]",
|
||||
row: "flex w-full mt-[0.8rem]",
|
||||
cell: "size-[3.6rem] text-center text-[1.4rem] p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
|
||||
day: cn(
|
||||
buttonVariants({ variant: "ghost" }),
|
||||
"size-[3.6rem] p-0 font-normal aria-selected:opacity-100 text-[1.3rem]",
|
||||
),
|
||||
day_range_end: "day-range-end",
|
||||
day_selected:
|
||||
"!bg-primary !text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
||||
day_today: "bg-accent text-accent-foreground",
|
||||
day_outside:
|
||||
"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",
|
||||
day_disabled: "text-muted-foreground opacity-50",
|
||||
day_range_middle:
|
||||
"aria-selected:bg-accent aria-selected:text-accent-foreground",
|
||||
day_hidden: "invisible",
|
||||
...classNames,
|
||||
}}
|
||||
components={{
|
||||
IconLeft: ({ className, ...props }) => (
|
||||
<ChevronLeft className={cn("size-[1.6rem]", className)} {...props} />
|
||||
),
|
||||
IconRight: ({ className, ...props }) => (
|
||||
<ChevronRight className={cn("size-[1.6rem]", className)} {...props} />
|
||||
),
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Calendar.displayName = "Calendar";
|
||||
@@ -0,0 +1,16 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
button[role="checkbox"] {
|
||||
@apply size-[1.5rem] shrink-0 overflow-hidden rounded-[0.5rem] border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground;
|
||||
}
|
||||
button[role="checkbox"] > span {
|
||||
@apply flex size-full items-center justify-center text-current;
|
||||
}
|
||||
button[role="checkbox"] + label {
|
||||
@apply text-label text-[1.3rem] font-medium;
|
||||
}
|
||||
button[role="checkbox"]:disabled + label {
|
||||
@apply cursor-not-allowed opacity-70;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { Checkbox } from ".";
|
||||
|
||||
const meta: Meta<typeof Checkbox> = {
|
||||
title: "Elements/Checkbox",
|
||||
component: Checkbox,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/checkbox)
|
||||
- [API Reference](https://www.radix-ui.com/primitives/docs/components/checkbox#api-reference)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Checkbox>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox id="terms" />
|
||||
<label htmlFor="terms">Accept terms and conditions</label>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import "./checkbox.css";
|
||||
|
||||
import * as React from "react";
|
||||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
||||
import { Check } from "lucide-react";
|
||||
|
||||
const Checkbox = React.forwardRef<
|
||||
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
||||
>(({ ...props }, ref) => (
|
||||
<CheckboxPrimitive.Root ref={ref} {...props}>
|
||||
<CheckboxPrimitive.Indicator>
|
||||
<Check className="size-6" />
|
||||
</CheckboxPrimitive.Indicator>
|
||||
</CheckboxPrimitive.Root>
|
||||
));
|
||||
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
||||
|
||||
export { Checkbox };
|
||||
@@ -0,0 +1,7 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
.date-picker-trigger {
|
||||
@apply h-[3rem] w-[12rem] justify-between border-input !bg-background px-4 py-2 text-left text-[1.3rem] font-normal leading-none text-muted-foreground hover:!bg-accent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { DatePicker } from ".";
|
||||
import { useState } from "react";
|
||||
|
||||
const meta: Meta<typeof DatePicker> = {
|
||||
title: "Elements/DatePicker",
|
||||
component: DatePicker,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/date-picker)
|
||||
- [React DayPicker](https://daypicker.dev/)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof DatePicker>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => <ControlledDatePicker />,
|
||||
};
|
||||
|
||||
function ControlledDatePicker() {
|
||||
const [date, setDate] = useState<Date>();
|
||||
return <DatePicker mode="single" selected={date} onSelect={setDate} />;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
"use client";
|
||||
|
||||
import "./date-picker.css";
|
||||
|
||||
import { format } from "date-fns";
|
||||
import { CalendarIcon } from "lucide-react";
|
||||
import type { DayPickerSingleProps } from "react-day-picker";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
import { Button } from "../button";
|
||||
import { Calendar } from "../calendar";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "../popover";
|
||||
|
||||
type DatePickerProps = DayPickerSingleProps;
|
||||
|
||||
export function DatePicker({ className, ...props }: DatePickerProps) {
|
||||
return (
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
className={cn("date-picker-trigger", className)}
|
||||
>
|
||||
{props.selected ? (
|
||||
format(props.selected, "yyyy-MM-dd")
|
||||
) : (
|
||||
<span>날짜 선택</span>
|
||||
)}
|
||||
<CalendarIcon className="!size-[1.6rem]" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-auto p-0">
|
||||
<Calendar initialFocus classNames={{ cell: "rounded-md" }} {...props} />
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from ".";
|
||||
import { Button } from "../button";
|
||||
|
||||
const meta: Meta<typeof DropdownMenu> = {
|
||||
title: "Elements/DropdownMenu",
|
||||
component: DropdownMenu,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/dropdown-menu)
|
||||
- [API Reference](https://www.radix-ui.com/primitives/docs/components/dropdown-menu#api-reference)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof DropdownMenu>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button className="group">
|
||||
Dropdown
|
||||
<i className="diveicon di-chevron-down translate-y-0.5 transition-transform group-data-[state=open]:rotate-180" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<DropdownMenuItem>Dropdown Item 1</DropdownMenuItem>
|
||||
<DropdownMenuItem>Dropdown Item 2</DropdownMenuItem>
|
||||
<DropdownMenuItem>Dropdown Item 3</DropdownMenuItem>
|
||||
<DropdownMenuItem>Dropdown Item 4</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,198 @@
|
||||
import * as React from "react";
|
||||
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
||||
import { Check, ChevronRight, Circle } from "lucide-react";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
const DropdownMenu = DropdownMenuPrimitive.Root;
|
||||
|
||||
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
||||
|
||||
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
||||
|
||||
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
||||
|
||||
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
||||
|
||||
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
||||
|
||||
const DropdownMenuSubTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, children, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRight className="ml-auto" />
|
||||
</DropdownMenuPrimitive.SubTrigger>
|
||||
));
|
||||
DropdownMenuSubTrigger.displayName =
|
||||
DropdownMenuPrimitive.SubTrigger.displayName;
|
||||
|
||||
const DropdownMenuSubContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DropdownMenuSubContent.displayName =
|
||||
DropdownMenuPrimitive.SubContent.displayName;
|
||||
|
||||
const DropdownMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
||||
>(({ className, sideOffset = 4, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Portal>
|
||||
<DropdownMenuPrimitive.Content
|
||||
ref={ref}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
));
|
||||
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
||||
|
||||
const DropdownMenuItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-4 py-3 text-[1.2rem] outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
||||
|
||||
const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
||||
>(({ className, children, checked, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className,
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<Check className="h-4 w-4" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.CheckboxItem>
|
||||
));
|
||||
DropdownMenuCheckboxItem.displayName =
|
||||
DropdownMenuPrimitive.CheckboxItem.displayName;
|
||||
|
||||
const DropdownMenuRadioItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.RadioItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<Circle className="h-2 w-2 fill-current" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.RadioItem>
|
||||
));
|
||||
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
||||
|
||||
const DropdownMenuLabel = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"px-2 py-1.5 text-sm font-semibold",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
||||
|
||||
const DropdownMenuSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Separator
|
||||
ref={ref}
|
||||
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
||||
|
||||
const DropdownMenuShortcut = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
||||
return (
|
||||
<span
|
||||
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
};
|
||||
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
||||
|
||||
export {
|
||||
DropdownMenu,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuRadioItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuShortcut,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuSub,
|
||||
DropdownMenuSubContent,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuRadioGroup,
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
.file-search-container {
|
||||
@apply flex w-full max-w-sm items-center gap-2;
|
||||
}
|
||||
.file-search-preview {
|
||||
@apply h-12 w-full min-w-56 overflow-x-auto whitespace-nowrap rounded-md border border-input bg-background px-3 py-2 text-[1.2rem];
|
||||
}
|
||||
.file-search-label {
|
||||
@apply flex-shrink-0 cursor-pointer rounded-sm border border-input bg-muted px-4 py-2 text-[1.2rem] font-medium text-muted-foreground;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { FileSearch } from ".";
|
||||
|
||||
const meta: Meta<typeof FileSearch> = {
|
||||
title: "UI/FileSearch",
|
||||
component: FileSearch,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/input#file)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof FileSearch>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => <FileSearch id="file-search" />,
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import "./file-search.css";
|
||||
|
||||
import { Input } from "../input";
|
||||
import { cn } from "../../lib/utils";
|
||||
import { combineFileName, validFileType } from "./utils";
|
||||
|
||||
type FileSearchProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
||||
id: string;
|
||||
files?: ReadonlyArray<File>;
|
||||
};
|
||||
|
||||
export function FileSearch({
|
||||
id,
|
||||
className,
|
||||
files,
|
||||
...props
|
||||
}: FileSearchProps) {
|
||||
return (
|
||||
<div className={cn("file-search-container", className)}>
|
||||
<Input id={id} type="file" className="sr-only" {...props} />
|
||||
<div className="file-search-preview">
|
||||
{files?.filter(validFileType).map(combineFileName).join(", ")}
|
||||
</div>
|
||||
<label htmlFor={id} className="file-search-label">
|
||||
파일 선택
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// TODO: 파일 타입 정책 협의 후 수정
|
||||
const fileTypes = [
|
||||
"image/apng",
|
||||
"image/bmp",
|
||||
"image/gif",
|
||||
"image/jpeg",
|
||||
"image/pjpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/tiff",
|
||||
"image/webp",
|
||||
"image/x-icon",
|
||||
"video/mp4",
|
||||
"video/mpeg",
|
||||
"video/ogg",
|
||||
"video/webm",
|
||||
"video/3gpp",
|
||||
"video/3gpp2",
|
||||
"application/pdf",
|
||||
"application/msword",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"application/vnd.ms-excel",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"application/vnd.ms-powerpoint",
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
"text/plain",
|
||||
"text/csv",
|
||||
];
|
||||
|
||||
export function validFileType(file: File) {
|
||||
if (!fileTypes.includes(file.type)) throw new Error("Invalid file type");
|
||||
return true;
|
||||
}
|
||||
|
||||
export function combineFileName(file: File) {
|
||||
return `${file.name}.${file.type.split("/")[1]}`;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
export * from "./accordion";
|
||||
export * from "./badge";
|
||||
export * from "./button";
|
||||
export * from "./calendar";
|
||||
export * from "./checkbox";
|
||||
export * from "./date-picker";
|
||||
export * from "./dropdown-menu";
|
||||
export * from "./input";
|
||||
export * from "./file-search";
|
||||
export * from "./input";
|
||||
export * from "./label";
|
||||
export * from "./loading";
|
||||
export * from "./popover";
|
||||
export * from "./radio-group";
|
||||
export * from "./slider";
|
||||
export * from "./switch";
|
||||
export * from "./tabs";
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
||||
({ className, type, ...props }, ref) => {
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
className={cn(
|
||||
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
className,
|
||||
)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
Input.displayName = "Input";
|
||||
|
||||
export { Input };
|
||||
@@ -0,0 +1,24 @@
|
||||
import * as React from "react";
|
||||
import * as LabelPrimitive from "@radix-ui/react-label";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
const labelVariants = cva(
|
||||
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
||||
);
|
||||
|
||||
const Label = React.forwardRef<
|
||||
React.ElementRef<typeof LabelPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
||||
VariantProps<typeof labelVariants>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<LabelPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(labelVariants(), className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
Label.displayName = LabelPrimitive.Root.displayName;
|
||||
|
||||
export { Label };
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Header } from "./header";
|
||||
import { LNB } from "./lnb";
|
||||
import "./common.css";
|
||||
import { Footer } from "./footer";
|
||||
|
||||
export function BaseLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div>
|
||||
<Header />
|
||||
<div className="flex h-[calc(100vh-50px)]">
|
||||
<LNB />
|
||||
<div className="flex flex-1 flex-col">
|
||||
<div className="flex-1">{children}</div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
@charset "utf-8";
|
||||
|
||||
@font-face {
|
||||
font-family: "Noto Sans KR";
|
||||
font-style: normal;
|
||||
src: url("../fonts/NotoSansKR-Light.otf") format("opentype");
|
||||
font-weight: 300;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Noto Sans KR";
|
||||
font-style: normal;
|
||||
src: url("../fonts/NotoSansKR-Regular.otf") format("opentype");
|
||||
font-weight: 400;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Noto Sans KR";
|
||||
font-style: normal;
|
||||
src: url("../fonts/NotoSansKR-Medium.otf") format("opentype");
|
||||
font-weight: 500;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Noto Sans KR";
|
||||
font-style: normal;
|
||||
src: url("../fonts/NotoSansKR-Bold.otf") format("opentype");
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#lnb {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
-webkit-transition: all 0.3s ease-in-out;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
#lnb .mline {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
font-size: 12px;
|
||||
padding: 6px 0 6px 14px;
|
||||
font-weight: 500;
|
||||
color: #b1b1b1;
|
||||
display: block;
|
||||
}
|
||||
#lnb h1 {
|
||||
height: 40px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
line-height: 1.8;
|
||||
letter-spacing: -2px;
|
||||
background: #d71a21;
|
||||
}
|
||||
#lnb > ul {
|
||||
position: relative;
|
||||
}
|
||||
#lnb > ul > li {
|
||||
position: relative;
|
||||
padding: 0px 0;
|
||||
width: 93%;
|
||||
margin: 0 3.5%;
|
||||
}
|
||||
#lnb > ul > li.on.noDepth a {
|
||||
color: #ffffff;
|
||||
background: #40a5ff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
#lnb > ul > li.on > a {
|
||||
background: #ffffff;
|
||||
color: #3a8bdd;
|
||||
}
|
||||
#lnb > ul > li > a {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 14px 0;
|
||||
margin: 0 auto;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
background: #ffffff;
|
||||
border-radius: 5px;
|
||||
text-indent: 7px;
|
||||
color: #777777;
|
||||
transition: all 0.1s ease-in-out;
|
||||
white-space: nowrap;
|
||||
line-height: 16px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#lnb > ul > li > a i.arrow {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: auto;
|
||||
right: 8px;
|
||||
font-size: 14px;
|
||||
text-indent: 0;
|
||||
color: #c5c5c5;
|
||||
}
|
||||
#lnb > ul > li a:hover {
|
||||
color: #277cc7;
|
||||
background: #edf4fb;
|
||||
}
|
||||
#lnb > ul > li.on a i.arrow {
|
||||
transform: rotate(-180deg);
|
||||
margin-top: 0px;
|
||||
}
|
||||
#lnb > ul > li .mnicon_1 {
|
||||
position: relative;
|
||||
top: 1px;
|
||||
transition: all 0.1s ease-in-out;
|
||||
font-size: 15px;
|
||||
padding: 0 8px 0 0;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
#lnb > ul > li > ul {
|
||||
display: none;
|
||||
background: #eaf5ff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
#lnb > ul > li > ul > li {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
#lnb > ul > li > ul > li > a {
|
||||
display: block;
|
||||
padding: 10px 0;
|
||||
font-size: 13px;
|
||||
text-indent: 30px;
|
||||
font-weight: 400;
|
||||
color: #6387ad;
|
||||
background-color: #eaf5ff;
|
||||
border-radius: 5px;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
#lnb > ul > li > ul > li > a i {
|
||||
font-size: 16px;
|
||||
padding: 0 10px 0 0;
|
||||
position: relative;
|
||||
top: 3px;
|
||||
}
|
||||
#lnb > ul > li > ul > li > a i.right {
|
||||
font-size: 11px;
|
||||
padding: 0 0 0 2px;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
#lnb > ul > li > ul > li .mnicon_1 {
|
||||
position: absolute;
|
||||
top: 11px;
|
||||
left: 37px;
|
||||
width: 23px;
|
||||
height: 23px;
|
||||
-webkit-transition: all 0.1s ease-in-out;
|
||||
transition: all 0.1s ease-in-out;
|
||||
}
|
||||
#lnb > ul > li > ul > li.on a {
|
||||
color: #ffffff;
|
||||
background: #2c94ff;
|
||||
}
|
||||
#lnb > ul > li > ul > li a:hover {
|
||||
color: #227fd2;
|
||||
background: #deeefd;
|
||||
}
|
||||
#lnb > ul > li > ul > li.on a:hover {
|
||||
color: #ffffff;
|
||||
background: #40a5ff;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export function Footer() {
|
||||
return (
|
||||
<footer className="flex h-[5rem] w-full items-center border-t border-solid border-border p-4">
|
||||
<p>© 2025 Ona And All. All Rights Reserved.</p>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { BASE_ASSETS_PATH } from "../../env";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
} from "../dropdown-menu";
|
||||
import { Button } from "../button";
|
||||
|
||||
export function Header() {
|
||||
return (
|
||||
<header className="sticky top-0 box-border flex h-[5rem] w-full items-center justify-between border-b border-solid border-border">
|
||||
<div className="flex items-center">
|
||||
<div className="MobMenuBtn">
|
||||
<img src={`${BASE_ASSETS_PATH}/images/mob_menuBtn.svg`} />
|
||||
</div>
|
||||
<h1 className="flex items-center gap-4">
|
||||
<img
|
||||
src={`${BASE_ASSETS_PATH}/images/logo.png`}
|
||||
className="h-[3rem]"
|
||||
alt="logo"
|
||||
/>
|
||||
<span className="text-[1.8rem] font-semibold">통합플랫폼관리</span>
|
||||
</h1>
|
||||
</div>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button className="group m-0 flex h-[3rem] items-center !bg-background px-4 py-0 text-label">
|
||||
<i className="diveicon di-account-circle static translate-y-0.5 pr-2 text-3xl" />
|
||||
관리자
|
||||
<i className="diveicon di-chevron-down static p-0 transition-transform group-data-[state=open]:rotate-180" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<DropdownMenuItem>프로필</DropdownMenuItem>
|
||||
<DropdownMenuItem>설정</DropdownMenuItem>
|
||||
<DropdownMenuItem>로그아웃</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { BaseLayout } from "./base";
|
||||
import "./stories.css";
|
||||
|
||||
const meta: Meta<typeof BaseLayout> = {
|
||||
title: "Layout/Base",
|
||||
component: BaseLayout,
|
||||
parameters: {
|
||||
layout: "fullscreen",
|
||||
controls: { disable: true },
|
||||
actions: { disable: true },
|
||||
},
|
||||
tags: ["!autodocs"],
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof BaseLayout>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<BaseLayout>
|
||||
<div className="h-full bg-muted p-4 text-xl text-muted-foreground">
|
||||
개발 영역
|
||||
</div>
|
||||
</BaseLayout>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,104 @@
|
||||
export function LNB() {
|
||||
return (
|
||||
<div
|
||||
id="lnb"
|
||||
className="!w-[22rem] overflow-auto border-r border-solid border-border"
|
||||
>
|
||||
<ul>
|
||||
<li id="m_dashboard">
|
||||
<a href="#none" className="!bg-background">
|
||||
Dashboard
|
||||
<i
|
||||
className="diveicon di-diveicon di-chevron-down arrow"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</a>
|
||||
</li>
|
||||
<div className="mline">PAGES</div>
|
||||
<li id="m_page_board">
|
||||
<a href="#none" className="!bg-background">
|
||||
콘텐츠 관리
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_page_mem">
|
||||
<a href="#none" className="!bg-background">
|
||||
로그인 & 회원관리
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_page_manage">
|
||||
<a href="#none" className="!bg-background">
|
||||
페이지 관리
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_page_example">
|
||||
<a href="#none" className="!bg-background">
|
||||
샘플 페이지
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_layouts">
|
||||
<a href="#none" className="!bg-background">
|
||||
페이지 레이아웃
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<div className="mline">COMPONENTS</div>
|
||||
<li id="m_charts">
|
||||
<a href="#none" className="!bg-background">
|
||||
Charts
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_tables">
|
||||
<a href="#none" className="!bg-background">
|
||||
Tables
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_elements">
|
||||
<a href="#none" className="!bg-background">
|
||||
Elements
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_tabs">
|
||||
<a href="#none" className="!bg-background">
|
||||
Tabs
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_popup">
|
||||
<a href="#none" className="!bg-background">
|
||||
Modal
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_swipe">
|
||||
<a href="#none" className="!bg-background">
|
||||
Swipe
|
||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_icon">
|
||||
<a href="#none" className="!bg-background">
|
||||
Font Icon
|
||||
</a>
|
||||
</li>
|
||||
<div className="mline">OTHERS</div>
|
||||
<li id="m_elements">
|
||||
<a href="#none" className="!bg-background">
|
||||
Menu Label <span className="ar_label_box red">NEW</span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="m_elements">
|
||||
<a href="#none" className="!bg-background">
|
||||
External Link
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#storybook-root > div {
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import "./loading.css";
|
||||
|
||||
interface LoadingWithAnimationProps {
|
||||
color?: "primary" | "secondary";
|
||||
}
|
||||
|
||||
const LoadingWithAnimation = ({
|
||||
color = "primary",
|
||||
}: LoadingWithAnimationProps) => {
|
||||
return (
|
||||
<div className="loading loading-animation">
|
||||
<i className={`spinner ${color}`} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
interface LoadingWithImageProps {
|
||||
color?: "primary" | "secondary";
|
||||
}
|
||||
|
||||
const LoadingWithImage = ({ color = "primary" }: LoadingWithImageProps) => {
|
||||
return (
|
||||
<div className="loading loading-image">
|
||||
<i className={`spinner ${color}`} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export { LoadingWithAnimation, LoadingWithImage };
|
||||
@@ -0,0 +1,28 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
.loading {
|
||||
@apply absolute left-1/2 top-1/2 size-full animate-spin-parent;
|
||||
}
|
||||
.spinner {
|
||||
@apply inline-block size-full animate-spin-child;
|
||||
}
|
||||
.loading-animation .spinner {
|
||||
@apply rounded-full border-[0.3rem];
|
||||
}
|
||||
.loading-animation .spinner.primary {
|
||||
@apply border-t-primary;
|
||||
}
|
||||
.loading-animation .spinner.secondary {
|
||||
@apply border-t-white;
|
||||
}
|
||||
.loading-image {
|
||||
@apply duration-1000;
|
||||
}
|
||||
.loading-image .spinner.primary {
|
||||
@apply bg-[url('../../../public/assets/images/loading_primary.png')] bg-no-repeat duration-0;
|
||||
}
|
||||
.loading-image .spinner.secondary {
|
||||
@apply bg-[url('../../../public/assets/images/loading_secondary.png')] bg-no-repeat duration-0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { LoadingWithAnimation, LoadingWithImage } from ".";
|
||||
|
||||
const meta: Meta<typeof LoadingWithAnimation> = {
|
||||
title: "UI/Loading",
|
||||
component: LoadingWithAnimation,
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof LoadingWithAnimation>;
|
||||
|
||||
export const Primary: Story = {
|
||||
render: () => (
|
||||
<div className="rounded-lg bg-secondary p-10 dark:bg-transparent">
|
||||
<div className="relative size-[5rem]">
|
||||
<LoadingWithAnimation color="primary" />
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const Secondary: Story = {
|
||||
render: () => (
|
||||
<div className="rounded-lg bg-secondary p-10 dark:bg-transparent">
|
||||
<div className="relative size-[5rem]">
|
||||
<LoadingWithAnimation color="secondary" />
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const PrimaryWithImage: Story = {
|
||||
render: () => (
|
||||
<div className="rounded-lg bg-secondary p-10 dark:bg-transparent">
|
||||
<div className="relative size-[5rem]">
|
||||
<LoadingWithImage color="primary" />
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const SecondaryWithImage: Story = {
|
||||
render: () => (
|
||||
<div className="rounded-lg bg-secondary p-10 dark:bg-transparent">
|
||||
<div className="relative size-[5rem]">
|
||||
<LoadingWithImage color="secondary" />
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import * as React from "react";
|
||||
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
const Popover = PopoverPrimitive.Root;
|
||||
|
||||
const PopoverTrigger = PopoverPrimitive.Trigger;
|
||||
|
||||
const PopoverContent = React.forwardRef<
|
||||
React.ElementRef<typeof PopoverPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
||||
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
||||
<PopoverPrimitive.Portal>
|
||||
<PopoverPrimitive.Content
|
||||
ref={ref}
|
||||
align={align}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</PopoverPrimitive.Portal>
|
||||
));
|
||||
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
||||
|
||||
export { Popover, PopoverTrigger, PopoverContent };
|
||||
@@ -0,0 +1,39 @@
|
||||
import "./radio-group.css";
|
||||
|
||||
import * as React from "react";
|
||||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
||||
|
||||
const RadioGroup = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> & {
|
||||
variant?: "radio" | "button";
|
||||
color?: "primary" | "secondary";
|
||||
shape?: "square" | "rounded";
|
||||
}
|
||||
>(
|
||||
(
|
||||
{ variant = "radio", color = "primary", shape = "square", ...props },
|
||||
ref,
|
||||
) => {
|
||||
return (
|
||||
<RadioGroupPrimitive.Root
|
||||
{...props}
|
||||
ref={ref}
|
||||
data-variant={variant}
|
||||
data-color={color}
|
||||
data-shape={shape}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
||||
|
||||
const RadioGroupItem = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
||||
>(({ ...props }, ref) => {
|
||||
return <RadioGroupPrimitive.Item ref={ref} {...props} />;
|
||||
});
|
||||
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
||||
|
||||
export { RadioGroup, RadioGroupItem };
|
||||
@@ -0,0 +1,13 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
div[role="radiogroup"] {
|
||||
@apply flex flex-row gap-4 data-[orientation="vertical"]:flex-col data-[orientation="vertical"]:gap-2;
|
||||
}
|
||||
button[role="radio"] {
|
||||
@apply aspect-square size-[18px] rounded-full bg-[url(../../../public/assets/images/checkbox_off.png)] bg-contain text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-[url(../../../public/assets/images/checkbox_on.png)];
|
||||
}
|
||||
button[role="radio"] + label {
|
||||
@apply text-[1.3rem] font-medium text-label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { RadioGroup, RadioGroupItem } from ".";
|
||||
import { Label } from "../label";
|
||||
const meta: Meta<typeof RadioGroup> = {
|
||||
title: "Elements/RadioGroup",
|
||||
component: RadioGroup,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/radio-group)
|
||||
- [API Reference](https://www.radix-ui.com/primitives/docs/components/radio-group#api-reference)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof RadioGroup>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable">
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="default" id="r1" />
|
||||
<Label htmlFor="r1">Default</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="comfortable" id="r2" />
|
||||
<Label htmlFor="r2">Comfortable</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="compact" id="r3" />
|
||||
<Label htmlFor="r3">Compact</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
import "./slider.css";
|
||||
|
||||
import * as React from "react";
|
||||
import * as SliderPrimitive from "@radix-ui/react-slider";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
const Slider = React.forwardRef<
|
||||
React.ElementRef<typeof SliderPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div>
|
||||
<SliderPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("slider-root", className)}
|
||||
{...props}
|
||||
>
|
||||
<SliderPrimitive.Track className="slider-track">
|
||||
<SliderPrimitive.Range className="slider-range" />
|
||||
</SliderPrimitive.Track>
|
||||
<SliderPrimitive.Thumb className="slider-thumb">
|
||||
<span className="slider-thumb-label">
|
||||
{props.value?.[0] ?? props.min ?? 0}
|
||||
</span>
|
||||
</SliderPrimitive.Thumb>
|
||||
</SliderPrimitive.Root>
|
||||
<div className="slider-bottom">
|
||||
<span className="slider-bottom-label">{props.min ?? 0}</span>
|
||||
<span className="slider-bottom-label">{props.max ?? 100}</span>
|
||||
</div>
|
||||
</div>
|
||||
));
|
||||
Slider.displayName = SliderPrimitive.Root.displayName;
|
||||
|
||||
export { Slider };
|
||||
@@ -0,0 +1,25 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
.slider-root {
|
||||
@apply relative flex w-full min-w-96 touch-none select-none items-center;
|
||||
}
|
||||
.slider-track {
|
||||
@apply relative h-3 w-full grow overflow-hidden rounded-full bg-muted;
|
||||
}
|
||||
.slider-range {
|
||||
@apply absolute h-full bg-primary data-[disabled]:bg-muted;
|
||||
}
|
||||
.slider-thumb {
|
||||
@apply relative block size-6 cursor-grab rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:cursor-grabbing data-[disabled]:cursor-not-allowed data-[disabled]:bg-muted;
|
||||
}
|
||||
.slider-thumb-label {
|
||||
@apply absolute -top-2 left-1/2 -translate-x-1/2 -translate-y-[100%] rounded-sm bg-primary px-2 text-[1.3rem] text-white;
|
||||
}
|
||||
.slider-bottom {
|
||||
@apply flex w-full justify-between pt-1;
|
||||
}
|
||||
.slider-bottom-label {
|
||||
@apply text-label text-[1.2rem];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { useState } from "react";
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { Slider } from ".";
|
||||
|
||||
const meta: Meta<typeof Slider> = {
|
||||
title: "Elements/Slider",
|
||||
component: Slider,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/slider)
|
||||
- [API Reference](https://www.radix-ui.com/primitives/docs/components/slider#api-reference)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Slider>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => <ControlledSlider />,
|
||||
};
|
||||
|
||||
function ControlledSlider() {
|
||||
const [value, setValue] = useState([50]);
|
||||
const handleValueChange = (value: number[]) => {
|
||||
setValue(value);
|
||||
};
|
||||
|
||||
return <Slider value={value} onValueChange={handleValueChange} />;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import "./switch.css";
|
||||
|
||||
import * as React from "react";
|
||||
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
||||
|
||||
const Switch = React.forwardRef<
|
||||
React.ElementRef<typeof SwitchPrimitives.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
||||
>(({ ...props }, ref) => (
|
||||
<SwitchPrimitives.Root {...props} ref={ref}>
|
||||
<SwitchPrimitives.Thumb />
|
||||
</SwitchPrimitives.Root>
|
||||
));
|
||||
Switch.displayName = SwitchPrimitives.Root.displayName;
|
||||
|
||||
export { Switch };
|
||||
@@ -0,0 +1,10 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
button[role="switch"] {
|
||||
@apply inline-flex h-[2.2rem] w-[5.3rem] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent bg-muted-foreground bg-[url(../../../public/assets/images/togbtn_off.png)] bg-[length:2.9rem] bg-[center_right_.1rem] bg-no-repeat transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:bg-[url(../../../public/assets/images/togbtn_on.png)] data-[state=checked]:bg-[center_left_.2rem];
|
||||
}
|
||||
button[role="switch"] > span {
|
||||
@apply pointer-events-none block size-[1.8rem] rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[3.1rem] data-[state=unchecked]:translate-x-0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { Switch } from ".";
|
||||
|
||||
const meta: Meta<typeof Switch> = {
|
||||
title: "Elements/Switch",
|
||||
component: Switch,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/switch)
|
||||
- [API Reference](https://www.radix-ui.com/primitives/docs/components/switch#api-reference)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Switch>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => <Switch />,
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
import "./tabs.css";
|
||||
|
||||
import * as React from "react";
|
||||
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
const Tabs = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Root> & {
|
||||
variant?: "default" | "underline" | "outline";
|
||||
}
|
||||
>(({ className, variant = "default", ...props }, ref) => (
|
||||
<TabsPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("tabs", className)}
|
||||
data-variant={variant}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
Tabs.displayName = TabsPrimitive.Root.displayName;
|
||||
|
||||
const TabsList = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.List>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<TabsPrimitive.List
|
||||
ref={ref}
|
||||
className={cn("tabs-list", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TabsList.displayName = TabsPrimitive.List.displayName;
|
||||
|
||||
const TabsTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<TabsPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn("tabs-trigger", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
||||
|
||||
const TabsContent = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<TabsPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn("tabs-content", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
||||
|
||||
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
||||
@@ -0,0 +1,25 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
.tabs-list {
|
||||
@apply inline-flex items-center justify-center rounded-md border bg-background p-2 text-muted-foreground;
|
||||
}
|
||||
.tabs-trigger {
|
||||
@apply inline-flex items-center justify-center whitespace-nowrap rounded-sm px-12 py-4 text-[1.5rem] font-medium ring-offset-background transition-all hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-white;
|
||||
}
|
||||
.tabs-content {
|
||||
@apply mt-4 rounded-sm border border-border p-4 text-[1.4rem] text-muted-foreground shadow-[0px_0px_10px_-1px_rgba(0,0,0,0.06)] ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2;
|
||||
}
|
||||
.tabs[data-variant="underline"] .tabs-list {
|
||||
@apply rounded-none border-none;
|
||||
}
|
||||
.tabs[data-variant="underline"] .tabs-trigger {
|
||||
@apply rounded-none border-b-2 border-b-border bg-background text-muted-foreground data-[state=active]:border-b-foreground data-[state=active]:text-foreground;
|
||||
}
|
||||
.tabs[data-variant="outline"] .tabs-list {
|
||||
@apply rounded-none border-none;
|
||||
}
|
||||
.tabs[data-variant="outline"] .tabs-trigger {
|
||||
@apply relative rounded-none rounded-t-sm border-border bg-background text-muted-foreground after:absolute after:bottom-0 after:left-0 after:h-[0.1rem] after:w-full after:bg-border after:content-[''] data-[state=active]:border data-[state=active]:border-b-0 data-[state=active]:border-border data-[state=active]:text-foreground data-[state=active]:after:bg-transparent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from ".";
|
||||
|
||||
const meta: Meta<typeof Tabs> = {
|
||||
title: "Elements/Tabs",
|
||||
component: Tabs,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `
|
||||
- [Docs](https://ui.shadcn.com/docs/components/tabs)
|
||||
- [API Reference](https://www.radix-ui.com/primitives/docs/components/tabs#api-reference)
|
||||
`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Tabs>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<Tabs defaultValue="account" className="w-[400px]">
|
||||
<TabsList>
|
||||
<TabsTrigger value="account">Account</TabsTrigger>
|
||||
<TabsTrigger value="password">Password</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="account">
|
||||
<p>Make changes to your account here. Click save when you're done.</p>
|
||||
</TabsContent>
|
||||
<TabsContent value="password">
|
||||
<p>Change your password here. After saving, you'll be logged out.</p>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
),
|
||||
};
|
||||
|
||||
export const Underline: Story = {
|
||||
render: () => (
|
||||
<Tabs defaultValue="account" className="w-[400px]" variant="underline">
|
||||
<TabsList>
|
||||
<TabsTrigger value="account">Account</TabsTrigger>
|
||||
<TabsTrigger value="password">Password</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="account">
|
||||
<p>Make changes to your account here. Click save when you're done.</p>
|
||||
</TabsContent>
|
||||
<TabsContent value="password">
|
||||
<p>Change your password here. After saving, you'll be logged out.</p>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
),
|
||||
};
|
||||
|
||||
export const Outline: Story = {
|
||||
render: () => (
|
||||
<Tabs defaultValue="account" className="w-[400px]" variant="outline">
|
||||
<TabsList>
|
||||
<TabsTrigger value="account">Account</TabsTrigger>
|
||||
<TabsTrigger value="password">Password</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="account">
|
||||
<p>Make changes to your account here. Click save when you're done.</p>
|
||||
</TabsContent>
|
||||
<TabsContent value="password">
|
||||
<p>Change your password here. After saving, you'll be logged out.</p>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
),
|
||||
};
|
||||
Reference in New Issue
Block a user