|
1 | | -# react-toggle-file-tree |
2 | | - |
3 | | -The `react-toggle-file-tree` is designed to display a file/folder structure based on the provided list of files and their properties. |
4 | | -This component organizes the files into folders and subfolders based on their localPath. Each folder can contain multiple files with their respective fileName |
| 1 | +# react-toggle-list |
5 | 2 |
|
| 3 | +The `react-toggle-list` is can hide and show content inside. |
6 | 4 |
|
7 | 5 | ## Document |
| 6 | + |
8 | 7 | --- |
9 | 8 |
|
10 | 9 | - [Installation](#installation) |
11 | 10 | - [How to use](#how-to-use) |
12 | | -- [Demos](#demos) |
13 | | -- [Supported file types](#supported-file-types) |
14 | 11 | - [Contribute](#contribute) |
15 | 12 |
|
| 13 | +## Installation |
16 | 14 |
|
17 | | -## Installation |
18 | 15 | --- |
19 | 16 |
|
20 | | -This library use `react-toggle-file-tree`, so you need to install it. |
| 17 | +This library use `react-toggle-list`, so you need to install it. |
21 | 18 |
|
22 | 19 | ```bash |
23 | | -npm install --save react-toggle-file-tree |
| 20 | +npm install --save react-toggle-list |
24 | 21 | ``` |
25 | 22 |
|
26 | 23 | or |
27 | 24 |
|
28 | 25 | ```bash |
29 | | -yarn add react-toggle-file-tree |
| 26 | +yarn add react-toggle-list |
30 | 27 | ``` |
31 | 28 |
|
32 | | - |
33 | 29 | ## How to use |
34 | | ---- |
35 | | -```tsx |
36 | | -import { |
37 | | - createFileTree, |
38 | | - Directory, |
39 | | - ToggleFileTree, |
40 | | -} from 'react-toggle-file-tree'; |
41 | | - |
42 | | -<ToggleFileTree |
43 | | - list={createFileTree(list) as Directory} |
44 | | - handleFileClick={handleFileClick} |
45 | | - handleDirectoryClick={handleDirectoryClick} |
46 | | -/> |
47 | | -``` |
48 | | - |
49 | | -⚠ The list must contain the localPath and fileName keys. |
50 | | - |
51 | | -<details> |
52 | | - <summary>list example view</summary> |
53 | | - |
54 | | -```ts |
55 | | - const list = [ |
56 | | - { |
57 | | - localPath: '/', |
58 | | - fileName: 'inch.txt', |
59 | | - properties: { |
60 | | - size: '1 bit', |
61 | | - anything: 'possible', |
62 | | - a: 'b', |
63 | | - }, |
64 | | - }, |
65 | | - { |
66 | | - localPath: '/fruit', |
67 | | - fileName: 'apple.docs', |
68 | | - properties: { |
69 | | - sizezz: '12mb', |
70 | | - azvv: 'asdfasd', |
71 | | - }, |
72 | | - }, |
73 | | - { |
74 | | - localPath: '/fruit', |
75 | | - fileName: 'banana.png', |
76 | | - properties: { |
77 | | - sizezz: '12mb', |
78 | | - azvv: 'asdfasd', |
79 | | - }, |
80 | | - }, |
81 | | - { |
82 | | - localPath: '/vehicle/car', |
83 | | - fileName: 'truck.pdf', |
84 | | - properties: { |
85 | | - sizezz: '12mb', |
86 | | - azvv: 'asdfasd', |
87 | | - }, |
88 | | - }, |
89 | | - { |
90 | | - localPath: '/vehicle/car', |
91 | | - fileName: 'taxi.ppt', |
92 | | - properties: { |
93 | | - sizezz: '12mb', |
94 | | - azvv: 'asdfasd', |
95 | | - }, |
96 | | - }, |
97 | | - { |
98 | | - localPath: '/plant/tree', |
99 | | - fileName: 'oak.json', |
100 | | - properties: { |
101 | | - sizezz: '10mb', |
102 | | - azvv: 'asdfasd', |
103 | | - }, |
104 | | - }, |
105 | | - { |
106 | | - localPath: '/plant/tree', |
107 | | - fileName: 'maple.zip', |
108 | | - properties: { |
109 | | - sizezz: '8mb', |
110 | | - azvv: 'asdfasd', |
111 | | - }, |
112 | | - }, |
113 | | - { |
114 | | - localPath: '/plant/flower', |
115 | | - fileName: 'cherry-blossom.numbers', |
116 | | - properties: { |
117 | | - sizezz: '5mb', |
118 | | - azvv: 'asdfasd', |
119 | | - }, |
120 | | - }, |
121 | | - { |
122 | | - localPath: '/plant/fruit', |
123 | | - fileName: 'apple-tree.csv', |
124 | | - properties: { |
125 | | - sizezz: '15mb', |
126 | | - azvv: 'asdfasd', |
127 | | - }, |
128 | | - }, |
129 | | - ]; |
130 | | -``` |
131 | | -</details> |
132 | | - |
133 | | - |
134 | | -## Demos |
135 | | ---- |
136 | | - |
137 | | - |
138 | | - |
139 | | -## Supported file types |
140 | | ---- |
141 | | -The `react-toggle-file-tree` supports the following file formats: |
142 | | - |
143 | | -Documents: csv, docs, html, json, manifest, numbers, pdf, ppt, pptx, txt, xlsx |
144 | | - |
145 | | -Images: gif, jpg, jpeg, png |
146 | | - |
147 | | -Media: mov, mp4 |
148 | | - |
149 | | -Scripts: js, ts |
150 | | - |
151 | | -Compressed: gif, zip |
152 | | - |
153 | 30 |
|
154 | | -## Example code |
155 | 31 | --- |
156 | 32 |
|
157 | | -You can see the example code and demo. |
158 | | - |
159 | | -Clone the repository |
160 | | - |
161 | | -```bash |
162 | | -git clone https://github.com/in-ch/react-file-folder.git |
163 | | -``` |
164 | | - |
165 | | -Install libraries |
166 | | - |
167 | | -```bash |
168 | | -cd example |
169 | | -``` |
170 | | - |
171 | | -and |
172 | | - |
173 | | -```bash |
174 | | -npm install |
175 | | -``` |
176 | | - |
177 | | -or |
| 33 | +```tsx |
| 34 | +import { ReactToggleList } from 'react-toggle-list'; |
178 | 35 |
|
| 36 | +const subItems = ['string1', 'string2', 'string3']; |
179 | 37 |
|
180 | | -```bash |
181 | | -yarn |
| 38 | +<ReactToggleList title="example" subItems={subItems} />; |
182 | 39 | ``` |
183 | 40 |
|
184 | | - |
185 | 41 | ## Contribute |
| 42 | + |
186 | 43 | --- |
187 | 44 |
|
188 | | -You can follow below to contribute `react-toggle-file-tree` |
| 45 | +You can follow below to contribute `react-toggle-list` |
189 | 46 |
|
190 | 47 | Clone the repository. |
191 | 48 |
|
|
0 commit comments