UNPKG

2.52 kBMarkdownView Raw
1# ink-task-list <a href="https://npm.im/ink-task-list"><img src="https://badgen.net/npm/v/ink-task-list"></a> <!-- <a href="https://npm.im/ink-task-list"><img src="https://badgen.net/npm/dm/ink-task-list"></a> --> <a href="https://packagephobia.now.sh/result?p=ink-task-list"><img src="https://packagephobia.now.sh/badge?p=ink-task-list"></a>
2
3Task list components for [Ink](https://github.com/vadimdemedes/ink)
4
5<p align="center">
6 <img width="400" src=".github/task-list.gif">
7</p>
8
9<sub>Support this project by ⭐️ starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️</sub>
10
11## 🚀 Install
12```sh
13npm i ink-task-list
14```
15
16## 🚦 Quick usage
17```tsx
18import React from 'react';
19import { render } from 'ink';
20import { TaskList, Task } from 'ink-task-list';
21
22render(
23 <TaskList>
24 <!-- Pending state -->
25 <Task
26 label="Pending"
27 state="pending"
28 />
29
30 <!-- Loading state -->
31 <Task
32 label="Loading"
33 state="loading"
34 />
35
36 <!-- Success state -->
37 <Task
38 label="Success"
39 state="success"
40 />
41
42 <!-- Warning state -->
43 <Task
44 label="Warning"
45 state="warning"
46 />
47
48 <!-- Error state -->
49 <Task
50 label="Error"
51 state="error"
52 />
53
54 <!-- Item with children -->
55 <Task
56 label="Item with children"
57 isExpanded
58 >
59 <Task
60 label="Loading"
61 state="loading"
62 />
63 </Task>
64 </TaskList>
65);
66```
67
68## 🎛 API
69
70### TaskList
71
72Optional wrapper to contain a list of `Tasks`.
73
74Basically just a `<Box flexDirection="column">`; only for styling and semantic purposes.
75
76#### children
77Type: `ReactNode | ReactNode[]`
78
79Required
80
81Pass in list of Tasks
82
83### Task
84
85Represents each task.
86
87#### children
88Type: `ReactNode | ReactNode[]`
89
90Pass in one or more `<Task>` components
91
92#### label
93Type: `string`
94
95Required
96#### state
97Type: `'pending'|'loading'|'success'|'warning'|'error'`
98
99Default: `pending`
100
101#### spinnerType
102Type: `string`
103
104Default: `dots`
105
106#### isExpanded
107Type: `boolean`
108
109Default: `false`
110
111## 🙏 Credits
112The component UI was insipired [listr](https://github.com/SamVerschueren/listr) and [listr2](https://github.com/cenk1cenk2/listr2) ❤️
113
114Big thanks to [Sindre Sorhus](https://github.com/sindresorhus) for making this package so easy to make.
\No newline at end of file