Skip to content

Commit

Permalink
products filter modified.
Browse files Browse the repository at this point in the history
  • Loading branch information
knightfury16 committed Nov 23, 2022
1 parent f8ea1a3 commit 1430bbc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 44 deletions.
2 changes: 1 addition & 1 deletion components/products-content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ProductsContent = () => {
return (
<section className="products-content">
<div className="products-content__intro">
<h2>Men's Tops <span>(133)</span></h2>
<h2>Top Products</h2>
<button type="button" onClick={() => setOrderProductsOpen(!orderProductsOpen)} className="products-filter-btn"><i className="icon-filters"></i></button>
<form className={`products-content__filter ${orderProductsOpen ? 'products-order-open' : ''}`}>
<div className="products__filter__select">
Expand Down
72 changes: 29 additions & 43 deletions components/products-filter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { useState } from 'react';
import Checkbox from './form-builder/checkbox';
import CheckboxColor from './form-builder/checkbox-color';
import Slider from 'rc-slider';

// data
import productsTypes from './../../utils/data/products-types';
import productsColors from './../../utils/data/products-colors';
import productsSizes from './../../utils/data/products-sizes';
import {category} from './../../utils/constants'

const { createSliderWithTooltip } = Slider;
const Range = createSliderWithTooltip(Slider.Range);
Expand All @@ -16,26 +13,30 @@ const ProductsFilter = () => {

const addQueryParams = () => {
// query params changes
}
};

return (
<form className="products-filter" onChange={addQueryParams}>
<button type="button"
onClick={() => setFiltersOpen(!filtersOpen)}
className={`products-filter__menu-btn ${filtersOpen ? 'products-filter__menu-btn--active' : ''}`}>
Add Filter <i className="icon-down-open"></i>
<button
type="button"
onClick={() => setFiltersOpen(!filtersOpen)}
className={`products-filter__menu-btn ${
filtersOpen ? 'products-filter__menu-btn--active' : ''
}`}
>
Add Filter <i className="icon-down-open"></i>
</button>

<div className={`products-filter__wrapper ${filtersOpen ? 'products-filter__wrapper--open' : ''}`}>

<div
className={`products-filter__wrapper ${
filtersOpen ? 'products-filter__wrapper--open' : ''
}`}
>
<div className="products-filter__block">
<button type="button">Product type</button>
<div className="products-filter__block__content">
{productsTypes.map(type => (
<Checkbox
key={type.id}
name="product-type"
label={type.name}
/>
{category.map(type => (
<Checkbox key={type} name="product-type" label={type} />
))}
</div>
</div>
Expand All @@ -46,36 +47,21 @@ const ProductsFilter = () => {
<Range min={0} max={20} defaultValue={[3, 10]} tipFormatter={value => `${value}%`} />
</div>
</div>

<div className="products-filter__block">
<button type="button">Size</button>
<div className="products-filter__block__content checkbox-square-wrapper">
{productsSizes.map(type => (
<Checkbox
type="square"
key={type.id}
name="product-size"
label={type.label} />
))}
<button type="button">Rating</button>
<div className="products-filter__block__content">
<Range min={1} max={5} defaultValue={[5]} tipFormatter={value => `${value}`} />
</div>
</div>

<div className="products-filter__block">
<button type="button">Color</button>
<div className="products-filter__block__content">
<div className="checkbox-color-wrapper">
{productsColors.map(type => (
<CheckboxColor key={type.id} valueName={type.color} name="product-color" color={type.color} />
))}
</div>
</div>
<button type="submit" className="btn btn-submit btn--rounded btn--yellow">
Apply
</button>
</div>

<button type="submit" className="btn btn-submit btn--rounded btn--yellow">Apply</button>
</div>
</form>
)
}

export default ProductsFilter

);
};

export default ProductsFilter;
5 changes: 5 additions & 0 deletions utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const category = [
'Accessories',
'Outdoors',
'Home'
];

0 comments on commit 1430bbc

Please sign in to comment.