Skip to content

Commit 6a798d8

Browse files
SharonStratsTallTedCopilot
authored
Apply suggestions from code review
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent ccbd029 commit 6a798d8

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/widgets/modals.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ export type ListItem = {
1212
link: string
1313
}
1414

15-
// Two functions that need to be implemented to use the modal
16-
// When the user clicks the button, open the modal
15+
// Two functions that need to be implemented to use the modal.
16+
// When the user clicks the button, open the modal.
1717
/* Click handler on the button to display it.
1818
btn.onclick = function() {
1919
modal.style.display = "block";
2020
}
2121
22-
// When the user clicks anywhere outside of the modal, close it
23-
Window click handler so that the modal will close
24-
even if the user doesn't click close
22+
// When the user clicks anywhere outside of the modal, close it.
23+
// Window click handler so that the modal will close
24+
// even if the user doesn't click close.
2525
window.onclick = function(event) {
2626
if (event.target == modal) {
2727
modal.style.display = "none";
@@ -70,7 +70,7 @@ const createListItems = (dom: HTMLDocument, list: ListItem) => {
7070
const link: HTMLAnchorElement = dom.createElement('a')
7171
link.setAttribute('style', modalStyles.anchorStyle)
7272
link.href = list.link
73-
link.innerHTML = list.label
73+
link.textContent = list.label
7474
li.appendChild(link)
7575
return li
7676
}
@@ -84,8 +84,9 @@ const createUnOrderedList = (dom: HTMLDocument, listOfLinks: ListItem[]) => {
8484
})
8585
return ul
8686
}
87-
export const createWindow = (dom: HTMLDocument, listOfLinks: ListItem[], options: ModalWidgetStyleOptions) => {
88-
const modal = createModal(dom, options)
87+
export const createWindow = (dom: HTMLDocument, listOfLinks: ListItem[], options?: ModalWidgetStyleOptions) => {
88+
const modalOptions = (options ?? {}) as ModalWidgetStyleOptions
89+
const modal = createModal(dom, modalOptions)
8990
const modalContent = createModalContent(dom)
9091
const closeButton = createCloseButton(dom)
9192
const ul = createUnOrderedList(dom, listOfLinks)

src/widgets/modalsStyle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Get the button style, based on options.
3-
* See https://design.inrupt.com/atomic-core/?cat=Atoms#Buttons
2+
* Get the modal styles, based on options such as position and background overlay.
3+
* See https://design.inrupt.com/atomic-core/?cat=Organisms#Modals for modal design guidelines.
44
*/
55
export type ModalWidgetStyleOptions = {
66
topPosition?: string,

0 commit comments

Comments
 (0)