Skip to content

Commit bf05189

Browse files
committed
feat: 🏷️ improve types
1 parent 6d53a0a commit bf05189

File tree

1 file changed

+67
-2
lines changed

1 file changed

+67
-2
lines changed

β€Žsrc/index.tsxβ€Ž

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,79 @@ export interface DividerProps {
77
/**
88
* Title shown in the middle of the divider.
99
*
10+
* @example
11+
* ```tsx
12+
* <Divider title="Title" />
13+
*
14+
* // ─────────── Title ───────────
15+
* ```
16+
*
1017
* @default null
1118
*/
1219
title?: string
1320

1421
/**
1522
* Width of the divider.
1623
*
24+
* @example
25+
* ```tsx
26+
* <Divider width={50} />
27+
*
28+
* // ──────────────────────────────────────────────────
29+
* ```
1730
* @default 'auto'
1831
*/
1932
width?: 'auto' | number
2033

2134
/**
2235
* Padding at the start and the end of the divider.
2336
*
37+
* @example
38+
* ```tsx
39+
* <Divider padding={2} />
40+
*
41+
* // ··─────────────────────────────··
42+
* ```
2443
* @default 0
2544
*/
2645
padding?: number
2746

2847
/**
2948
* Padding besides the title in the middle.
3049
*
50+
* @example
51+
* ```tsx
52+
* <Divider title="My title" titlePadding={3} />
53+
*
54+
* // ───────── Title ─────────
55+
* ```
56+
*
3157
* @default 1
3258
*/
3359
titlePadding?: number
3460

3561
/**
3662
* Color of the title.
3763
*
64+
* @example
65+
* ```tsx
66+
* <Divider title="My title" titleColor="green" />
67+
* ```
68+
*
3869
* @default 'white'
3970
*/
4071
titleColor?: TextProps['color']
4172

4273
/**
4374
* Char used as a divider.
4475
*
76+
* @example
77+
* ```tsx
78+
* <Divider dividerChar="=" />
79+
*
80+
* // =============================
81+
* ```
82+
*
4583
* @default '─'
4684
*/
4785
dividerChar?: string
@@ -50,10 +88,28 @@ export interface DividerProps {
5088
* Color of the divider's border. Matches the type of `borderColor` in the Ink `Box` component.
5189
* Accepts standard Ink color names or hex codes.
5290
*
91+
* @example
92+
* ```tsx
93+
* <Divider dividerColor="red" />
94+
* ```
95+
*
5396
* @default 'gray'
5497
*/
5598
dividerColor?: BoxProps['borderColor']
5699

100+
/**
101+
* Additional props to be passed to the underlying Ink `Box` component.
102+
*
103+
* @example
104+
* ```tsx
105+
* <Divider boxProps={{ marginTop: 2 }} />
106+
*
107+
*
108+
* //
109+
* //
110+
* // ─────────────────────────────
111+
* ```
112+
*/
57113
boxProps?: BoxProps
58114
}
59115

@@ -86,8 +142,17 @@ const BaseDivider: React.FC<DividerProps> = ({
86142
/**
87143
* A horizontal divider component styled as a single border line.
88144
*
89-
* @param props - Properties to customize the divider.
90-
* @returns A styled Ink `Box` component representing a divider.
145+
* @example
146+
* ```tsx
147+
* import { render } from 'ink'
148+
* import Divider from 'ink-divider'
149+
*
150+
* render(<Divider title='Title' />)
151+
*
152+
* // ─────────── Title ───────────
153+
* ```
154+
*
155+
* @returns A styled divider.
91156
*/
92157
const Divider: React.FC<DividerProps> = ({
93158
title,

0 commit comments

Comments
Β (0)