From d8d864a5fe8a7300b48a6f649682d7a1ff0fc5b7 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 6 Dec 2022 13:50:13 -0800 Subject: [PATCH] Implement new Select in FilterBar --- components/FilterBar/index.scss | 11 ++- components/FilterBar/index.tsx | 110 ++++++++++++++++++------------ components/RaidDropdown/index.tsx | 2 + components/Select/index.tsx | 6 +- 4 files changed, 82 insertions(+), 47 deletions(-) diff --git a/components/FilterBar/index.scss b/components/FilterBar/index.scss index 9098df3c..bf220493 100644 --- a/components/FilterBar/index.scss +++ b/components/FilterBar/index.scss @@ -25,7 +25,8 @@ text-align: left; } - select { + select, + .SelectTrigger { // background: url("/icons/Arrow.svg"), $grey-90; // background-repeat: no-repeat; // background-position-y: center; @@ -37,6 +38,14 @@ max-width: 200px; } + .SelectTrigger { + width: 100%; + + span { + font-size: $font-small; + } + } + .UserInfo { align-items: center; display: flex; diff --git a/components/FilterBar/index.tsx b/components/FilterBar/index.tsx index 82f8813c..d648af50 100644 --- a/components/FilterBar/index.tsx +++ b/components/FilterBar/index.tsx @@ -1,10 +1,12 @@ -import React from 'react' +import React, { useState } from 'react' import { useTranslation } from 'next-i18next' import classNames from 'classnames' import RaidDropdown from '~components/RaidDropdown' import './index.scss' +import Select from '~components/Select' +import SelectItem from '~components/SelectItem' interface Props { children: React.ReactNode @@ -27,6 +29,9 @@ const FilterBar = (props: Props) => { // Set up translation const { t } = useTranslation('common') + const [recencyOpen, setRecencyOpen] = useState(false) + const [elementOpen, setElementOpen] = useState(false) + // Set up refs for filter dropdowns const elementSelect = React.createRef() const raidSelect = React.createRef() @@ -38,17 +43,21 @@ const FilterBar = (props: Props) => { shadow: props.scrolled, }) - function elementSelectChanged() { - const elementValue = elementSelect.current - ? parseInt(elementSelect.current.value) - : -1 + function openElementSelect() { + setElementOpen(!elementOpen) + } + + function openRecencySelect() { + setRecencyOpen(!recencyOpen) + } + + function elementSelectChanged(value: string) { + const elementValue = parseInt(value) props.onFilter({ element: elementValue }) } - function recencySelectChanged() { - const recencyValue = recencySelect.current - ? parseInt(recencySelect.current.value) - : -1 + function recencySelectChanged(value: string) { + const recencyValue = parseInt(value) props.onFilter({ recency: recencyValue }) } @@ -59,65 +68,76 @@ const FilterBar = (props: Props) => { return (
{props.children} - + + + - + {t('recency.all_time')} - - + {t('recency.last_day')} - - + {t('recency.last_week')} - - + {t('recency.last_month')} - - + {t('recency.last_3_months')} - - + {t('recency.last_6_months')} - - + {t('recency.last_year')} - - + +
) } diff --git a/components/RaidDropdown/index.tsx b/components/RaidDropdown/index.tsx index 95a1b145..636caf0c 100644 --- a/components/RaidDropdown/index.tsx +++ b/components/RaidDropdown/index.tsx @@ -15,6 +15,7 @@ import './index.scss' interface Props { showAllRaidsOption: boolean currentRaid?: string + defaultRaid?: string onChange?: (slug?: string) => void onBlur?: (event: React.ChangeEvent) => void } @@ -129,6 +130,7 @@ const RaidDropdown = React.forwardRef( return (