Skip to content

Commit 5cb7262

Browse files
committed
[#101] ♻️ make divider more expandable
1 parent 31b8056 commit 5cb7262

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed
Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1-
export const Divider = (): JSX.Element => {
2-
return <div className='h-14 w-1 bg-gray-200' />
1+
import { twMerge } from 'tailwind-merge'
2+
3+
interface DividerProps {
4+
isVertical?: boolean
5+
thickness?: Length
6+
length?: Length
7+
color?: string
8+
className?: string
9+
}
10+
11+
type Length = '1' | '14' | 'full'
12+
13+
const heightMap: Record<Length, string> = {
14+
'1': 'h-1',
15+
'14': 'h-14',
16+
full: 'h-full',
17+
}
18+
const weightMap: Record<Length, string> = {
19+
'1': 'w-1',
20+
'14': 'w-14',
21+
full: 'w-full',
22+
}
23+
24+
export const Divider = ({
25+
isVertical = true,
26+
thickness = '1',
27+
length = 'full',
28+
color = 'bg-gray-200',
29+
className = '',
30+
}: DividerProps): JSX.Element => {
31+
const dividerClass = twMerge(
32+
'min-h-0 min-w-0',
33+
color,
34+
isVertical ? heightMap[length] : heightMap[thickness],
35+
isVertical ? weightMap[thickness] : weightMap[length],
36+
className
37+
)
38+
39+
return <div className={dividerClass} />
340
}

0 commit comments

Comments
 (0)