Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
components: adds toggle filter component
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
/* | ||
* This file is part of React-SearchKit. | ||
* Copyright (C) 2020 CERN. | ||
* | ||
* React-SearchKit is free software; you can redistribute it and/or modify it | ||
* under the terms of the MIT License; see LICENSE file for more details. | ||
*/ | ||
|
||
import React, { Component } from 'react'; | ||
import { Checkbox } from 'semantic-ui-react'; | ||
import Overridable from 'react-overridable'; | ||
import _get from 'lodash/get'; | ||
import { Card } from 'semantic-ui-react'; | ||
|
||
|
||
class ToggleComponent extends Component{ | ||
constructor(props) { | ||
super(props); | ||
this.title = props.title; | ||
this.label = props.label; | ||
this.filterValue = props.filterValue; | ||
this.updateQueryFilters = props.updateQueryFilters; | ||
} | ||
|
||
onToggleClicked = () => { | ||
this.updateQueryFilters(this.filterValue); | ||
}; | ||
|
||
render() { | ||
return( | ||
<Overridable id={'ToggleComponent'}> | ||
<Card> | ||
<Card.Content> | ||
<Card.Header>{this.title}</Card.Header> | ||
</Card.Content> | ||
<Card.Content> | ||
<Checkbox | ||
toggle | ||
label={this.label} | ||
onClick={this.onToggleClicked} | ||
/> | ||
</Card.Content> | ||
</Card> | ||
</Overridable> | ||
) | ||
} | ||
} | ||
|
||
export default Overridable.component('ToggleComponent', ToggleComponent); |
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,22 @@ | ||
/* | ||
* This file is part of React-SearchKit. | ||
* Copyright (C) 2020 CERN. | ||
* | ||
* React-SearchKit is free software; you can redistribute it and/or modify it | ||
* under the terms of the MIT License; see LICENSE file for more details. | ||
*/ | ||
|
||
import { connect } from '../../store'; | ||
import { updateQueryFilters } from '../../state/actions'; | ||
import ToggleComponent from './ToggleElement'; | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
updateQueryFilters: filter => dispatch(updateQueryFilters(filter)), | ||
}); | ||
|
||
export const Toggle = connect( | ||
state => ({ | ||
userSelectionFilters: state.query.filters | ||
}), | ||
mapDispatchToProps, | ||
)(ToggleComponent); |
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