feat(admin-ui): shadcn primitives + @/ui barrel (Stage 2.1)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import * as React from 'react'
|
||||
import { cva, type VariantProps } from 'class-variance-authority'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
/**
|
||||
* Alert / inline message — статусная карточка с border-left accent.
|
||||
* shadcn-style API: children может быть [Title, Description] или произвольный.
|
||||
*/
|
||||
const alertVariants = cva(
|
||||
'relative w-full rounded-md border-l-4 px-4 py-3 text-sm [&>svg]:text-ink-2 [&>svg]:size-4 [&>svg]:absolute [&>svg]:left-3 [&>svg]:top-3 [&>svg+*]:pl-6',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
info: 'border-l-accent bg-accent-bg text-ink',
|
||||
success: 'border-l-green bg-green-bg text-ink',
|
||||
warning: 'border-l-warn bg-warn-bg text-ink',
|
||||
danger: 'border-l-pink bg-pink-bg text-ink',
|
||||
neutral: 'border-l-line bg-surface-2 text-ink',
|
||||
},
|
||||
},
|
||||
defaultVariants: { variant: 'info' },
|
||||
},
|
||||
)
|
||||
|
||||
export type AlertProps = React.HTMLAttributes<HTMLDivElement> &
|
||||
VariantProps<typeof alertVariants> & {
|
||||
title?: React.ReactNode
|
||||
}
|
||||
|
||||
export const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
|
||||
function Alert({ className, variant, title, children, ...props }, ref) {
|
||||
return (
|
||||
<div ref={ref} role="alert" className={cn(alertVariants({ variant }), className)} {...props}>
|
||||
{title && <div className="font-medium mb-0.5">{title}</div>}
|
||||
<div className="text-ink-2 text-[13px] leading-snug">{children}</div>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user