Skip to content

Commit 9cffdc5

Browse files
committed
feat(demo): snack-bar
1 parent f8595d1 commit 9cffdc5

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

demo/snack-bar/scripts.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
11
import {SnackBarManager, gecutButton} from '@gecut/components';
2+
import {numberUtils} from '@gecut/utilities/data-types/number.js';
23
import {render, html} from 'lit/html.js';
34

4-
const sbm = new SnackBarManager({
5-
position: {
6-
bottom: '0px',
7-
left: '0px',
8-
right: '0px',
5+
const manager = new SnackBarManager({
6+
style: {
7+
position: 'fixed',
8+
right: 0,
9+
left: 0,
10+
maxWidth: '640px',
11+
margin: '0 auto',
12+
bottom: '5rem',
913
},
1014
});
1115

12-
const id1 = 'id1';
13-
const id2 = 'id2';
14-
15-
sbm.connect(id1, {
16-
message: 'Hello ' + id1,
17-
close: true,
16+
manager.connect('hello', {
17+
message: 'Hello',
1818
});
1919

20-
sbm.connect(id2, {
21-
message:
22-
// eslint-disable-next-line max-len
23-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ' +
24-
id2,
25-
action: {
26-
label: 'Longer Action',
27-
},
28-
});
20+
for (let index = 0; index < 3; index++) {
21+
manager.notify({
22+
message: 'Fuck you ' + index,
23+
close: numberUtils.random.number(1, 0) > 0,
24+
});
25+
manager.notify({
26+
message:
27+
// eslint-disable-next-line max-len
28+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Diam maecenas ultricies mi eget mauris pharetra et.',
29+
30+
action: {
31+
label: 'Save',
32+
},
33+
});
34+
}
2935

3036
render(
3137
html`
3238
<div class="mx-auto max-w-sm flex flex-col gap-4 relative h-full w-full">
33-
${sbm.html}
34-
${gecutButton({
35-
type: 'filled',
36-
label: 'Push 1',
37-
events: {
38-
click: () => {
39-
sbm.open(id1);
40-
},
41-
},
42-
})}
39+
${manager.html}
4340
${gecutButton({
4441
type: 'filled',
45-
label: 'Push 2',
42+
label: 'Open',
4643
events: {
4744
click: () => {
48-
sbm.open(id2);
45+
manager.open('hello');
4946
},
5047
},
5148
})}
5249
${gecutButton({
5350
type: 'filled',
54-
label: 'Remove 1',
51+
label: 'Notify',
5552
events: {
5653
click: () => {
57-
sbm.disconnect(id1);
54+
manager.notify({
55+
message: 'Fuck you',
56+
close: true,
57+
});
5858
},
5959
},
6060
})}

0 commit comments

Comments
 (0)