@nys-cui/cui-section 0.2.2 → 0.2.4

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.2.2",
9
+ "version": "0.2.4",
10
10
  "scripts": {
11
11
  "clean": "rm -rf ./dist",
12
12
  "build": "npm run clean && cui --dep",
package/src/section.js CHANGED
@@ -31,17 +31,17 @@ export default class CUI_SECTION extends HTMLElement {
31
31
 
32
32
  get template() {
33
33
 
34
- let sTemplate = `<section><header>
35
- <h2 id="section-title"></h2>`;
34
+ let sTemplate = `<section part="root-section"><header part="section-header">
35
+ <h2 id="section-title" part="section-title"></h2>`;
36
36
 
37
37
  if (!this.state.bHideControls) {
38
38
 
39
39
  if (this.sIconBasePath) {
40
40
 
41
41
  sTemplate += `
42
- <div class="header-controls">
43
- <button type="button" id="collapse-control" aria-controls="container">
44
- <cui-icon src="caret-down" base="${this.sIconBasePath}"></cui-icon>
42
+ <div class="header-controls" part="header-controls">
43
+ <button type="button" id="collapse-control" aria-controls="container" part="collapse-control">
44
+ <cui-icon src="caret-down" base="${this.sIconBasePath}" part="collapse-control-icon"></cui-icon>
45
45
  </button>
46
46
  </div>`;
47
47
 
@@ -49,16 +49,16 @@ export default class CUI_SECTION extends HTMLElement {
49
49
  else {
50
50
 
51
51
  sTemplate += `
52
- <div class="header-controls">
53
- <button type="button" id="collapse-control" aria-controls="container">
54
- <cui-icon src="caret-down"></cui-icon>
52
+ <div class="header-controls" part="header-controls">
53
+ <button type="button" id="collapse-control" aria-controls="container" part="collapse-control">
54
+ <cui-icon src="caret-down" part="collapse-control-icon"></cui-icon>
55
55
  </button>
56
56
  </div>`;
57
57
  }
58
58
 
59
59
  }
60
60
 
61
- sTemplate += `</header><div class="container" id="container">
61
+ sTemplate += `</header><div class="container" id="container" part="container">
62
62
  <slot name="section-text"></slot>
63
63
  <slot name="section-contents"></slot>
64
64
  <slot name="section-footer"></slot>
@@ -73,6 +73,7 @@ export default class CUI_SECTION extends HTMLElement {
73
73
 
74
74
  // remove "height" from the dContainer's inline styles, so it can return to its initial value
75
75
  dContainer.style.height = "";
76
+ dContainer.style.overflow = null;
76
77
 
77
78
  // mark the section as "currently not collapsed"
78
79
  dContainer.setAttribute('data-collapsed', 'false');
@@ -91,6 +92,7 @@ export default class CUI_SECTION extends HTMLElement {
91
92
 
92
93
  // have the dContainer transition to the height of its inner content
93
94
  dContainer.style.height = sectionHeight + 'px';
95
+ dContainer.style.overflow = "hidden";
94
96
 
95
97
  // when the next css transition finishes (which should be the one we just triggered)
96
98
  dContainer.addEventListener('transitionend', transitionEnd, true);
@@ -103,6 +105,7 @@ export default class CUI_SECTION extends HTMLElement {
103
105
  function transitionEnd(e) {
104
106
 
105
107
  dContainer.style.height = "";
108
+ dContainer.style.overflow = null;
106
109
 
107
110
  // mark the section as "currently collapsed"
108
111
  dContainer.setAttribute('data-collapsed', 'true');
@@ -126,7 +129,7 @@ export default class CUI_SECTION extends HTMLElement {
126
129
  requestAnimationFrame(function() {
127
130
  dContainer.style.height = sectionHeight + 'px';
128
131
  dContainer.style.transition = dContainerTransition;
129
-
132
+ dContainer.style.overflow = "hidden";
130
133
 
131
134
  // on the next frame (as soon as the previous style change has taken effect),
132
135
  // have the dContainer transition to height: 0
@@ -147,7 +150,7 @@ export default class CUI_SECTION extends HTMLElement {
147
150
 
148
151
  this.state = {
149
152
  sTitle: this.getAttribute('sectiontitle') || "SECTION TITLE",
150
- bHideControls: (this.getAttribute("hideControls") === "true") ? true : false,
153
+ bHideControls: this.hasAttribute("hideControls") ? true : false,
151
154
  bCollapsed: (this.getAttribute('collapsed') === "true") ? true : false,
152
155
  asStyles: (this.getAttribute('styles')) ? this.getAttribute('styles').split(',') : null
153
156
  }
package/src/section.scss CHANGED
@@ -64,15 +64,21 @@
64
64
  }
65
65
 
66
66
  .container {
67
+ box-sizing:content-box;
67
68
  //margin: 0 0.75em 20px;
68
69
  //margin: 0 0.75em;
69
- transition: height 0.5s ease;
70
- overflow: hidden;
70
+ transition: height 0.5s ease;
71
71
 
72
72
  &[data-collapsed="true"] {
73
73
  height: 0;
74
+ overflow: hidden;
74
75
  }
75
76
 
77
+ // Prevent margin collapse of section contents when collapsing/expanding.
78
+ &::before, &::after{
79
+ content: ' ';
80
+ display: table;
81
+ }
76
82
 
77
83
  }
78
84
  }