mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-24 13:44:54 +00:00
64 lines
1.3 KiB
TypeScript
64 lines
1.3 KiB
TypeScript
import { ReactNode } from 'react'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
interface StackProps {
|
|
children: ReactNode
|
|
direction?: 'horizontal' | 'vertical'
|
|
spacing?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
align?: 'start' | 'center' | 'end' | 'stretch'
|
|
justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'
|
|
wrap?: boolean
|
|
className?: string
|
|
}
|
|
|
|
const spacingClasses = {
|
|
none: 'gap-0',
|
|
xs: 'gap-1',
|
|
sm: 'gap-2',
|
|
md: 'gap-4',
|
|
lg: 'gap-6',
|
|
xl: 'gap-8',
|
|
}
|
|
|
|
const alignClasses = {
|
|
start: 'items-start',
|
|
center: 'items-center',
|
|
end: 'items-end',
|
|
stretch: 'items-stretch',
|
|
}
|
|
|
|
const justifyClasses = {
|
|
start: 'justify-start',
|
|
center: 'justify-center',
|
|
end: 'justify-end',
|
|
between: 'justify-between',
|
|
around: 'justify-around',
|
|
evenly: 'justify-evenly',
|
|
}
|
|
|
|
export function Stack({
|
|
children,
|
|
direction = 'vertical',
|
|
spacing = 'md',
|
|
align = 'stretch',
|
|
justify = 'start',
|
|
wrap = false,
|
|
className
|
|
}: StackProps) {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'flex',
|
|
direction === 'horizontal' ? 'flex-row' : 'flex-col',
|
|
spacingClasses[spacing],
|
|
alignClasses[align],
|
|
justifyClasses[justify],
|
|
wrap && 'flex-wrap',
|
|
className
|
|
)}
|
|
>
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|