Skip to content

Commit 1b682fc

Browse files
committed
improve name and return modal
1 parent e5b4110 commit 1b682fc

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/style.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ export const style = { // styleModule
6868
modalListItemStyle: 'list-style: none; box-shadow: 1px 1px 1px 1px #888888; padding: .5em;',
6969
modalAnchorStyle: 'text-decoration: none;',
7070
modalContentStyle: 'display: flex; flex-direction: column; background-color: #fefefe;',
71-
modalCloseStyle: 'color: #aaaaaa; align-self: flex-end; font-size: 20px; font-weight: bold; margin-right: .2em; margin-top: .2em; cursor: pointer;',
72-
modalCloseStyleHover: 'color: #666666; align-self: flex-end; font-size: 20px; font-weight: bold; margin-right: .2em; margin-top: .2em; text-decoration: none; cursor: pointer;',
73-
modalCloseStyleFocus: 'color: #666666; align-self: flex-end; font-size: 20px; font-weight: bold; margin-right: .2em; margin-top: .2em; text-decoration: none; cursor: pointer; outline: 1px solid #888;',
71+
modalCloseStyle: 'background: none; border: 0; padding: 0; color: #aaaaaa; align-self: flex-end; font-size: 20px; font-weight: bold; margin-right: .2em; margin-top: .2em; cursor: pointer;',
72+
modalCloseStyleHover: 'background: none; border: 0; padding: 0; color: #666666; align-self: flex-end; font-size: 20px; font-weight: bold; margin-right: .2em; margin-top: .2em; text-decoration: none; cursor: pointer;',
73+
modalCloseStyleFocus: 'background: none; border: 0; padding: 0; color: #666666; align-self: flex-end; font-size: 20px; font-weight: bold; margin-right: .2em; margin-top: .2em; text-decoration: none; cursor: pointer; outline: 1px solid #888;',
7474

7575
// ACL
7676
aclControlBoxContainer: 'margin: 1em;',

src/widgets/modals.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ const createModalContent = (dom: HTMLDocument) => {
4141
}
4242

4343
const createCloseButton = (dom: HTMLDocument, modal: HTMLDivElement) => {
44-
const closeButton: HTMLSpanElement = dom.createElement('span')
44+
const closeButton: HTMLButtonElement = dom.createElement('button')
45+
closeButton.setAttribute('type', 'button')
46+
closeButton.setAttribute('aria-label', 'Close modal')
47+
closeButton.textContent = 'x'
4548
closeButton.addEventListener('click', () => closeClickHandler(modal))
4649
closeButton.addEventListener('mouseenter', () => {
4750
closeButton.setAttribute('style', style.modalCloseStyleHover)
@@ -55,7 +58,6 @@ const createCloseButton = (dom: HTMLDocument, modal: HTMLDivElement) => {
5558
closeButton.addEventListener('blur', () => {
5659
closeButton.setAttribute('style', style.modalCloseStyle)
5760
})
58-
closeButton.setAttribute('tabindex', '0')
5961
closeButton.setAttribute('style', style.modalCloseStyle)
6062
return closeButton
6163
}
@@ -71,7 +73,7 @@ const createListItems = (dom: HTMLDocument, list: ListItem) => {
7173
return li
7274
}
7375

74-
const createUnOrderedList = (dom: HTMLDocument, listOfLinks: ListItem[]) => {
76+
const createUnorderedList = (dom: HTMLDocument, listOfLinks: ListItem[]) => {
7577
const ul: HTMLUListElement = dom.createElement('ul')
7678
ul.setAttribute('style', style.modalUnorderedListStyle)
7779
listOfLinks.forEach(list => {
@@ -80,12 +82,14 @@ const createUnOrderedList = (dom: HTMLDocument, listOfLinks: ListItem[]) => {
8082
})
8183
return ul
8284
}
83-
export const createWindow = (dom: HTMLDocument, listOfLinks: ListItem[], options: ModalWidgetStyleOptions) => {
85+
export const createListModal = (dom: HTMLDocument, listOfLinks: ListItem[], options: ModalWidgetStyleOptions) => {
8486
const modal = createModal(dom, options)
8587
const modalContent = createModalContent(dom)
8688
const closeButton = createCloseButton(dom, modal)
87-
const ul = createUnOrderedList(dom, listOfLinks)
89+
const ul = createUnorderedList(dom, listOfLinks)
8890
modalContent.appendChild(closeButton)
8991
modalContent.appendChild(ul)
9092
modal.appendChild(modalContent)
93+
94+
return modal
9195
}

0 commit comments

Comments
 (0)