<commit_before>/* global django */
const React = require('react')

class Toggles extends React.Component {
  clickStatusButton () {
    this.props.changeStatusSelection(-1)
  }

  clickParticipationButton () {
    this.props.changeParticipationSelection(-1)
  }

  clickOrganisationButton () {
    this.props.changeOrganisationSelection('-1')
  }

  clickTitleSearchButton () {
    this.props.changeTitleSearchSelection('-1')
  }

  titleSearchButtonString () {
    if (this.props.titleSearchString.length > 20) {
      return this.props.titleSearchString.substr(0, 20) + '...'
    }
    return this.props.titleSearchString
  }

  organisationButtonString () {
    if (this.props.organisationString.length > 20) {
      return this.props.organisationString.substr(0, 20) + '...'
    }
    return this.props.organisationString
  }

  render () {
    if (this.props.isSlider) {
      return (
        <div>
          <div className="l-frame switch-container">
            <div className={this.props.displayButtons ? 'switch-filter__label' : 'd-none'}>{this.props.projectCount}{django.gettext(' search results')}</div>
            <div className="switch-filter__btn-group">
              {this.props.displayButtons && this.props.statusSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickStatusButton.bind(this)}
                  type="button"
                >{this.props.statusString} {this.props.statusCount} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.participationSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickParticipationButton.bind(this)}
                  type="button"
                >{this.props.participationString} {this.props.participationCount} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.organisationSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickOrganisationButton.bind(this)}
                  type="button"
                >{this.organisationButtonString()} {this.props.organisationCount} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.titleSearchSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickTitleSearchButton.bind(this)}
                  type="button"
                >{this.titleSearchButtonString()} {this.props.titleSearchCount} <i className="fa fa-times" />
                </button>}
            </div>
            <div className="switch">
              <div className="switch-group" role="group" aria-labelledby="id-switch-label">
                <label htmlFor="switch-primary" className="switch-label">
                  <span className="switch-label__text">{django.gettext('Show map')}</span>
                  <input
                    className="switch-input"
                    id="switch-primary"
                    onChange={this.props.toggleSwitch} /* eslint-disable-line react/jsx-handler-names */
                    name="switch-primary"
                    type="checkbox"
                  />
                  <span className="switch__toggle" />
                </label>
              </div>
            </div>
          </div>
        </div>
      )
    } else {
      return (
        <div>
          <div className="l-frame switch-container">
            <div className={this.props.displayButtons ? 'switch-filter__label' : 'd-none'}>{this.props.projectCount}{django.gettext(' search results')}</div>
            <div className="switch-filter__btn-group">
              {this.props.displayButtons && this.props.statusSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickStatusButton.bind(this)}
                  type="button"
                >{this.props.statusString} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.participationSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickParticipationButton.bind(this)}
                  type="button"
                >{this.props.participationString} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.organisationSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickOrganisationButton.bind(this)}
                  type="button"
                >{this.props.organisationString} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.titleSearchSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickTitleSearchButton.bind(this)}
                  type="button"
                >{this.titleSearchButtonString()} <i className="fa fa-times" />
                </button>}
            </div>
            <div className="switch-btn-group-container">
              <div className="btn-group switch-btn-group" role="group">
                <label
                  className={!this.props.displayMap ? 'btn btn--light switch--btn active' : 'btn btn--light switch--btn'}
                  onClick={this.props.showList} // eslint-disable-line react/jsx-handler-names
                  htmlFor="show_list"
                >
                  <span className="sr-only">{django.gettext('Show List')}</span>
                  <input className="radio__input" type="radio" value="list" id="show_list" /> <i className="fa fa-list" />
                </label>
                <label
                  className={this.props.displayMap ? 'btn btn--light switch--btn active' : 'btn btn--light switch--btn'}
                  onClick={this.props.showMap} // eslint-disable-line react/jsx-handler-names
                  htmlFor="show_map"
                >
                  <span className="sr-only">{django.gettext('Show Map')}</span>
                  <input className="radio__input" type="radio" value="map" id="show_map" /> <i className="fa fa-map" />
                </label>
              </div>
            </div>
          </div>
        </div>
      )
    }
  }
}

module.exports = Toggles<commit_msg>assets/Toggels: make mobile screen labels into switches to stop linting error, attempt to make desktop v a11y compliant<commit_after>/* global django */
const React = require('react')

class Toggles extends React.Component {
  clickStatusButton () {
    this.props.changeStatusSelection(-1)
  }

