Skip to content

Commit b8f48cb

Browse files
committed
fix: update readme and build storybook.
1 parent 0a22d04 commit b8f48cb

File tree

5 files changed

+3293
-38
lines changed

5 files changed

+3293
-38
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
22
lib
3+
storybook-static
4+
build-storybook.log

README.md

+75-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,77 @@
11
# use-disposable-list
22

3-
A React hook for a disposable list.
3+
A react hook to create a list of disposable items,
44

5-
```js
6-
const [notifs, addNotif, removeNotif] = useDisposableList({
7-
hideDuration: 300,
8-
timeout: 2000,
9-
});
5+
It can be used as a core infra to display a growl notification for **any** css framework.
6+
7+
### Basic Sample
8+
9+
See live in [Codesandbox](https://codesandbox.io/s/clever-cache-y7xw1)
10+
11+
```jsx
12+
import "./styles.css";
13+
import useDisposableList from "use-disposable-list";
14+
15+
export default function App() {
16+
const [notifs, addNotif, removeNotif] = useDisposableList({
17+
hideDuration: 0,
18+
timeout: 2000,
19+
});
20+
21+
return (
22+
<div className="App">
23+
<h1>use-disposable-list</h1>
24+
<div>
25+
<div style={{ paddingBottom: "20px" }}>
26+
<button
27+
onClick={() =>
28+
addNotif({
29+
message: "Hello",
30+
level: "info",
31+
description: "World",
32+
})
33+
}
34+
>
35+
info
36+
</button>
37+
<button
38+
onClick={() =>
39+
addNotif({
40+
message: "Oh no",
41+
level: "error",
42+
description: "Something bad happened",
43+
})
44+
}
45+
>
46+
error
47+
</button>
48+
</div>
49+
{notifs.map(({ id, show, details = { level: "info" } }) => (
50+
<div>
51+
<span>{details.message}</span>
52+
<button
53+
onClick={() => removeNotif(id)}
54+
style={{ marginLeft: "3px" }}
55+
>
56+
X
57+
</button>
58+
</div>
59+
))}
60+
</div>
61+
</div>
62+
);
63+
}
1064
```
1165

12-
```ts
66+
### Typescript
67+
68+
```tsx
69+
export interface NotificationDef {
70+
message: string;
71+
description?: string;
72+
level: "info" | "error";
73+
}
74+
1375
interface NotificationsDef {
1476
id: string;
1577
show: boolean;
@@ -20,6 +82,11 @@ const [notifs, addNotif, removeNotif] = useDisposableList<NotificationDef>({
2082
hideDuration: 300,
2183
timeout: 2000,
2284
});
85+
86+
//...
2387
```
2488

25-
- `notifs` is a list of disposable notifications to display
89+
### Demos
90+
91+
- [story book](https://60afd8ceda1d8b003977ba04-bwpixgfhhi.chromatic.com/)
92+
- [Codesandbox with Bootstrap](https://codesandbox.io/s/holy-tdd-t8gr8)

0 commit comments

Comments
 (0)