-
Notifications
You must be signed in to change notification settings - Fork 6
/
snackbar.js
73 lines (63 loc) 路 2.05 KB
/
snackbar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { COMPONENT_NAME } from '@vonage/vwc-snackbar';
import '@vonage/vwc-button';
import { html } from 'lit-element';
import { spread } from '@open-wc/lit-helpers';
import { argTypes } from './arg-types.js';
export default {
title: 'Components/Snackbar',
component: COMPONENT_NAME,
argTypes
};
const TemplateBasic = args => html`
<div>
<vwc-button layout="filled" @click="${openSnackbar}">Show snackbar</vwc-button>
</div>
<vwc-snackbar ...=${spread(args)}></vwc-snackbar>
`;
export const Basic = TemplateBasic.bind({});
Basic.args = {
icon: 'megaphone-solid',
connotation: 'info',
message: 'Pascal argues that a rational person should live as though God exists and seek to believe in God.',
};
export const Dismissible = TemplateBasic.bind({});
Dismissible.args = {
timeoutMs: 10000,
icon: 'megaphone-solid',
message: 'Pascal argues that a rational person should live as though God exists and seek to believe in God.',
dismissible: true
};
const TemplateAction = args => html`
<div>
<vwc-button layout="filled" @click="${openSnackbar}">Show snackbar</vwc-button>
</div>
<vwc-snackbar ...=${spread(args)}>
<vwc-button slot="action" layout="outlined" shape="pill" dense >Show more</vwc-button>
</vwc-snackbar>
`;
export const Action = TemplateAction.bind({});
Action.args = {
timeoutMs: 10000,
icon: 'megaphone-solid',
connotation: 'success',
header: 'Pascal heritage',
message: 'Pascal argues that a rational person should live as though God exists and seek to believe in God.'
};
export const ActionWithDismissible = TemplateAction.bind({});
ActionWithDismissible.args = {
timeoutMs: 10000,
icon: 'megaphone-solid',
connotation: 'success',
header: 'Pascal heritage',
message: 'Pascal argues that a rational person should live as though God exists and seek to believe in God.',
dismissible: true
};
function openSnackbar(e) {
const opener = e.target;
e.target.setAttribute('disabled', '');
const sb = document.querySelector('vwc-snackbar');
sb.addEventListener('closed', () => {
opener.removeAttribute('disabled');
}, { once: true });
sb.show();
}