Skip to content

Commit 84ac808

Browse files
committed
Move close into header & make sticky.
Fixes #653
1 parent 6ab2157 commit 84ac808

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/css/reset.css

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,18 +1403,24 @@ dialog.my-calendar-modal .my-calendar-modal__wrapper {
14031403
}
14041404

14051405
dialog.my-calendar-modal .mc-modal-title-container {
1406-
position: relative;
1406+
position: sticky;
1407+
top: 0;
14071408
margin-top: 0;
14081409
margin-bottom: 0;
1409-
padding: 16px;
1410+
padding: 4px 16px;
14101411
background: var(--highlight-light);
14111412
z-index: 1;
1413+
display: grid;
1414+
grid-template-columns: 1fr auto;
1415+
gap: 16px;
1416+
align-items: center;
1417+
border-bottom: 1px solid var(--highlight-dark);
14121418
}
14131419

14141420
dialog.my-calendar-modal #modal-title {
14151421
font-size: var(--modal-title);
14161422
margin: 0;
1417-
margin-right: 64px;
1423+
padding: 0;
14181424
box-sizing: border-box;
14191425
}
14201426

@@ -1512,9 +1518,6 @@ body.mc-no-scroll {
15121518
overflow: auto;
15131519
}
15141520
.my-calendar-modal-close {
1515-
position: absolute;
1516-
top: 3px;
1517-
right: 3px;
15181521
background: var(--close-button);
15191522
border-radius: 3px;
15201523
color: var(--primary-light);
@@ -1525,6 +1528,9 @@ body.mc-no-scroll {
15251528
display: flex;
15261529
align-items: center;
15271530
column-gap: 4px;
1531+
order: 1;
1532+
font-size: 1rem;
1533+
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif
15281534
}
15291535
.my-calendar-modal-close:focus,
15301536
.my-calendar-modal-close:hover,

src/js/modal/accessible-modal-window-aria.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@
150150
var outerContent = document.createElement( 'div' );
151151
var innerContent = document.createElement( 'div' );
152152
var contentContainer = document.createElement( 'div' );
153+
var titleContainer = document.createElement( 'div' );
153154
contentContainer.setAttribute( 'id', MODAL_CONTENT_JS_ID );
155+
titleContainer.classList.add( 'mc-modal-title-container' );
154156

155157
var id = MODAL_JS_ID;
156158
var modalClassName = config.modalPrefixClass + MODAL_CLASS_SUFFIX;
@@ -159,7 +161,7 @@
159161
var buttonCloseInner = '<span class="' + config.modalPrefixClass + MODAL_CLOSE_TEXT_CLASS_SUFFIX + '">\n ' + config.modalCloseText + '\n </span>';
160162
var contentClassName = config.modalPrefixClass + MODAL_CONTENT_CLASS_SUFFIX;
161163
var titleClassName = config.modalPrefixClass + MODAL_TITLE_CLASS_SUFFIX;
162-
var title = config.modalTitle !== '' ? '<div class="mc-modal-title-container"><h1 id="' + MODAL_TITLE_ID + '" class="' + titleClassName + '">\n ' + config.modalTitle + '\n </h1></div>' : '';
164+
var title = config.modalTitle !== '' ? '<h1 id="' + MODAL_TITLE_ID + '" class="' + titleClassName + '">\n ' + config.modalTitle + '\n </h1>' : '';
163165
var button_close = '<button type="button" class="' + MODAL_BUTTON_JS_CLASS + ' ' + buttonCloseClassName + '" id="' + MODAL_BUTTON_JS_ID + '" ' + MODAL_BUTTON_CONTENT_BACK_ID + '="' + config.modalContentId + '" ' + MODAL_BUTTON_FOCUS_BACK_ID + '="' + config.modalFocusBackId + '"><span class="dashicons dashicons-no" aria-hidden="true"></span>\n ' + buttonCloseInner + '\n </button>';
164166
var content = config.modalText;
165167

@@ -179,9 +181,10 @@
179181
dialog.setAttribute( ATTR_LABELLEDBY, MODAL_TITLE_ID );
180182
outerContent.setAttribute( 'role', 'document' );
181183
outerContent.classList.add( modalClassWrapper );
182-
outerContent.insertAdjacentHTML( 'afterBegin', button_close );
184+
titleContainer.insertAdjacentHTML( 'afterBegin', title );
185+
titleContainer.insertAdjacentHTML( 'afterBegin', button_close );
183186
innerContent.classList.add( contentClassName );
184-
innerContent.insertAdjacentHTML( 'afterBegin', title );
187+
innerContent.insertAdjacentElement( 'afterbegin', titleContainer );
185188
innerContent.insertAdjacentElement( 'beforeEnd', contentContainer );
186189
outerContent.insertAdjacentElement( 'afterBegin', innerContent );
187190
dialog.insertAdjacentElement( 'afterBegin', outerContent );

src/js/modal/accessible-modal-window-aria.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)