Skip to content

Commit a99b5ff

Browse files
committed
added stories
1 parent 9426f6c commit a99b5ff

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

src/stories/Modals.stories.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import * as UI from '../../src/index'
2+
3+
export default {
4+
title: 'Modals',
5+
}
6+
7+
const demoLinks = [
8+
{ label: 'Solid Project', link: 'https://solidproject.org/' },
9+
{ label: 'SolidOS', link: 'https://github.com/solidos' },
10+
{ label: 'W3C', link: 'https://www.w3.org/' },
11+
]
12+
13+
export const ListModal = {
14+
render: () => {
15+
const modal = UI.widgets.createListModal(document, demoLinks, {
16+
withGreyedBackground: true,
17+
ariaLabel: 'Helpful links',
18+
})
19+
modal.style.display = 'block'
20+
return modal
21+
},
22+
name: 'List modal',
23+
}
24+
25+
export const OpenListModal = {
26+
render: () => {
27+
const container = document.createElement('div')
28+
29+
const openButton = document.createElement('button')
30+
openButton.setAttribute('type', 'button')
31+
openButton.textContent = 'Open links modal'
32+
33+
const helper = document.createElement('p')
34+
helper.textContent = 'Open the modal, then press Escape or use the close button.'
35+
36+
openButton.addEventListener('click', () => {
37+
const existing = container.querySelector('.modal')
38+
if (existing) {
39+
existing.remove()
40+
}
41+
42+
const modal = UI.widgets.createListModal(document, demoLinks, {
43+
withGreyedBackground: true,
44+
ariaLabel: 'Helpful links',
45+
})
46+
modal.style.display = 'block'
47+
container.appendChild(modal)
48+
})
49+
50+
container.appendChild(openButton)
51+
container.appendChild(helper)
52+
return container
53+
},
54+
name: 'Open list modal',
55+
}

0 commit comments

Comments
 (0)