Skip to content

Commit

Permalink
not working no errors
Browse files Browse the repository at this point in the history
  • Loading branch information
philli-m committed Nov 25, 2021
1 parent 615b216 commit a4633fc
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 102 deletions.
11 changes: 0 additions & 11 deletions meinberlin/apps/budgeting/assets/BudgetingProposalList.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useState } from 'react'
import { BudgetingProposalListItem } from './BudgetingProposalListItem'
import { Pagination } from './Pagination'
import IconSwitch from '../../contrib/assets/IconSwitch'

export const BudgetingProposalList = (props) => {
const [data, setData] = useState([])
Expand Down Expand Up @@ -34,16 +33,6 @@ export const BudgetingProposalList = (props) => {
return (
<div className="l-wrapper">
<div className="l-center-8">
<IconSwitch
activeClass="btn btn--icon btn--light switch--btn active"
inactiveClass="btn btn--icon btn--light"
startText="List"
endText="Map"
startIconClass="fa fa-list"
endIconClass="fa fa-map"
startID="show_list"
endID="show_map"
/>
<ul className="u-list-reset">
{data.map((proposal, idx) =>
<BudgetingProposalListItem
Expand Down
125 changes: 58 additions & 67 deletions meinberlin/apps/contrib/assets/IconSwitch.jsx
Original file line number Diff line number Diff line change
@@ -1,73 +1,64 @@
import React from 'react'

export default class IconSwitch extends React.Component {
constructor (props) {
super(props)
export const IconSwitch = (props) => {
const {
activeClass,
inactiveClass,
startIconClass,
endIconClass,
startText,
endText,
startID,
endID,
startAria,
endAria,
showStartObject,
showEndObject,
displayStartObject
} = props

this.state = {
showObject: false
}
}

handleStartActive () {
this.setState({ showObject: false })
}

handleEndActive () {
this.setState({ showObject: true })
}

render () {
const selectedClass = this.props.activeClass
const unselectedClass = this.props.inactiveClass
const startIconClass = this.props.startIconClass
const endIconClass = this.props.endIconClass
const startText = this.props.startText
const endText = this.props.endText
const startID = this.props.startID
const endID = this.props.endID

return (
<div>
<div className="switch-btn-group-container">
<div className="btn-group switch-btn-group" role="group">
<label
htmlFor={startID}
className={!this.state.showObject ? selectedClass : unselectedClass}
>
<input
className="radio__input"
type="radio"
value={startID}
id={startID}
aria-label={startText}
checked={this.state.showObject}
onClick={(e) => this.handleStartActive(e)}
onKeyDown={(e) => this.handleStartActive(e)}
/>
<i className={startIconClass} />
<span>{startText}</span>
</label>
<label
htmlFor={endID}
className={this.state.showObject ? selectedClass : unselectedClass}
>
<input
className="radio__input"
type="radio"
id={endID}
value={endID}
aria-label={endText}
checked={!this.state.showObject}
onClick={(e) => this.handleEndActive(e)}
onKeyDown={(e) => this.handleEndActive(e)}
/>
<i className={endIconClass} />
<span>{endText}</span>
</label>
</div>
return (
<div>
<div className="switch-btn-group-container">
<div className="btn-group switch-btn-group" role="group">
<label
htmlFor={startID}
className={!displayStartObject ? activeClass : inactiveClass}
>
<input
className="radio__input"
type="radio"
value={startID}
id={startID}
aria-label={startAria}
checked={displayStartObject}
onChange={showStartObject}
onClick={showStartObject}
onKeyDown={showStartObject}
/>
<i className={startIconClass} />
<span>{startText}</span>
</label>
<label
htmlFor={endID}
className={displayStartObject ? activeClass : inactiveClass}
>
<input
className="radio__input"
type="radio"
id={endID}
value={endID}
aria-label={endAria}
checked={!displayStartObject}
onChange={showEndObject}
onClick={showEndObject}
onKeyDown={showEndObject}
/>
<i className={endIconClass} />
<span>{endText}</span>
</label>
</div>
</div>
)
}
</div>
)
}
42 changes: 18 additions & 24 deletions meinberlin/apps/plans/assets/Toggles.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global django */
const React = require('react')
import React from 'react'
import django from 'django'
import { IconSwitch } from '../../contrib/assets/IconSwitch'

class Toggles extends React.Component {
clickStatusButton () {
Expand Down Expand Up @@ -122,28 +123,21 @@ class Toggles extends React.Component {
>{this.titleSearchButtonString()} <i className="fa fa-times" />
</button>}
</div>
<div className="switch-btn-group-container">
<div className="btn-group switch-btn-group" role="group">
<switch
className={!this.props.displayMap ? 'btn btn--light switch--btn active' : 'btn btn--light'}
onClick={this.props.showList} // eslint-disable-line react/jsx-handler-names
htmlFor="show_list"
>
<input className="radio__input" type="radio" value="list" id="show_list" aria-label={django.gettext('show list')} />
<i className="fa fa-list" />
<span> {django.gettext('List')}</span>
</switch>
<switch
className={this.props.displayMap ? 'btn btn--light switch--btn active' : 'btn btn--light'}
onClick={this.props.showMap} // eslint-disable-line react/jsx-handler-names
htmlFor="show_map"
>
<input className="radio__input" type="radio" value="map" id="show_map" aria-label={django.gettext('show map')} />
<i className="fa fa-map" />
<span> {django.gettext('Map')}</span>
</switch>
</div>
</div>
<IconSwitch
activeClass="btn btn--icon btn--light switch--btn active"
inactiveClass="btn btn--icon btn--light"
startText={django.gettext('List')}
endText={django.gettext('Map')}
startAria={django.gettext('show list')}
endAria={django.gettext('show map')}
startIconClass="fa fa-list"
endIconClass="fa fa-map"
startID="show_list"
endID="show_map"
displayStartObject={!this.props.displayMap}
showStartObject={this.props.showList}
showEndObject={this.props.showMap}
/>
</div>
</div>
)
Expand Down

0 comments on commit a4633fc

Please sign in to comment.