@@ -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}
0 commit comments