|
|
|
@ -1,11 +1,17 @@ |
|
|
|
|
import React, { useState, useEffect, useRef } from "react"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
import { book } from "../../redux/actions"; |
|
|
|
|
import _ from 'lodash'; |
|
|
|
|
import _ from "lodash"; |
|
|
|
|
import dropdown from "../../assets/icons/dropdown.png"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function GradeFilter({selectedGrade, gradeFilter, grades, gradeDropdown, setGradeDropdown, theme}: any) { |
|
|
|
|
function GradeFilter({ |
|
|
|
|
selectedGrade, |
|
|
|
|
gradeFilter, |
|
|
|
|
grades, |
|
|
|
|
gradeDropdown, |
|
|
|
|
setGradeDropdown, |
|
|
|
|
theme, |
|
|
|
|
}: any) { |
|
|
|
|
const [arrowTop, setArrowTop] = useState(false); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
@ -17,10 +23,18 @@ function GradeFilter({selectedGrade, gradeFilter, grades, gradeDropdown, setGrad |
|
|
|
|
const setDropdown = (e: any) => { |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
setGradeDropdown(!gradeDropdown); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<section className={_.join(["grade-filter d-flex align-items-center", theme === 'light' ? 'grade-filter__light' : 'grade-filter__dark']," ")}> |
|
|
|
|
<section |
|
|
|
|
className={_.join( |
|
|
|
|
[ |
|
|
|
|
"grade-filter d-flex align-items-center", |
|
|
|
|
theme === "light" ? "grade-filter-light" : "grade-filter-dark", |
|
|
|
|
], |
|
|
|
|
" " |
|
|
|
|
)} |
|
|
|
|
> |
|
|
|
|
<h1 className="d-flex align-items-center"> |
|
|
|
|
پایه تحصیلی |
|
|
|
|
<span className="desktop"></span> |
|
|
|
@ -45,10 +59,10 @@ function GradeFilter({selectedGrade, gradeFilter, grades, gradeDropdown, setGrad |
|
|
|
|
{grades.map((item: any, i: any) => ( |
|
|
|
|
<li |
|
|
|
|
key={i} |
|
|
|
|
onClick={() => |
|
|
|
|
gradeFilter(item.value) |
|
|
|
|
onClick={() => gradeFilter(item.value)} |
|
|
|
|
className={ |
|
|
|
|
selectedGrade === item.value ? "grade-filter__list--active" : "" |
|
|
|
|
} |
|
|
|
|
className={selectedGrade === item.value ? "grade-filter__list--active" : ""} |
|
|
|
|
> |
|
|
|
|
{item.name} |
|
|
|
|
</li> |
|
|
|
@ -57,7 +71,15 @@ function GradeFilter({selectedGrade, gradeFilter, grades, gradeDropdown, setGrad |
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
|
<ul className="desktop align-items-center" ref={mobileList}> |
|
|
|
|
{ selectedGrade && <figure style={{ right : (mobileList as any).current?.offsetWidth / 12 * (selectedGrade - 1) }}></figure> } |
|
|
|
|
{selectedGrade && ( |
|
|
|
|
<figure |
|
|
|
|
style={{ |
|
|
|
|
right: |
|
|
|
|
((mobileList as any).current?.offsetWidth / 12) * |
|
|
|
|
(selectedGrade - 1), |
|
|
|
|
}} |
|
|
|
|
></figure> |
|
|
|
|
)} |
|
|
|
|
{grades.map((item: any, i: any) => ( |
|
|
|
|
<li |
|
|
|
|
key={i} |
|
|
|
|