astro-accelerator 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.6",
2
+ "version": "0.3.8",
3
3
  "author": "Steve Fenton",
4
4
  "name": "astro-accelerator",
5
5
  "description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
@@ -1093,14 +1093,14 @@ button[data-share]:focus {
1093
1093
  }
1094
1094
 
1095
1095
  /* Detail tabs */
1096
-
1097
- .tablist [role="tablist"] {
1098
- min-width: 100%;
1096
+
1097
+ .tab-list {
1098
+ padding-inline: 10px;
1099
1099
  }
1100
1100
 
1101
- .tablist [role="tab"],
1102
- .tablist [role="tab"]:focus,
1103
- .tablist [role="tab"]:hover {
1101
+ .tab-list button,
1102
+ .tab-list button:focus,
1103
+ .tab-list button:hover {
1104
1104
  display: inline-block;
1105
1105
  position: relative;
1106
1106
  z-index: 2;
@@ -1116,7 +1116,7 @@ button[data-share]:focus {
1116
1116
  cursor: pointer;
1117
1117
  }
1118
1118
 
1119
- .tablist [role="tab"][aria-selected="true"] {
1119
+ .tab-list button[aria-selected="true"] {
1120
1120
  margin-top: 0;
1121
1121
  border-width: 2px;
1122
1122
  border-top-width: 6px;
@@ -1126,28 +1126,22 @@ button[data-share]:focus {
1126
1126
  background-color: var(--aft);
1127
1127
  }
1128
1128
 
1129
- .tablist [role="tab"][aria-selected="false"] {
1129
+ .tab-list button[aria-selected="false"] {
1130
1130
  top: 0px;
1131
1131
  }
1132
1132
 
1133
- .tablist [role="tab"] span.focus {
1133
+ .tab-list button span.focus {
1134
1134
  display: inline-block;
1135
1135
  margin: 2px;
1136
1136
  padding: 4px 6px;
1137
1137
  outline: none;
1138
1138
  }
1139
1139
 
1140
- .input-keyboard .tablist [role="tab"]:hover span.focus,
1141
- .input-keyboard .tablist [role="tab"]:focus span.focus,
1142
- .input-keyboard .tablist [role="tab"]:active span.focus {
1143
- outline: 2px solid var(--fore-link);
1144
- }
1145
-
1146
1140
  [role="tabpanel"] {
1147
1141
  position:relative;
1148
1142
  padding: 1rem;
1149
1143
  border: 2px solid var(--fore-link);
1150
- border-radius: 0 var(--block-radius) var(--block-radius);
1144
+ border-radius: var(--block-radius);
1151
1145
  background: var(--aft);
1152
1146
  min-height: 10em;
1153
1147
  overflow: auto;
@@ -22,7 +22,7 @@ function enhanceDetailGroups() {
22
22
 
23
23
  const tablist = document.createElement('div');
24
24
  tablist.role = 'tablist';
25
- tablist.className = 'tablist';
25
+ tablist.className = 'tab-list';
26
26
  participants[0].parentNode.insertBefore(tablist, participants[0]);
27
27
 
28
28
  participants.forEach((p, i) => {
@@ -32,6 +32,7 @@ function enhanceDetailGroups() {
32
32
  // Create the tab panel
33
33
 
34
34
  const tabPanel = document.createElement('div');
35
+ tabPanel.setAttribute('tabindex', '0');
35
36
  tabPanel.setAttribute('role', 'tabpanel');
36
37
  tabPanel.setAttribute('aria-labelledby', `aatb_${ g }_${ i }`);
37
38
  tabPanel.id = `aatb_panel_${ g }_${ i }`;
@@ -122,6 +123,7 @@ class TabsManual {
122
123
 
123
124
  moveFocusToTab(currentTab) {
124
125
  currentTab.focus();
126
+ this.setSelectedTab(currentTab);
125
127
  }
126
128
 
127
129
  moveFocusToPreviousTab(currentTab) {
@@ -183,8 +185,6 @@ class TabsManual {
183
185
  }
184
186
  }
185
187
 
186
- // Since this example uses buttons for the tabs, the click onr also is activated
187
- // with the space and enter keys
188
188
  onClick(event) {
189
189
  this.setSelectedTab(event.currentTarget);
190
190
  }
@@ -16,7 +16,7 @@ import { getFocusableElement, trapFocusForward, trapReverseFocus } from './focus
16
16
  * @param {string} resizedEventName
17
17
  */
18
18
  function addMobileNav(resizedEventName) {
19
- const icons = qsa('[data-navigationid');
19
+ const icons = qsa('[data-navigationid]');
20
20
  for (let icon of icons) {
21
21
  addMobileNavigation(icon, resizedEventName);
22
22
  }
@@ -36,8 +36,7 @@ function addMobileNav(resizedEventName) {
36
36
  * @param {string} resizedEventName
37
37
  */
38
38
  function addMobileNavigation(icon, resizedEventName) {
39
- icon.tabIndex = 0;
40
- const navigationSelector = icon.dataset.navigationid;
39
+ const navigationSelector = icon.dataset.navigationid || '';
41
40
  const iconType = icon.firstElementChild && icon.firstElementChild.tagName == 'svg'
42
41
  ? 'svg'
43
42
  : 'element';
@@ -46,6 +45,9 @@ function addMobileNav(resizedEventName) {
46
45
  const overlay = document.createElement('div');
47
46
  const dataOpen = 'data-open';
48
47
 
48
+ icon.setAttribute('aria-expanded', 'false');
49
+ icon.setAttribute('aria-controls', navigationSelector);
50
+
49
51
  // Focus trap (forwards the tab / shift-tab back to the menu)
50
52
  icon.addEventListener('keydown', function(e) {
51
53
  if (icon.getAttribute(dataOpen) === dataOpen) {
@@ -86,6 +88,7 @@ function addMobileNav(resizedEventName) {
86
88
  overlay.innerHTML = menuElement.outerHTML;
87
89
  overlay.className = 'overlay overlay-menu';
88
90
  overlay.style.display = 'block';
91
+ menuElement.style.display = 'none';
89
92
 
90
93
  qsa('[id]', overlay).forEach((elem) => {
91
94
  elem.id = 'overlay__' + elem.id
@@ -119,10 +122,13 @@ function addMobileNav(resizedEventName) {
119
122
 
120
123
  document.body.appendChild(overlay);
121
124
  icon.setAttribute(dataOpen, dataOpen);
125
+ icon.setAttribute('aria-expanded', 'true');
122
126
  focusElements.first.focus();
123
127
  }
124
128
 
125
129
  function closeMobileMenu() {
130
+ const menuElement = qs('#' + navigationSelector);
131
+ menuElement.style.display = 'initial';
126
132
  document.body.style.overflow = 'auto';
127
133
  document.documentElement.style.paddingInlineEnd = '0';
128
134
 
@@ -134,6 +140,7 @@ function addMobileNav(resizedEventName) {
134
140
 
135
141
  icon.innerHTML = originalIcon;
136
142
  icon.removeAttribute(dataOpen);
143
+ icon.setAttribute('aria-expanded', 'false');
137
144
  }
138
145
 
139
146
  icon.addEventListener('click', function (e) {
@@ -13,7 +13,7 @@ function enhanceSearchIcon() {
13
13
  const form = doc.querySelector('#site-search');
14
14
  const input = form.querySelector('#site-search-query');
15
15
  const results = doc.querySelector('#site-search-results');
16
-
16
+ icon.setAttribute('aria-expanded', 'false');
17
17
 
18
18
  input?.setAttribute('autofocus', 'autofocus');
19
19
 
@@ -26,8 +26,7 @@ function enhanceSearchIcon() {
26
26
  <line x1="18" y1="6" x2="6" y2="18"></line>
27
27
  <line x1="6" y1="6" x2="18" y2="18"></line>
28
28
  </svg>`;
29
- close.addEventListener('click', () => dialog.close());
30
-
29
+
31
30
  const script = doc.querySelector('script[src*="/search.js"]');
32
31
  const scr = document.createElement('script');
33
32
  for (let att, i = 0, atts = script.attributes, n = atts.length; i < n; i++){
@@ -45,8 +44,12 @@ function enhanceSearchIcon() {
45
44
  icon.addEventListener('click', (e) => {
46
45
  e.preventDefault();
47
46
  dialog.showModal();
47
+ icon.setAttribute('aria-expanded', 'true');
48
48
  return false;
49
- })
49
+ });
50
+
51
+ close.addEventListener('click', () => dialog.close());
52
+ dialog.addEventListener('close', () => icon.setAttribute('aria-expanded', 'false'));
50
53
  });
51
54
  }
52
55
  }
@@ -25,7 +25,7 @@ const search = accelerator.posts.all().filter(PostFiltering.isSearch).shift() ??
25
25
  stats.stop();
26
26
  ---
27
27
  <header class="site-header">
28
- <a href="#site-nav" data-navigationid="site-nav" class="navigation-icon" title={ _(Translations.header.open_menu) }><svg xmlns="http://www.w3.org/2000/svg"
28
+ <a href="#site-nav" data-navigationid="site-nav" class="navigation-icon" title={ _(Translations.header.toggle_menu) }><svg xmlns="http://www.w3.org/2000/svg"
29
29
  width="40" height="40" viewBox="0 0 24 24" stroke-width="1.5"
30
30
  fill="none" stroke-linecap="round" stroke-linejoin="round">
31
31
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
@@ -35,7 +35,7 @@ stats.stop();
35
35
  </svg></a>
36
36
  <a href={ (SITE.subfolder ?? '') + '/' } class="site-title" translate="no">{ SITE.title }</a>
37
37
  {search != null &&
38
- <a href={ accelerator.urlFormatter.formatAddress(search.url) } class="search-icon" title={ _(Translations.header.open_search) }><svg xmlns="http://www.w3.org/2000/svg"
38
+ <a href={ accelerator.urlFormatter.formatAddress(search.url) } class="search-icon" title={ _(Translations.header.toggle_search) }><svg xmlns="http://www.w3.org/2000/svg"
39
39
  width="40" height="40" viewBox="0 0 24 24" stroke-width="1"
40
40
  fill="none" stroke-linecap="round" stroke-linejoin="round">
41
41
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
@@ -51,7 +51,6 @@ stats.stop();
51
51
  <Header frontmatter={ frontmatter } headings={ headings } lang={ lang } />
52
52
  <Breadcrumbs frontmatter={ frontmatter } headings={ headings } lang={ lang } breadcrumbs={ breadcrumbs } />
53
53
  <div class="content-group">
54
- <Navigation lang={ lang } />
55
54
  <main id="site-main">
56
55
  <article itemscope itemtype="https://schema.org/Article">
57
56
  <header>
@@ -70,6 +69,7 @@ stats.stop();
70
69
  </div>
71
70
  </article>
72
71
  </main>
72
+ <Navigation lang={ lang } />
73
73
  </div>
74
74
  <Footer frontmatter={ frontmatter } headings={ headings } lang={ lang }>
75
75
  <Copyright frontmatter={ frontmatter } headings={ headings } lang={ lang } />
@@ -4,7 +4,7 @@
4
4
  "en": "Breadcrumb"
5
5
  },
6
6
  "site_navigation": {
7
- "en": "Site Navigation"
7
+ "en": "Site"
8
8
  },
9
9
  "toc": {
10
10
  "en": "Table of contents"
@@ -34,11 +34,11 @@
34
34
  }
35
35
  },
36
36
  "header": {
37
- "open_menu": {
38
- "en": "Open menu"
37
+ "toggle_menu": {
38
+ "en": "Toggle menu"
39
39
  },
40
- "open_search": {
41
- "en": "Open site search"
40
+ "toggle_search": {
41
+ "en": "Toggle site search"
42
42
  }
43
43
  },
44
44
  "navigation": {