forked from baron/baron-sso
button badge input card 공용화
This commit is contained in:
@@ -1,38 +1,17 @@
|
|||||||
import { type VariantProps, cva } from "class-variance-authority";
|
|
||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
import {
|
||||||
|
type CommonBadgeVariant,
|
||||||
|
getCommonBadgeClasses,
|
||||||
|
} from "../../../../common/ui/badge";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
const badgeVariants = cva(
|
|
||||||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default:
|
|
||||||
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
||||||
secondary:
|
|
||||||
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
||||||
outline: "text-foreground",
|
|
||||||
muted: "border-border bg-secondary/60 text-muted-foreground",
|
|
||||||
success:
|
|
||||||
"border-transparent bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300",
|
|
||||||
warning:
|
|
||||||
"border-transparent bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-200",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export interface BadgeProps
|
export interface BadgeProps
|
||||||
extends React.HTMLAttributes<HTMLDivElement>,
|
extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
VariantProps<typeof badgeVariants> {}
|
variant?: CommonBadgeVariant;
|
||||||
|
|
||||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
||||||
return (
|
|
||||||
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Badge, badgeVariants };
|
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||||
|
return <div className={cn(getCommonBadgeClasses({ variant }), className)} {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Badge };
|
||||||
|
|||||||
@@ -1,41 +1,16 @@
|
|||||||
import { Slot } from "@radix-ui/react-slot";
|
import { Slot } from "@radix-ui/react-slot";
|
||||||
import { type VariantProps, cva } from "class-variance-authority";
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
import {
|
||||||
|
type CommonButtonSize,
|
||||||
|
type CommonButtonVariant,
|
||||||
|
getCommonButtonClasses,
|
||||||
|
} from "../../../../common/ui/button";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
const buttonVariants = cva(
|
|
||||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-semibold 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 ring-offset-background",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default:
|
|
||||||
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
||||||
secondary:
|
|
||||||
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
||||||
outline:
|
|
||||||
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
||||||
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
||||||
destructive:
|
|
||||||
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
||||||
muted: "bg-muted text-muted-foreground hover:bg-muted/80",
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
default: "h-10 px-4 py-2",
|
|
||||||
sm: "h-9 rounded-md px-3",
|
|
||||||
lg: "h-11 rounded-md px-6 text-base",
|
|
||||||
icon: "h-10 w-10",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
size: "default",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export interface ButtonProps
|
export interface ButtonProps
|
||||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
VariantProps<typeof buttonVariants> {
|
variant?: CommonButtonVariant;
|
||||||
|
size?: CommonButtonSize;
|
||||||
asChild?: boolean;
|
asChild?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +19,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
const Comp = asChild ? Slot : "button";
|
const Comp = asChild ? Slot : "button";
|
||||||
return (
|
return (
|
||||||
<Comp
|
<Comp
|
||||||
className={cn(buttonVariants({ variant, size, className }))}
|
className={cn(getCommonButtonClasses({ variant, size }), className)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
@@ -53,4 +28,4 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
);
|
);
|
||||||
Button.displayName = "Button";
|
Button.displayName = "Button";
|
||||||
|
|
||||||
export { Button, buttonVariants };
|
export { Button };
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
import {
|
||||||
|
commonCardClass,
|
||||||
|
commonCardContentClass,
|
||||||
|
commonCardDescriptionClass,
|
||||||
|
commonCardFooterClass,
|
||||||
|
commonCardHeaderClass,
|
||||||
|
commonCardTitleClass,
|
||||||
|
} from "../../../../common/ui/card";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
function Card({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
function Card({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(commonCardClass, className)}
|
||||||
"rounded-2xl border border-border bg-card/90 text-card-foreground shadow-card",
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -18,10 +23,7 @@ function CardHeader({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={cn(commonCardHeaderClass, className)} {...props} />
|
||||||
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,10 +32,7 @@ function CardTitle({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLHeadingElement>) {
|
}: React.HTMLAttributes<HTMLHeadingElement>) {
|
||||||
return (
|
return (
|
||||||
<h3
|
<h3 className={cn(commonCardTitleClass, className)} {...props} />
|
||||||
className={cn("text-lg font-semibold leading-none", className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ function CardDescription({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLParagraphElement>) {
|
}: React.HTMLAttributes<HTMLParagraphElement>) {
|
||||||
return (
|
return (
|
||||||
<p className={cn("text-sm text-muted-foreground", className)} {...props} />
|
<p className={cn(commonCardDescriptionClass, className)} {...props} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ function CardContent({
|
|||||||
className,
|
className,
|
||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return <div className={cn("p-6 pt-0", className)} {...props} />;
|
return <div className={cn(commonCardContentClass, className)} {...props} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function CardFooter({
|
function CardFooter({
|
||||||
@@ -58,7 +57,7 @@ function CardFooter({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
<div className={cn(commonCardFooterClass, className)} {...props} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
import { commonInputClass } from "../../../../common/ui/input";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
export interface InputProps
|
export interface InputProps
|
||||||
@@ -10,7 +11,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|||||||
<input
|
<input
|
||||||
type={type}
|
type={type}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex h-10 w-full rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium 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",
|
commonInputClass,
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
26
common/ui/badge.ts
Normal file
26
common/ui/badge.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
export const commonBadgeBaseClass =
|
||||||
|
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2";
|
||||||
|
|
||||||
|
export const commonBadgeVariantClasses = {
|
||||||
|
default:
|
||||||
|
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
||||||
|
secondary:
|
||||||
|
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||||
|
outline: "text-foreground",
|
||||||
|
muted: "border-border bg-secondary/60 text-muted-foreground",
|
||||||
|
success:
|
||||||
|
"border-transparent bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300",
|
||||||
|
warning:
|
||||||
|
"border-transparent bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-200",
|
||||||
|
info: "border-transparent bg-blue-500 text-white hover:bg-blue-500/90",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type CommonBadgeVariant = keyof typeof commonBadgeVariantClasses;
|
||||||
|
|
||||||
|
export function getCommonBadgeClasses({
|
||||||
|
variant = "default",
|
||||||
|
}: {
|
||||||
|
variant?: CommonBadgeVariant;
|
||||||
|
}) {
|
||||||
|
return [commonBadgeBaseClass, commonBadgeVariantClasses[variant]].join(" ");
|
||||||
|
}
|
||||||
37
common/ui/button.ts
Normal file
37
common/ui/button.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
export const commonButtonBaseClass =
|
||||||
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-semibold 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 ring-offset-background";
|
||||||
|
|
||||||
|
export const commonButtonVariantClasses = {
|
||||||
|
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
||||||
|
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||||
|
outline:
|
||||||
|
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
||||||
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
||||||
|
destructive:
|
||||||
|
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
||||||
|
muted: "bg-muted text-muted-foreground hover:bg-muted/80",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const commonButtonSizeClasses = {
|
||||||
|
default: "h-10 px-4 py-2",
|
||||||
|
sm: "h-9 rounded-md px-3",
|
||||||
|
lg: "h-11 rounded-md px-6 text-base",
|
||||||
|
icon: "h-10 w-10",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type CommonButtonVariant = keyof typeof commonButtonVariantClasses;
|
||||||
|
export type CommonButtonSize = keyof typeof commonButtonSizeClasses;
|
||||||
|
|
||||||
|
export function getCommonButtonClasses({
|
||||||
|
variant = "default",
|
||||||
|
size = "default",
|
||||||
|
}: {
|
||||||
|
variant?: CommonButtonVariant;
|
||||||
|
size?: CommonButtonSize;
|
||||||
|
}) {
|
||||||
|
return [
|
||||||
|
commonButtonBaseClass,
|
||||||
|
commonButtonVariantClasses[variant],
|
||||||
|
commonButtonSizeClasses[size],
|
||||||
|
].join(" ");
|
||||||
|
}
|
||||||
7
common/ui/card.ts
Normal file
7
common/ui/card.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export const commonCardClass =
|
||||||
|
"rounded-2xl border border-border bg-card/90 text-card-foreground shadow-card";
|
||||||
|
export const commonCardHeaderClass = "flex flex-col space-y-1.5 p-6";
|
||||||
|
export const commonCardTitleClass = "text-lg font-semibold leading-none";
|
||||||
|
export const commonCardDescriptionClass = "text-sm text-muted-foreground";
|
||||||
|
export const commonCardContentClass = "p-6 pt-0";
|
||||||
|
export const commonCardFooterClass = "flex items-center p-6 pt-0";
|
||||||
2
common/ui/input.ts
Normal file
2
common/ui/input.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export const commonInputClass =
|
||||||
|
"flex h-10 w-full rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium 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";
|
||||||
@@ -1,39 +1,17 @@
|
|||||||
import { type VariantProps, cva } from "class-variance-authority";
|
|
||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
import {
|
||||||
|
type CommonBadgeVariant,
|
||||||
|
getCommonBadgeClasses,
|
||||||
|
} from "../../../../common/ui/badge";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
const badgeVariants = cva(
|
|
||||||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default:
|
|
||||||
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
||||||
secondary:
|
|
||||||
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
||||||
outline: "text-foreground",
|
|
||||||
muted: "border-border bg-secondary/60 text-muted-foreground",
|
|
||||||
success:
|
|
||||||
"border-transparent bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300",
|
|
||||||
warning:
|
|
||||||
"border-transparent bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-200",
|
|
||||||
info: "border-transparent bg-blue-500 text-white hover:bg-blue-500/90",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export interface BadgeProps
|
export interface BadgeProps
|
||||||
extends React.HTMLAttributes<HTMLDivElement>,
|
extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
VariantProps<typeof badgeVariants> {}
|
variant?: CommonBadgeVariant;
|
||||||
|
|
||||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
||||||
return (
|
|
||||||
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Badge, badgeVariants };
|
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||||
|
return <div className={cn(getCommonBadgeClasses({ variant }), className)} {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Badge };
|
||||||
|
|||||||
@@ -1,41 +1,16 @@
|
|||||||
import { Slot } from "@radix-ui/react-slot";
|
import { Slot } from "@radix-ui/react-slot";
|
||||||
import { type VariantProps, cva } from "class-variance-authority";
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
import {
|
||||||
|
type CommonButtonSize,
|
||||||
|
type CommonButtonVariant,
|
||||||
|
getCommonButtonClasses,
|
||||||
|
} from "../../../../common/ui/button";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
const buttonVariants = cva(
|
|
||||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-semibold 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 ring-offset-background",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default:
|
|
||||||
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
||||||
secondary:
|
|
||||||
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
||||||
outline:
|
|
||||||
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
||||||
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
||||||
destructive:
|
|
||||||
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
||||||
muted: "bg-muted text-muted-foreground hover:bg-muted/80",
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
default: "h-10 px-4 py-2",
|
|
||||||
sm: "h-9 rounded-md px-3",
|
|
||||||
lg: "h-11 rounded-md px-6 text-base",
|
|
||||||
icon: "h-10 w-10",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
size: "default",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export interface ButtonProps
|
export interface ButtonProps
|
||||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
VariantProps<typeof buttonVariants> {
|
variant?: CommonButtonVariant;
|
||||||
|
size?: CommonButtonSize;
|
||||||
asChild?: boolean;
|
asChild?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +19,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
const Comp = asChild ? Slot : "button";
|
const Comp = asChild ? Slot : "button";
|
||||||
return (
|
return (
|
||||||
<Comp
|
<Comp
|
||||||
className={cn(buttonVariants({ variant, size, className }))}
|
className={cn(getCommonButtonClasses({ variant, size }), className)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
@@ -53,4 +28,4 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
);
|
);
|
||||||
Button.displayName = "Button";
|
Button.displayName = "Button";
|
||||||
|
|
||||||
export { Button, buttonVariants };
|
export { Button };
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
import {
|
||||||
|
commonCardClass,
|
||||||
|
commonCardContentClass,
|
||||||
|
commonCardDescriptionClass,
|
||||||
|
commonCardFooterClass,
|
||||||
|
commonCardHeaderClass,
|
||||||
|
commonCardTitleClass,
|
||||||
|
} from "../../../../common/ui/card";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
function Card({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
function Card({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(commonCardClass, className)}
|
||||||
"rounded-2xl border border-border bg-card/90 text-card-foreground shadow-card",
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -18,10 +23,7 @@ function CardHeader({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={cn(commonCardHeaderClass, className)} {...props} />
|
||||||
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,10 +32,7 @@ function CardTitle({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLHeadingElement>) {
|
}: React.HTMLAttributes<HTMLHeadingElement>) {
|
||||||
return (
|
return (
|
||||||
<h3
|
<h3 className={cn(commonCardTitleClass, className)} {...props} />
|
||||||
className={cn("text-lg font-semibold leading-none", className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ function CardDescription({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLParagraphElement>) {
|
}: React.HTMLAttributes<HTMLParagraphElement>) {
|
||||||
return (
|
return (
|
||||||
<p className={cn("text-sm text-muted-foreground", className)} {...props} />
|
<p className={cn(commonCardDescriptionClass, className)} {...props} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ function CardContent({
|
|||||||
className,
|
className,
|
||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return <div className={cn("p-6 pt-0", className)} {...props} />;
|
return <div className={cn(commonCardContentClass, className)} {...props} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function CardFooter({
|
function CardFooter({
|
||||||
@@ -58,7 +57,7 @@ function CardFooter({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
<div className={cn(commonCardFooterClass, className)} {...props} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
import { commonInputClass } from "../../../../common/ui/input";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
export interface InputProps
|
export interface InputProps
|
||||||
@@ -10,7 +11,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|||||||
<input
|
<input
|
||||||
type={type}
|
type={type}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex h-10 w-full rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium 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",
|
commonInputClass,
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|||||||
@@ -1,39 +1,17 @@
|
|||||||
import { type VariantProps, cva } from "class-variance-authority";
|
|
||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
import {
|
||||||
|
type CommonBadgeVariant,
|
||||||
|
getCommonBadgeClasses,
|
||||||
|
} from "../../../../common/ui/badge";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
const badgeVariants = cva(
|
|
||||||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default:
|
|
||||||
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
||||||
secondary:
|
|
||||||
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
||||||
outline: "text-foreground",
|
|
||||||
muted: "border-border bg-secondary/60 text-muted-foreground",
|
|
||||||
success:
|
|
||||||
"border-transparent bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300",
|
|
||||||
warning:
|
|
||||||
"border-transparent bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-200",
|
|
||||||
info: "border-transparent bg-blue-500 text-white hover:bg-blue-500/90",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export interface BadgeProps
|
export interface BadgeProps
|
||||||
extends React.HTMLAttributes<HTMLDivElement>,
|
extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
VariantProps<typeof badgeVariants> {}
|
variant?: CommonBadgeVariant;
|
||||||
|
|
||||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
||||||
return (
|
|
||||||
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Badge, badgeVariants };
|
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||||
|
return <div className={cn(getCommonBadgeClasses({ variant }), className)} {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Badge };
|
||||||
|
|||||||
@@ -1,41 +1,16 @@
|
|||||||
import { Slot } from "@radix-ui/react-slot";
|
import { Slot } from "@radix-ui/react-slot";
|
||||||
import { type VariantProps, cva } from "class-variance-authority";
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
import {
|
||||||
|
type CommonButtonSize,
|
||||||
|
type CommonButtonVariant,
|
||||||
|
getCommonButtonClasses,
|
||||||
|
} from "../../../../common/ui/button";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
const buttonVariants = cva(
|
|
||||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-semibold 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 ring-offset-background",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default:
|
|
||||||
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
||||||
secondary:
|
|
||||||
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
||||||
outline:
|
|
||||||
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
||||||
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
||||||
destructive:
|
|
||||||
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
||||||
muted: "bg-muted text-muted-foreground hover:bg-muted/80",
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
default: "h-10 px-4 py-2",
|
|
||||||
sm: "h-9 rounded-md px-3",
|
|
||||||
lg: "h-11 rounded-md px-6 text-base",
|
|
||||||
icon: "h-10 w-10",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
size: "default",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export interface ButtonProps
|
export interface ButtonProps
|
||||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
VariantProps<typeof buttonVariants> {
|
variant?: CommonButtonVariant;
|
||||||
|
size?: CommonButtonSize;
|
||||||
asChild?: boolean;
|
asChild?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +19,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
const Comp = asChild ? Slot : "button";
|
const Comp = asChild ? Slot : "button";
|
||||||
return (
|
return (
|
||||||
<Comp
|
<Comp
|
||||||
className={cn(buttonVariants({ variant, size, className }))}
|
className={cn(getCommonButtonClasses({ variant, size }), className)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
@@ -53,4 +28,4 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
);
|
);
|
||||||
Button.displayName = "Button";
|
Button.displayName = "Button";
|
||||||
|
|
||||||
export { Button, buttonVariants };
|
export { Button };
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import type * as React from "react";
|
import type * as React from "react";
|
||||||
|
import {
|
||||||
|
commonCardClass,
|
||||||
|
commonCardContentClass,
|
||||||
|
commonCardDescriptionClass,
|
||||||
|
commonCardFooterClass,
|
||||||
|
commonCardHeaderClass,
|
||||||
|
commonCardTitleClass,
|
||||||
|
} from "../../../../common/ui/card";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
function Card({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
function Card({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(commonCardClass, className)}
|
||||||
"rounded-2xl border border-border bg-card/90 text-card-foreground shadow-card",
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -18,10 +23,7 @@ function CardHeader({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={cn(commonCardHeaderClass, className)} {...props} />
|
||||||
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,10 +32,7 @@ function CardTitle({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLHeadingElement>) {
|
}: React.HTMLAttributes<HTMLHeadingElement>) {
|
||||||
return (
|
return (
|
||||||
<h3
|
<h3 className={cn(commonCardTitleClass, className)} {...props} />
|
||||||
className={cn("text-lg font-semibold leading-none", className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ function CardDescription({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLParagraphElement>) {
|
}: React.HTMLAttributes<HTMLParagraphElement>) {
|
||||||
return (
|
return (
|
||||||
<p className={cn("text-sm text-muted-foreground", className)} {...props} />
|
<p className={cn(commonCardDescriptionClass, className)} {...props} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ function CardContent({
|
|||||||
className,
|
className,
|
||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return <div className={cn("p-6 pt-0", className)} {...props} />;
|
return <div className={cn(commonCardContentClass, className)} {...props} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function CardFooter({
|
function CardFooter({
|
||||||
@@ -58,7 +57,7 @@ function CardFooter({
|
|||||||
...props
|
...props
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
return (
|
return (
|
||||||
<div className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
<div className={cn(commonCardFooterClass, className)} {...props} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
import { commonInputClass } from "../../../../common/ui/input";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
export interface InputProps
|
export interface InputProps
|
||||||
@@ -10,7 +11,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|||||||
<input
|
<input
|
||||||
type={type}
|
type={type}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex h-10 w-full rounded-lg border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium 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",
|
commonInputClass,
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|||||||
Reference in New Issue
Block a user