Accordion: use children instead of content

This commit is contained in:
Alex Gleason 2020-12-31 20:18:57 -06:00
parent a8893907d4
commit a1db330b14
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 31 additions and 33 deletions

View file

@ -92,7 +92,9 @@ class CommunityTimeline extends React.PureComponent {
<div className='explanation-box'> <div className='explanation-box'>
<Accordion <Accordion
headline={<FormattedMessage id='fediverse_tab.explanation_box.title' defaultMessage='What is the Fediverse?' />} headline={<FormattedMessage id='fediverse_tab.explanation_box.title' defaultMessage='What is the Fediverse?' />}
content={( expanded={explanationBoxExpanded}
onToggle={this.toggleExplanationBox}
>
<FormattedMessage <FormattedMessage
id='fediverse_tab.explanation_box.explanation' id='fediverse_tab.explanation_box.explanation'
defaultMessage='{site_title} is part of the Fediverse, a social network made up of thousands of independent social media sites (aka "servers"). The posts you see here are from 3rd-party servers. You have the freedom to engage with them, or to block any server you don&apos;t like. Pay attention to the full username after the second @ symbol to know which server a post is from. To see only {site_title} posts, visit {local}.' defaultMessage='{site_title} is part of the Fediverse, a social network made up of thousands of independent social media sites (aka "servers"). The posts you see here are from 3rd-party servers. You have the freedom to engage with them, or to block any server you don&apos;t like. Pay attention to the full username after the second @ symbol to know which server a post is from. To see only {site_title} posts, visit {local}.'
@ -109,10 +111,7 @@ class CommunityTimeline extends React.PureComponent {
), ),
}} }}
/> />
)} </Accordion>
expanded={explanationBoxExpanded}
onToggle={this.toggleExplanationBox}
/>
</div> </div>
<StatusListContainer <StatusListContainer
scrollKey={`${timelineId}_timeline`} scrollKey={`${timelineId}_timeline`}

View file

@ -308,7 +308,9 @@ class SoapboxConfig extends ImmutablePureComponent {
</FieldsGroup> </FieldsGroup>
<Accordion <Accordion
headline={intl.formatMessage(messages.rawJSONLabel)} headline={intl.formatMessage(messages.rawJSONLabel)}
content={( expanded={this.state.jsonEditorExpanded}
onToggle={this.toggleJSONEditor}
>
<div className={this.state.jsonValid ? 'code-editor' : 'code-editor code-editor--invalid'}> <div className={this.state.jsonValid ? 'code-editor' : 'code-editor code-editor--invalid'}>
<SimpleTextarea <SimpleTextarea
hint={intl.formatMessage(messages.rawJSONHint)} hint={intl.formatMessage(messages.rawJSONHint)}
@ -317,10 +319,7 @@ class SoapboxConfig extends ImmutablePureComponent {
rows={12} rows={12}
/> />
</div> </div>
)} </Accordion>
expanded={this.state.jsonEditorExpanded}
onToggle={this.toggleJSONEditor}
/>
</fieldset> </fieldset>
<div className='actions'> <div className='actions'>
<button name='button' type='submit' className='btn button button-primary'> <button name='button' type='submit' className='btn button button-primary'>

View file

@ -12,7 +12,7 @@ export default @injectIntl class Accordion extends React.PureComponent {
static propTypes = { static propTypes = {
headline: PropTypes.node.isRequired, headline: PropTypes.node.isRequired,
content: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), children: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
expanded: PropTypes.bool, expanded: PropTypes.bool,
onToggle: PropTypes.func, onToggle: PropTypes.func,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
@ -29,7 +29,7 @@ export default @injectIntl class Accordion extends React.PureComponent {
} }
render() { render() {
const { headline, content, expanded, intl } = this.props; const { headline, children, expanded, intl } = this.props;
return ( return (
<div className={classNames('accordion', { 'accordion--expanded' : expanded })}> <div className={classNames('accordion', { 'accordion--expanded' : expanded })}>
@ -42,7 +42,7 @@ export default @injectIntl class Accordion extends React.PureComponent {
{headline} {headline}
</button> </button>
<div className='accordion__content'> <div className='accordion__content'>
{content} {children}
</div> </div>
</div> </div>
); );