-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1850 from newamericafoundation/accordion-blocks
Accordion blocks
- Loading branch information
Showing
9 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,49 @@ | ||
import '../home-panels/pages/Jobs.scss'; | ||
|
||
import React, { Component } from 'react'; | ||
import { PlusX } from '../components/Icons'; | ||
|
||
const NAME = 'accordionBlock'; | ||
const ID = 'accordion-block'; | ||
|
||
|
||
class APP extends Component { | ||
state = { | ||
expanded: new Set() | ||
} | ||
|
||
toggleExpand = (i) => { | ||
let updated = new Set(this.state.expanded); | ||
if (updated.has(i)) { | ||
updated.delete(i); | ||
} else { | ||
updated.add(i); | ||
} | ||
this.setState({expanded: updated}); | ||
} | ||
|
||
render() { | ||
let { items } = this.props; | ||
let { expanded } = this.state; | ||
let itemsArray = JSON.parse(items); | ||
return ( | ||
<section className="padding-80"> | ||
<div className="home__fellowships"> | ||
<div className="menu-list"> | ||
{itemsArray.map((item, i) => ( | ||
<div key={`accordion-${i}`} className={`${expanded.has(i) ? 'expanded ': ''}home__fellowship`}> | ||
<PlusX x={expanded.has(i)} /> | ||
<h2 onClick={()=>{ this.toggleExpand(i) }}>{item.title}</h2> | ||
<div className="home__fellowship__more"> | ||
<div dangerouslySetInnerHTML={{__html: item.body }} /> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} | ||
} | ||
|
||
export default { APP, NAME, ID, MULTI: true }; |
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
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
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
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 @@ | ||
<div class="na-react__accordion-block" data-items="{{ items }}"></div> |
Large diffs are not rendered by default.
Oops, something went wrong.