-
Notifications
You must be signed in to change notification settings - Fork 1
Add accessibility and keyboard semantics #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
|
|
||
| // Score display | ||
| var scoreEl = sf.el('span', { className: 'sf-statusbar-score' }, '\u2014'); | ||
| var scoreEl = sf.el('span', { className: 'sf-statusbar-score', id: 'sfScoreDisplay', 'aria-live': 'polite' }, '\u2014'); | ||
| bar.appendChild(scoreEl); | ||
|
|
||
| // Separator | ||
|
|
@@ -33,6 +34,7 @@ | |
| // Separator + status text | ||
| bar.appendChild(sf.el('span', { className: 'sf-statusbar-sep' }, '|')); | ||
| var statusEl = sf.el('span'); | ||
| var statusEl = sf.el('span', { id: 'sfStatusText', role: 'status', 'aria-live': 'polite' }); | ||
| bar.appendChild(statusEl); | ||
|
|
||
| // Build initial constraint dots | ||
|
|
@@ -129,12 +131,16 @@ | |
| constraints.forEach(function (c, i) { | ||
| var dot = sf.el('div', { | ||
| className: 'sf-constraint-dot', | ||
| id: 'sf-cdot-' + i, | ||
| title: c.name || ('Constraint ' + i), | ||
| role: onClick ? 'button' : null, | ||
| tabIndex: onClick ? '0' : null, | ||
| 'aria-label': onClick ? ('Open constraint ' + (c.name || ('Constraint ' + i))) : null, | ||
|
Comment on lines
133
to
+138
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| dataset: { type: c.type || 'hard', index: String(i) }, | ||
| }); | ||
| if (onClick) { | ||
| dot.style.cursor = 'pointer'; | ||
| dot.addEventListener('click', function () { onClick(i); }); | ||
| sf.bindActivation(dot, function () { onClick(i); }); | ||
| } | ||
| container.appendChild(dot); | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,15 +10,25 @@ | |
| sf.assert(!config.footer || Array.isArray(config.footer), 'createModal(config.footer) must be an array'); | ||
|
|
||
| var overlay = sf.el('div', { className: 'sf-modal-overlay' }); | ||
| var dialog = sf.el('div', { className: 'sf-modal' }); | ||
| var dialogId = sf.uid('sf-modal'); | ||
| var dialog = sf.el('div', { | ||
| className: 'sf-modal', | ||
| id: dialogId, | ||
| role: 'dialog', | ||
| 'aria-modal': 'true', | ||
| 'aria-labelledby': dialogId + '-title', | ||
| }); | ||
| var body = sf.el('div', { className: 'sf-modal-body' }); | ||
|
|
||
| // Header | ||
| var header = sf.el('div', { className: 'sf-modal-header' }); | ||
| header.appendChild(sf.el('div', { className: 'sf-modal-title' }, config.title || '')); | ||
| var titleEl = sf.el('div', { className: 'sf-modal-title', id: dialogId + '-title' }, config.title || ''); | ||
| header.appendChild(titleEl); | ||
|
|
||
| var closeBtn = sf.el('button', { | ||
| className: 'sf-modal-close', | ||
| html: '×', | ||
| 'aria-label': 'Close modal', | ||
| onClick: function () { api.close(); }, | ||
|
Comment on lines
28
to
32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| }, '×'); | ||
| header.appendChild(closeBtn); | ||
|
|
@@ -40,6 +50,8 @@ | |
|
|
||
| overlay.appendChild(dialog); | ||
|
|
||
| var previousFocus = null; | ||
|
|
||
| // Close on backdrop click | ||
| overlay.addEventListener('click', function (e) { | ||
| if (e.target === overlay) api.close(); | ||
|
|
@@ -53,15 +65,18 @@ | |
| var api = { el: overlay, body: body }; | ||
|
|
||
| api.open = function () { | ||
| document.body.appendChild(overlay); | ||
| overlay.classList.add('open'); | ||
| document.addEventListener('keydown', onKeyDown); | ||
| }; | ||
| previousFocus = document.activeElement; | ||
| document.body.appendChild(overlay); | ||
| if (closeBtn.focus) closeBtn.focus(); | ||
| overlay.classList.add('open'); | ||
| document.addEventListener('keydown', onKeyDown); | ||
| }; | ||
|
|
||
| api.close = function () { | ||
| overlay.classList.remove('open'); | ||
| document.removeEventListener('keydown', onKeyDown); | ||
| if (overlay.parentNode) overlay.parentNode.removeChild(overlay); | ||
| if (previousFocus && previousFocus.focus) previousFocus.focus(); | ||
| if (config.onClose) config.onClose(); | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.sf-UI onlyThis rule targets
*,*::before, and*::after, so includingsf.cssnow disables animations/transitions and overridesscroll-behaviorfor the entire host page whenever the user prefers reduced motion. Because the rest of the stylesheet is scoped to SolverForge classes, this introduces a cross-app side effect for any page that embeds the bundle; the selectors should be narrowed to the library's own DOM subtree instead of globally resetting the document.Useful? React with 👍 / 👎.