|
|
@ -1,34 +1,55 @@ |
|
|
|
import React from 'react'; |
|
|
|
import React from "react"; |
|
|
|
import FormControlLabel from '@material-ui/core/FormControlLabel'; |
|
|
|
import FormControlLabel from "@material-ui/core/FormControlLabel"; |
|
|
|
import Checkbox from '@material-ui/core/Checkbox'; |
|
|
|
import Checkbox from "@material-ui/core/Checkbox"; |
|
|
|
|
|
|
|
|
|
|
|
import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank'; |
|
|
|
import CheckBoxOutlineBlankIcon from "@material-ui/icons/CheckBoxOutlineBlank"; |
|
|
|
import CheckBoxIcon from '@material-ui/icons/CheckBox'; |
|
|
|
import CheckBoxIcon from "@material-ui/icons/CheckBox"; |
|
|
|
import CloseIcon from '@material-ui/icons/Close'; |
|
|
|
import CloseIcon from "@material-ui/icons/Close"; |
|
|
|
|
|
|
|
|
|
|
|
import './index.scss'; |
|
|
|
import "./index.scss"; |
|
|
|
|
|
|
|
|
|
|
|
const maxDesktopSize = 1250; |
|
|
|
const maxDesktopSize = 1250; |
|
|
|
|
|
|
|
|
|
|
|
const fontSize = { |
|
|
|
const fontSize = { |
|
|
|
h2 : window.innerWidth > maxDesktopSize ? 13 : window.innerWidth / 85, |
|
|
|
h2: window.innerWidth > maxDesktopSize ? 13 : window.innerWidth / 85, |
|
|
|
strong: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 90, |
|
|
|
strong: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 90, |
|
|
|
} |
|
|
|
}; |
|
|
|
export default class TypicalFilters extends React.Component { |
|
|
|
export default class TypicalFilters extends React.Component { |
|
|
|
|
|
|
|
onChange = (name, data) => { |
|
|
|
|
|
|
|
if (name === "subject") { |
|
|
|
|
|
|
|
this.props.parent.setState((prevState) => ({ |
|
|
|
|
|
|
|
selectedFilters: { |
|
|
|
|
|
|
|
...prevState.selectedFilters, |
|
|
|
|
|
|
|
subject: |
|
|
|
|
|
|
|
prevState.selectedFilters.subject.indexOf(data) !== -1 |
|
|
|
|
|
|
|
? prevState.selectedFilters.subject.filter(item => item !== data) |
|
|
|
|
|
|
|
: [...new Set([...prevState.selectedFilters.subject, data])], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
}else if(name === "level"){ |
|
|
|
|
|
|
|
this.props.parent.setState((prevState) => ({ |
|
|
|
|
|
|
|
selectedFilters: { |
|
|
|
|
|
|
|
...prevState.selectedFilters, |
|
|
|
|
|
|
|
level: |
|
|
|
|
|
|
|
prevState.selectedFilters.level.indexOf(data) !== -1 |
|
|
|
|
|
|
|
? prevState.selectedFilters.level.filter(item => item !== data) |
|
|
|
|
|
|
|
: [...new Set([...prevState.selectedFilters.level, data])], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
render() { |
|
|
|
render() { |
|
|
|
const {data, title, theme} = this.props; |
|
|
|
const { data, title, theme, name, parent } = this.props; |
|
|
|
return( |
|
|
|
return ( |
|
|
|
<div className="products-filters-typical d-flex flex-column"> |
|
|
|
<div className="products-filters-typical d-flex flex-column"> |
|
|
|
<header className="products-filters-typical__header d-flex align-items-center"> |
|
|
|
<header className="products-filters-typical__header d-flex align-items-center"> |
|
|
|
<span style={{ background : theme }}></span> |
|
|
|
<span style={{ background: theme }}></span> |
|
|
|
<h2 style={{ fontSize : fontSize.h2 }}>{title}</h2> |
|
|
|
<h2 style={{ fontSize: fontSize.h2 }}>{title}</h2> |
|
|
|
</header> |
|
|
|
</header> |
|
|
|
<div className="products-filters-typical__items d-flex flex-column"> |
|
|
|
<div className="products-filters-typical__items d-flex flex-column"> |
|
|
|
{ |
|
|
|
{data.map((item, i) => ( |
|
|
|
data.map((item,i) => ( |
|
|
|
<Item data={item} key={i} parent={this} /> |
|
|
|
<Item data={item} key={i} /> |
|
|
|
))} |
|
|
|
)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
@ -36,14 +57,30 @@ export default class TypicalFilters extends React.Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const Item = (props) => { |
|
|
|
const Item = (props) => { |
|
|
|
const {data} = props; |
|
|
|
const { data, parent } = props; |
|
|
|
return( |
|
|
|
const checkHandler = (data, name) => { |
|
|
|
|
|
|
|
var available; |
|
|
|
|
|
|
|
if(name === "subject"){ |
|
|
|
|
|
|
|
available = props.parent.props.parent.state.selectedFilters.subject.indexOf(data) !== -1 ? true : false; |
|
|
|
|
|
|
|
}else if(name === "level"){ |
|
|
|
|
|
|
|
available = props.parent.props.parent.state.selectedFilters.level.indexOf(data) !== -1 ? true : false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return available; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
<div className="d-flex align-items-center mt-2"> |
|
|
|
<div className="d-flex align-items-center mt-2"> |
|
|
|
<FormControlLabel |
|
|
|
<FormControlLabel |
|
|
|
control={<Checkbox icon={<CheckBoxOutlineBlankIcon style={{ color: '#EAEAEA' }} />} checkedIcon={<CheckBoxIcon style={{ color: '#00CC69' }} />} name="checkedH" />} |
|
|
|
control={ |
|
|
|
label="" |
|
|
|
<Checkbox |
|
|
|
|
|
|
|
icon={<CheckBoxOutlineBlankIcon style={{ color: "#EAEAEA" }} />} |
|
|
|
|
|
|
|
checkedIcon={<CheckBoxIcon style={{ color: "#00CC69" }} />} |
|
|
|
|
|
|
|
name="checkedH" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
checked={checkHandler(data,parent.props.name)} |
|
|
|
|
|
|
|
onChange={() => parent.onChange(parent.props.name, data)} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<strong style={{ fontSize: fontSize.strong }}>{data}</strong> |
|
|
|
<strong style={{ fontSize: fontSize.strong }}>{data}</strong> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
}; |
|
|
|