@nys-cui/cui-section 0.1.3 → 0.2.1

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
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "main": "./dist/js/section.js",
8
8
  "type": "module",
9
- "version": "0.1.3",
9
+ "version": "0.2.1",
10
10
  "scripts": {
11
11
  "clean": "rm -rf ./dist",
12
12
  "build": "npm run clean && cui --dep",
package/src/section.js CHANGED
@@ -40,7 +40,7 @@ export default class CUI_SECTION extends HTMLElement {
40
40
 
41
41
  sTemplate += `
42
42
  <div class="header-controls">
43
- <button type="button" id="collapse-control">
43
+ <button type="button" id="collapse-control" aria-controls="container">
44
44
  <cui-icon src="caret-down" base="${this.sIconBasePath}"></cui-icon>
45
45
  </button>
46
46
  </div>`;
@@ -50,7 +50,7 @@ export default class CUI_SECTION extends HTMLElement {
50
50
 
51
51
  sTemplate += `
52
52
  <div class="header-controls">
53
- <button type="button" id="collapse-control">
53
+ <button type="button" id="collapse-control" aria-controls="container">
54
54
  <cui-icon src="caret-down"></cui-icon>
55
55
  </button>
56
56
  </div>`;
@@ -76,12 +76,15 @@ export default class CUI_SECTION extends HTMLElement {
76
76
 
77
77
  // mark the section as "currently not collapsed"
78
78
  dContainer.setAttribute('data-collapsed', 'false');
79
+ dContainer.setAttribute('aria-expanded', 'true');
79
80
 
80
81
  // remove this event listener so it only gets triggered once
81
82
  dContainer.removeEventListener('transitionend', transitionEnd, this);
82
83
 
83
84
  }
84
85
 
86
+ dContainer.removeAttribute('aria-expanded');
87
+
85
88
  this.bLock = true;
86
89
 
87
90
  var sectionHeight = dContainer.scrollHeight;
@@ -101,12 +104,15 @@ export default class CUI_SECTION extends HTMLElement {
101
104
 
102
105
  // mark the section as "currently collapsed"
103
106
  dContainer.setAttribute('data-collapsed', 'true');
107
+ dContainer.setAttribute('aria-expanded', 'false');
104
108
 
105
109
  dContainer.style.height = "";
106
110
 
107
111
  dContainer.removeEventListener('transitionend', transitionEnd, true);
108
112
  }
109
113
 
114
+ dContainer.removeAttribute('aria-expanded');
115
+
110
116
  // get the height of the dContainer's inner content, regardless of its actual size
111
117
  var sectionHeight = dContainer.scrollHeight;
112
118
 
@@ -137,6 +143,16 @@ export default class CUI_SECTION extends HTMLElement {
137
143
 
138
144
  }
139
145
 
146
+ animationstart() {
147
+
148
+ console.log("Animation started");
149
+ }
150
+
151
+ animationend() {
152
+
153
+ console.log("Animation ended");
154
+ }
155
+
140
156
  connectedCallback() {
141
157
 
142
158
  this.state = {
@@ -159,9 +175,17 @@ export default class CUI_SECTION extends HTMLElement {
159
175
  this.sdSectionTitle = this.shadowRoot.querySelector(`#section-title`);
160
176
  this.sdContentsContainer = this.shadowRoot.querySelector(`#container`);
161
177
 
178
+ if (this.bCollapsed) {
179
+ this.sdContentsContainer.setAttribute('aria-expanded', 'false');
180
+ }
181
+ else {
182
+ this.sdContentsContainer.setAttribute('aria-expanded', 'true');
183
+ }
184
+
185
+
162
186
  this.sdSectionTitle.appendChild(document.createTextNode(this.state.sTitle));
163
187
 
164
- if (!this.state.bHideControls) {
188
+ if (!this.state.bHideControls) {
165
189
 
166
190
  this.sdSectionCollapseControl = this.shadowRoot.querySelector(`#collapse-control`);
167
191
 
@@ -173,6 +197,7 @@ export default class CUI_SECTION extends HTMLElement {
173
197
 
174
198
  this.sdSectionCollapseControl.classList.add('collapsed');
175
199
  this.sdContentsContainer.setAttribute('data-collapsed', "true");
200
+ this.sdContentsContainer.setAttribute('aria-expanded', "false");
176
201
  }
177
202
 
178
203
  this.sdSectionCollapseControl.addEventListener('click', () => {
package/src/section.scss CHANGED
@@ -72,6 +72,9 @@
72
72
  height: 0;
73
73
  }
74
74
 
75
+ &[aria-expanded="false"] {
76
+ display: none;
77
+ }
75
78
 
76
79
  }
77
80
  }