22 * WordPress dependencies
33 */
44import {
5- Button ,
65 Icon ,
76 __experimentalText as Text ,
87 __experimentalHeading as Heading ,
98 __experimentalVStack as VStack ,
109 __experimentalHStack as HStack ,
1110 Card ,
11+ Button ,
1212} from '@wordpress/components' ;
1313import { __ , sprintf } from '@wordpress/i18n' ;
1414import { chevronDown } from '@wordpress/icons' ;
@@ -32,10 +32,25 @@ export default function GuidelineAccordion( {
3232
3333 return (
3434 < Card className = "content-guidelines__accordion" >
35- < VStack
36- spacing = { 4 }
35+ < Button
36+ className = "content-guidelines__accordion-trigger"
3737 onClick = { ( ) => setIsOpen ( ! isOpen ) }
38- className = "content-guidelines__accordion-header-container"
38+ aria-expanded = { isOpen }
39+ aria-controls = { contentId }
40+ aria-describedby = { descriptionId }
41+ aria-label = {
42+ isOpen
43+ ? sprintf (
44+ /* translators: %s: Guideline title */
45+ __ ( 'Collapse %s guidelines' ) ,
46+ title
47+ )
48+ : sprintf (
49+ /* translators: %s: Guideline title */
50+ __ ( 'Expand %s guidelines' ) ,
51+ title
52+ )
53+ }
3954 >
4055 < HStack spacing = { 4 } >
4156 < VStack spacing = { 1 } >
@@ -58,42 +73,17 @@ export default function GuidelineAccordion( {
5873 { description }
5974 </ Text >
6075 </ VStack >
61- < Button
62- icon = {
63- < Icon
64- icon = { chevronDown }
65- className = {
66- isOpen
67- ? 'content-guidelines__accordion-chevron-up'
68- : 'content-guidelines__accordion-chevron-down'
69- }
70- />
71- }
72- onClick = { (
73- event : React . MouseEvent < HTMLButtonElement >
74- ) => {
75- event . stopPropagation ( ) ;
76- setIsOpen ( ! isOpen ) ;
77- } }
78- aria-expanded = { isOpen }
79- aria-controls = { contentId }
80- aria-label = {
76+ < Icon
77+ icon = { chevronDown }
78+ className = {
8179 isOpen
82- ? sprintf (
83- /* translators: %s: Guideline title */
84- __ ( 'Collapse %s guidelines' ) ,
85- title
86- )
87- : sprintf (
88- /* translators: %s: Guideline title */
89- __ ( 'Expand %s guidelines' ) ,
90- title
91- )
80+ ? 'content-guidelines__accordion-chevron-up'
81+ : 'content-guidelines__accordion-chevron-down'
9282 }
9383 />
9484 </ HStack >
95- </ VStack >
96- { isOpen && children }
85+ </ Button >
86+ < div hidden = { ! isOpen } > { children } </ div >
9787 </ Card >
9888 ) ;
9989}
0 commit comments