From c5500a38a8534ea9b323398fc552f9e5b39c32ea Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 16 Jun 2023 17:16:24 -0700 Subject: [PATCH] Fix styles for combobox input --- components/FilterBar/index.tsx | 3 +- .../common/CharLimitedFieldset/index.scss | 46 ------- components/raids/RaidCombobox/index.scss | 126 +++++++++--------- components/raids/RaidCombobox/index.tsx | 57 +++++++- styles/globals.scss | 47 +++++++ 5 files changed, 166 insertions(+), 113 deletions(-) diff --git a/components/FilterBar/index.tsx b/components/FilterBar/index.tsx index d7c3d2fc..5d94deb9 100644 --- a/components/FilterBar/index.tsx +++ b/components/FilterBar/index.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useState } from 'react' +import React, { useEffect, useState } from 'react' import { useTranslation } from 'next-i18next' import classNames from 'classnames' import equals from 'fast-deep-equal' @@ -140,7 +140,6 @@ const FilterBar = (props: Props) => { span { overflow: hidden; diff --git a/components/raids/RaidCombobox/index.tsx b/components/raids/RaidCombobox/index.tsx index 0378d9f2..86b73e42 100644 --- a/components/raids/RaidCombobox/index.tsx +++ b/components/raids/RaidCombobox/index.tsx @@ -36,6 +36,34 @@ enum Sort { DESCENDING, } +// Set up empty raid for "All raids" +const untitledGroup: RaidGroup = { + id: '0', + name: { + en: '', + ja: '', + }, + section: 0, + order: 0, + extra: false, + raids: [], + difficulty: 0, + hl: false, +} + +// Set up empty raid for "All raids" +const allRaidsOption: Raid = { + id: '0', + name: { + en: 'All battles', + ja: '全てのバトル', + }, + group: untitledGroup, + slug: 'all', + level: 0, + element: 0, +} + const RaidCombobox = (props: Props) => { // Set up router for locale const router = useRouter() @@ -75,12 +103,15 @@ const RaidCombobox = (props: Props) => { if (appState.party.raid) { setCurrentRaid(appState.party.raid) setCurrentSection(appState.party.raid.group.section) + } else if (props.showAllRaidsOption && !currentRaid) { + setCurrentRaid(allRaidsOption) } }, []) // Set current raid and section when the current raid changes useEffect(() => { if (props.currentRaid) { + console.log('We are here with a raid') setCurrentRaid(props.currentRaid) setCurrentSection(props.currentRaid.group.section) } @@ -224,7 +255,9 @@ const RaidCombobox = (props: Props) => { // Toggle the open state of the combobox function toggleOpen() { if (open) { - if (currentRaid) setCurrentSection(currentRaid.group.section) + if (currentRaid && currentRaid.slug !== 'all') { + setCurrentSection(currentRaid.group.section) + } setScrolled(false) } setOpen(!open) @@ -287,6 +320,26 @@ const RaidCombobox = (props: Props) => { ) } + // Render the ungrouped raid group + function renderUngroupedRaids() { + // Render the Untitled group with the allRaids inside of it first if the option is enabled + if (props.showAllRaidsOption) { + const ungroupedRaids = generateRaidItems([allRaidsOption]) + + return ( + + {ungroupedRaids} + + ) + } + } + // Generates a list of RaidItem components from the specified raids function generateRaidItems(raids: Raid[]) { return raids @@ -361,7 +414,6 @@ const RaidCombobox = (props: Props) => { } // Renders a Button for sorting raids and a Tooltip for explaining what it does. - function renderSortButton() { return ( { tabIndex={6} onKeyDown={handleListKeyDown} > + {renderUngroupedRaids()} {renderRaidSections()} diff --git a/styles/globals.scss b/styles/globals.scss index a06cb236..ec53412d 100644 --- a/styles/globals.scss +++ b/styles/globals.scss @@ -306,3 +306,50 @@ i.tag { grid-template-columns: 1fr 1fr; } } + +.Joined { + $offset: 2px; + + align-items: center; + background: var(--input-bg); + border-radius: $input-corner; + border: $offset solid transparent; + box-sizing: border-box; + display: flex; + gap: $unit; + padding-top: 2px; + padding-bottom: 2px; + padding-right: calc($unit-2x - $offset); + + &.Bound { + background-color: var(--input-bound-bg); + + &:hover { + background-color: var(--input-bound-bg-hover); + } + } + + &:focus-within { + border: $offset solid $blue; + // box-shadow: 0 2px rgba(255, 255, 255, 1); + } + + .Counter { + color: $grey-55; + font-weight: $bold; + line-height: 42px; + } + + .Input { + background: transparent; + border: none; + border-radius: 0; + padding: $unit * 1.5 $unit-2x; + padding-left: calc($unit-2x - $offset); + + &:focus { + border: none; + outline: none; + } + } +}