-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add new Accordion Section for advanced options
- Loading branch information
1 parent
fd07038
commit 1108821
Showing
4 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
modules/ppcp-settings/resources/css/components/reusable-components/_accordion-section.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.ppcp-r-accordion { | ||
|
||
&--title { | ||
@include font(14, 32, 450); | ||
color: $color-gray-900; | ||
|
||
display: flex; | ||
align-items: center; | ||
gap: 16px; | ||
margin: 24px auto; | ||
border: 0; | ||
background: transparent; | ||
cursor: pointer; | ||
} | ||
|
||
&--content { | ||
margin: 24px 0 0; | ||
} | ||
|
||
&.open { | ||
.ppcp-r-accordion--icon { | ||
transform: rotate(180deg); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
modules/ppcp-settings/resources/js/Components/ReusableComponents/AccordionSection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { useState } from 'react'; | ||
import data from '../../utils/data'; | ||
|
||
const Accordion = ( { title, initiallyOpen, children } ) => { | ||
const [ isOpen, setIsOpen ] = useState( initiallyOpen ); | ||
|
||
const toggleOpen = ( ev ) => { | ||
setIsOpen( ! isOpen ); | ||
ev?.preventDefault(); | ||
return false; | ||
}; | ||
|
||
const iconChevron = data().getImage( | ||
'icon-arrow-down.svg', | ||
'ppcp-r-accordion--icon' | ||
); | ||
|
||
return ( | ||
<div className={ `ppcp-r-accordion ${ isOpen ? 'open' : '' }` }> | ||
<button | ||
onClick={ toggleOpen } | ||
className="ppcp-r-accordion--title" | ||
type="button" | ||
> | ||
{ title } | ||
{ iconChevron } | ||
</button> | ||
{ isOpen && ( | ||
<div className="ppcp-r-accordion--content">{ children }</div> | ||
) } | ||
</div> | ||
); | ||
}; | ||
|
||
export default Accordion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters