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 |
|
3 | Task 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
|
13 | npm i ink-task-list
|
14 | ```
|
15 |
|
16 | ## 🚦 Quick usage
|
17 | ```tsx
|
18 | import React from 'react';
|
19 | import { render } from 'ink';
|
20 | import { TaskList, Task } from 'ink-task-list';
|
21 |
|
22 | render(
|
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 |
|
72 | Optional wrapper to contain a list of `Tasks`.
|
73 |
|
74 | Basically just a `<Box flexDirection="column">`; only for styling and semantic purposes.
|
75 |
|
76 | #### children
|
77 | Type: `ReactNode | ReactNode[]`
|
78 |
|
79 | Required
|
80 |
|
81 | Pass in list of Tasks
|
82 |
|
83 | ### Task
|
84 |
|
85 | Represents each task.
|
86 |
|
87 | #### children
|
88 | Type: `ReactNode | ReactNode[]`
|
89 |
|
90 | Pass in one or more `<Task>` components
|
91 |
|
92 | #### label
|
93 | Type: `string`
|
94 |
|
95 | Required
|
96 | #### state
|
97 | Type: `'pending'|'loading'|'success'|'warning'|'error'`
|
98 |
|
99 | Default: `pending`
|
100 |
|
101 | #### spinnerType
|
102 | Type: `string`
|
103 |
|
104 | Default: `dots`
|
105 |
|
106 | #### isExpanded
|
107 | Type: `boolean`
|
108 |
|
109 | Default: `false`
|
110 |
|
111 | ## 🙏 Credits
|
112 | The component UI was insipired [listr](https://github.com/SamVerschueren/listr) and [listr2](https://github.com/cenk1cenk2/listr2) ❤️
|
113 |
|
114 | Big thanks to [Sindre Sorhus](https://github.com/sindresorhus) for making this package so easy to make. |
\ | No newline at end of file |