Skip to content

Commit 57397f9

Browse files
author
castastrophe
committed
Add comments to the content set component
1 parent b2384c2 commit 57397f9

File tree

3 files changed

+5626
-5599
lines changed

3 files changed

+5626
-5599
lines changed

elements/pfe-content-set/src/pfe-content-set.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PfeContentSet extends PFElement {
2626
}
2727

2828
get orientation() {
29-
return this.hasAttribute("vertical") ? "vertical" : null;
29+
return this.hasAttribute("vertical") ? "vertical" : "horizontal";
3030
}
3131

3232
get settings() {
@@ -63,62 +63,91 @@ class PfeContentSet extends PFElement {
6363
}
6464

6565
_buildAccordion() {
66+
// Use a document fragment for efficiency
6667
const fragment = document.createDocumentFragment();
68+
// Create the accordion wrapper component
6769
const accordion = document.createElement("pfe-accordion");
6870

71+
// Iterate over each element in the light DOM
6972
[...this.children].forEach(child => {
73+
// If one of them has the attribute indicating they belong in the header region
7074
if (child.hasAttribute("pfe-content-set--header")) {
75+
// Create a header component
7176
const header = document.createElement("pfe-accordion-header");
77+
// Append the light DOM element to that component
7278
header.appendChild(child);
79+
// Append the component to the accordion parent
7380
accordion.appendChild(header);
7481
}
75-
82+
// If one of them has the attribute indicating they belong in the panel region
7683
if (child.hasAttribute("pfe-content-set--panel")) {
84+
// Create a panel component
7785
const panel = document.createElement("pfe-accordion-panel");
86+
// Append the light DOM element to that component
7887
panel.appendChild(child);
88+
// Append the component to the accordion parent
7989
accordion.appendChild(panel);
8090
}
8191
});
8292

93+
// Append the accordion to the document fragment
8394
fragment.appendChild(accordion);
8495

96+
// Pass the color property down to the accordion component
8597
if (this.settings.color) {
8698
accordion.setAttribute("color", this.settings.color);
8799
}
88100

101+
// Append the fragment to the component
89102
this.appendChild(fragment);
90103
}
91104

92105
_buildTabs() {
106+
// Use a document fragment for efficiency
93107
const fragment = document.createDocumentFragment();
108+
// Create the tabs wrapper component
94109
const tabs = document.createElement("pfe-tabs");
95110

111+
// Iterate over each element in the light DOM
96112
[...this.children].forEach(child => {
113+
// If one of them has the attribute indicating they belong in the header region
97114
if (child.hasAttribute("pfe-content-set--header")) {
115+
// Create a tab component
98116
const header = document.createElement("pfe-tab");
117+
// Set the attribute indicating its slot
99118
header.setAttribute("slot", "tab");
119+
// Append the light DOM element to that component
100120
header.appendChild(child);
121+
// Append the component to the tabs parent
101122
tabs.appendChild(header);
102123
}
103-
124+
// If one of them has the attribute indicating they belong in the panel region
104125
if (child.hasAttribute("pfe-content-set--panel")) {
126+
// Create the panel component
105127
const panel = document.createElement("pfe-tab-panel");
128+
// Set the attribute indicating its slot
106129
panel.setAttribute("slot", "panel");
130+
// Append the light DOM element to that component
107131
panel.appendChild(child);
132+
// Append the component to the tabs parent
108133
tabs.appendChild(panel);
109134
}
110135
});
111136

137+
// Append the tabs to the document fragment
112138
fragment.appendChild(tabs);
113139

114-
if (this.orientation) {
140+
// If the orientation is set to vertical, add that attribute to the tabs
141+
if (this.orientation === "vertical") {
115142
tabs.setAttribute("vertical", true);
116143
}
117144

145+
// Pass the variant attribute down to the tabs component
118146
if (this.settings.variant) {
119147
tabs.setAttribute("pfe-variant", this.settings.variant);
120148
}
121149

150+
// Append the fragment to the component
122151
this.appendChild(fragment);
123152
}
124153
}

examples/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ <h1>Demos</h1>
2222
<li><a href="../elements/pfe-icon/demo">pfe-icon</a></li>
2323
<li><a href="../elements/pfe-icon-panel/demo">pfe-icon-panel</a></li>
2424
<li><a href="../elements/pfe-layouts/demo">pfe-layouts</a></li>
25-
<li><a href="../elements/pfe-link-list/demo">pfe-link-list</a></li>
26-
<li><a href="../elements/pfe-navigation/demo">pfe-navigation</a></li>
2725
<li><a href="../elements/pfe-number/demo">pfe-number</a></li>
2826
<li><a href="../elements/pfe-tabs/demo">pfe-tabs</a></li>
2927
</ul>

0 commit comments

Comments
 (0)