  clickParticipationButton () {
    this.props.changeParticipationSelection(-1)
  }

  clickOrganisationButton () {
    this.props.changeOrganisationSelection('-1')
  }

  clickTitleSearchButton () {
    this.props.changeTitleSearchSelection('-1')
  }

  titleSearchButtonString () {
    if (this.props.titleSearchString.length > 20) {
      return this.props.titleSearchString.substr(0, 20) + '...'
    }
    return this.props.titleSearchString
  }

  organisationButtonString () {
    if (this.props.organisationString.length > 20) {
      return this.props.organisationString.substr(0, 20) + '...'
    }
    return this.props.organisationString
  }

  render () {
    if (this.props.isSlider) {
      return (
        <div>
          <div className="l-frame switch-container">
            <div className={this.props.displayButtons ? 'switch-filter__label' : 'd-none'}>{this.props.projectCount}{django.gettext(' search results')}</div>
            <div className="switch-filter__btn-group">
              {this.props.displayButtons && this.props.statusSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickStatusButton.bind(this)}
                  type="button"
                >{this.props.statusString} {this.props.statusCount} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.participationSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickParticipationButton.bind(this)}
                  type="button"
                >{this.props.participationString} {this.props.participationCount} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.organisationSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickOrganisationButton.bind(this)}
                  type="button"
                >{this.organisationButtonString()} {this.props.organisationCount} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.titleSearchSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickTitleSearchButton.bind(this)}
                  type="button"
                >{this.titleSearchButtonString()} {this.props.titleSearchCount} <i className="fa fa-times" />
                </button>}
            </div>
            <div className="switch">
              <div className="switch-group" role="group" aria-labelledby="switch-primary">
                <label htmlFor="switch-primary" className="switch-label">
                  <span className="switch-label__text">{django.gettext('Show map')}</span>
                  <input
                    className="switch-input"
                    id="switch-primary"
                    onChange={this.props.toggleSwitch} /* eslint-disable-line react/jsx-handler-names */
                    name="switch-primary"
                    type="checkbox"
                    aria-label={django.gettext('show map')}
                  />
                  <span className="switch__toggle" />
                </label>
              </div>
            </div>
          </div>
        </div>
      )
    } else {
      return (
        <div>
          <div className="l-frame switch-container">
            <div className={this.props.displayButtons ? 'switch-filter__label' : 'd-none'}>{this.props.projectCount}{django.gettext(' search results')}</div>
            <div className="switch-filter__btn-group">
              {this.props.displayButtons && this.props.statusSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickStatusButton.bind(this)}
                  type="button"
                >{this.props.statusString} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.participationSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickParticipationButton.bind(this)}
                  type="button"
                >{this.props.participationString} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.organisationSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickOrganisationButton.bind(this)}
                  type="button"
                >{this.props.organisationString} <i className="fa fa-times" />
                </button>}
              {this.props.displayButtons && this.props.titleSearchSelected &&
                <button
                  className="btn btn--transparent btn--small"
                  onClick={this.clickTitleSearchButton.bind(this)}
                  type="button"
                >{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 switch--btn'}
                  onClick={this.props.showList} // eslint-disable-line react/jsx-handler-names
                  htmlFor="show_list"
                >
                  <span className="sr-only">{django.gettext('Show List')}</span>
                  <input className="radio__input" type="radio" value="list" id="show_list" aria-label={django.gettext('show list')} /> <i className="fa fa-list" />
                </switch>
                <switch
                  className={this.props.displayMap ? 'btn btn--light switch--btn active' : 'btn btn--light switch--btn'}
                  onClick={this.props.showMap} // eslint-disable-line react/jsx-handler-names
                  htmlFor="show_map"
                >
                  <span className="sr-only">{django.gettext('Show Map')}</span>
                  <input className="radio__input" type="radio" value="map" id="show_map" aria-label={django.gettext('show map')} /> <i className="fa fa-map" />
                </switch>
              </div>
            </div>
          </div>
        </div>
      )
    }
  }
}

module.exports = Toggles
{'fraction_non_alphanumeric': 0.1305793674253621, 'fraction_numerical': 0.0022169671888856044, 'mean_word_length': 1.7754306808859721, 'pattern_counts': {'":': 0, '<': 135, '<?xml version=': 0, '>': 139, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3506735', 'n_tokens_mistral': 3595, 'n_tokens_neox': 3434, 'n_words': 552}