From 775a83d147a930b0b2f0b8ba355444ebcd6275e9 Mon Sep 17 00:00:00 2001 From: mattyl006 Date: Tue, 12 Jul 2022 10:47:14 +0200 Subject: [PATCH] correct states in Challenges for filters --- src/components/elements/Filter.js | 28 +++++++++++++++---- .../elements/FiltersMenu/FiltersMenu.js | 20 +++++++------ src/components/sections/FilterBy.js | 12 ++++---- src/pages/Challenges.js | 25 ++++++++++++++++- 4 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/components/elements/Filter.js b/src/components/elements/Filter.js index 2f5696c..85d9b76 100644 --- a/src/components/elements/Filter.js +++ b/src/components/elements/Filter.js @@ -10,8 +10,15 @@ const FilterStyle = styled(FlexRow)` border: 1px solid ${({theme}) => theme.colors.dark}; box-shadow: ${({theme}) => theme.shadow}; cursor: pointer; - color: ${({theme, active}) => active ? theme.colors.white : theme.colors.dark}; - background-color: ${({theme, active}) => active ? theme.colors.darj : theme.colors.white}; + background-color: ${({theme, active}) => active ? theme.colors.dark : theme.colors.white}; + + p { + color: ${({theme, active}) => active ? theme.colors.white : theme.colors.dark}; + } + + span { + background-color: ${({theme, active}) => active ? theme.colors.white : theme.colors.dark}; + } * { cursor: pointer; @@ -19,10 +26,21 @@ const FilterStyle = styled(FlexRow)` `; const Filter = (props) => { + + const onCheckHandler = (e) => { + if (e.target.checked) + props.handler(Number(e.target.value)); + } + return ( - - {props.children} - + <> + + {props.children} + + onCheckHandler(e)}/> + ); } diff --git a/src/components/elements/FiltersMenu/FiltersMenu.js b/src/components/elements/FiltersMenu/FiltersMenu.js index 4c5d3a2..2680dc8 100644 --- a/src/components/elements/FiltersMenu/FiltersMenu.js +++ b/src/components/elements/FiltersMenu/FiltersMenu.js @@ -11,12 +11,10 @@ const FiltersMenuStyle = styled(FlexColumn)` top: 0; right: 0; overflow-y: scroll; - width: 240px; + width: 260px; height: 100vh; - justify-content: space-around; - @media (max-height: 626px) { - justify-content: flex-start; - } + max-height: 650px; + justify-content: flex-start; padding: 14px 16px 14px 24px; box-shadow: ${({theme}) => theme.filtersShadow}; background-color: ${({theme}) => theme.colors.white}; @@ -30,10 +28,14 @@ const FiltersMenu = (props) => { - - - - + + + +