Skip to content

Commit

Permalink
DRY the toggle code
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Oct 1, 2019
1 parent 6c0d063 commit 38c71dc
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions _inc/client/plans/plan-grid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,23 @@ class PlanGrid extends React.Component {

renderPlanPeriodToggle() {
const { period } = this.state;
const periods = {
monthly: __( 'Monthly' ),
yearly: __( 'Yearly' ),
};

return (
<div className="plan-grid-period">
<ButtonGroup>
<Button
primary={ 'monthly' === period }
onClick={ this.handlePeriodChange( 'monthly' ) }
compact
>
{ __( 'Monthly' ) }
</Button>
<Button
primary={ 'yearly' === period }
onClick={ this.handlePeriodChange( 'yearly' ) }
compact
>
{ __( 'Yearly' ) }
</Button>
{ map( periods, ( periodLabel, periodName ) => (
<Button
primary={ periodName === period }
onClick={ this.handlePeriodChange( periodName ) }
compact
>
{ periodLabel }
</Button>
) ) }
</ButtonGroup>
</div>
);
Expand Down

0 comments on commit 38c71dc

Please sign in to comment.