@@ -41,7 +41,10 @@ const createModalContent = (dom: HTMLDocument) => {
4141}
4242
4343const 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