Update modal skeleton

This commit is contained in:
Justin Edmund 2023-03-18 06:50:30 -07:00
parent 4b8e905630
commit e4eb90aff1
2 changed files with 41 additions and 32 deletions

View file

@ -1,6 +1,6 @@
.Dialog { .Dialog {
.Filter.DialogContent { .Dialog .Filter.DialogContent {
overflow: hidden; overflow: hidden;
.TableField .Right .SelectTrigger.Table { .TableField .Right .SelectTrigger.Table {
width: $unit-20x; width: $unit-20x;

View file

@ -22,6 +22,8 @@ import type { DialogProps } from '@radix-ui/react-dialog'
import CrossIcon from '~public/icons/Cross.svg' import CrossIcon from '~public/icons/Cross.svg'
import './index.scss' import './index.scss'
import SwitchTableField from '~components/SwitchTableField'
import InputTableField from '~components/InputTableField'
interface Props extends DialogProps {} interface Props extends DialogProps {}
defaultFilterSet: FilterSet defaultFilterSet: FilterSet
@ -48,10 +50,17 @@ const FilterModal = (props: Props) => {
// States // States
const [filters, setFilters] = useState<{ [key: string]: any }>() const [filters, setFilters] = useState<{ [key: string]: any }>()
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
const [chargeAttackOpen, setChargeAttackOpen] = useState(false)
const [fullAutoOpen, setFullAutoOpen] = useState(false) const [fullAuto, setFullAuto] = useState(false)
const [autoGuardOpen, setAutoGuardOpen] = useState(false) const [autoGuard, setAutoGuard] = useState(false)
const [filterSet, setFilterSet] = useState<FilterSet>({}) const [chargeAttack, setChargeAttack] = useState(false)
const [minCharacterCount, setMinCharacterCount] = useState(3)
const [minWeaponCount, setMinWeaponCount] = useState(5)
const [minSummonCount, setMinSummonCount] = useState(2)
const [maxButtonsCount, setMaxButtonsCount] = useState(0)
const [maxTurnsCount, setMaxTurnsCount] = useState(0)
// Filter states // Filter states
const [fullAuto, setFullAuto] = useState(props.defaultFilterSet.full_auto) const [fullAuto, setFullAuto] = useState(props.defaultFilterSet.full_auto)
@ -74,13 +83,13 @@ const FilterModal = (props: Props) => {
const [maxTurnsCount, setMaxTurnsCount] = useState( const [maxTurnsCount, setMaxTurnsCount] = useState(
props.defaultFilterSet.turn_count props.defaultFilterSet.turn_count
) )
const [userQuality, setUserQuality] = useState( const [userQuality, setUserQuality] = useState(false)
props.defaultFilterSet.user_quality props.defaultFilterSet.user_quality
) )
const [nameQuality, setNameQuality] = useState( const [nameQuality, setNameQuality] = useState(false)
props.defaultFilterSet.name_quality props.defaultFilterSet.name_quality
) )
const [originalOnly, setOriginalOnly] = useState( const [originalOnly, setOriginalOnly] = useState(false)
props.defaultFilterSet.original props.defaultFilterSet.original
) )
@ -262,11 +271,11 @@ const FilterModal = (props: Props) => {
// Selects // Selects
const fullAutoField = () => ( const fullAutoField = () => (
<SelectTableField <SwitchTableField
name="full_auto" name="full_auto"
label={t('modals.filters.labels.full_auto')} label={t('modals.filters.labels.full_auto')}
open={fullAutoOpen} open={fullAutoOpen}
value={`${fullAuto}`} value={fullAuto}
onOpenChange={() => openSelect('full_auto')} onOpenChange={() => openSelect('full_auto')}
onClose={() => setFullAutoOpen(false)} onClose={() => setFullAutoOpen(false)}
onChange={handleFullAutoValueChange} onChange={handleFullAutoValueChange}
@ -280,15 +289,15 @@ const FilterModal = (props: Props) => {
<SelectItem key="off" value="0"> <SelectItem key="off" value="0">
{t('modals.filters.options.off')} {t('modals.filters.options.off')}
</SelectItem> </SelectItem>
</SelectTableField> />
) )
const autoGuardField = () => ( const autoGuardField = () => (
<SelectTableField <SwitchTableField
name="auto_guard" name="auto_guard"
label={t('modals.filters.labels.auto_guard')} label={t('modals.filters.labels.auto_guard')}
open={autoGuardOpen} open={autoGuardOpen}
value={`${autoGuard}`} value={autoGuard}
onOpenChange={() => openSelect('auto_guard')} onOpenChange={() => openSelect('auto_guard')}
onClose={() => setAutoGuardOpen(false)} onClose={() => setAutoGuardOpen(false)}
onChange={handleAutoGuardValueChange} onChange={handleAutoGuardValueChange}
@ -302,15 +311,15 @@ const FilterModal = (props: Props) => {
<SelectItem key="off" value="0"> <SelectItem key="off" value="0">
{t('modals.filters.options.off')} {t('modals.filters.options.off')}
</SelectItem> </SelectItem>
</SelectTableField> />
) )
const chargeAttackField = () => ( const chargeAttackField = () => (
<SelectTableField <SwitchTableField
name="charge_attack" name="charge_attack"
label={t('modals.filters.labels.charge_attack')} label={t('modals.filters.labels.charge_attack')}
open={chargeAttackOpen} open={chargeAttackOpen}
value={`${chargeAttack}`} value={chargeAttack}
onOpenChange={() => openSelect('charge_attack')} onOpenChange={() => openSelect('charge_attack')}
onClose={() => setChargeAttackOpen(false)} onClose={() => setChargeAttackOpen(false)}
onChange={handleChargeAttackValueChange} onChange={handleChargeAttackValueChange}
@ -324,7 +333,7 @@ const FilterModal = (props: Props) => {
<SelectItem key="off" value="0"> <SelectItem key="off" value="0">
{t('modals.filters.options.off')} {t('modals.filters.options.off')}
</SelectItem> </SelectItem>
</SelectTableField> />
) )
// Switches // Switches
@ -382,7 +391,7 @@ const FilterModal = (props: Props) => {
<Dialog open={open} onOpenChange={openChange}> <Dialog open={open} onOpenChange={openChange}>
<DialogTrigger asChild>{props.children}</DialogTrigger> <DialogTrigger asChild>{props.children}</DialogTrigger>
<DialogContent <DialogContent
className="Search" className="Filter"
headerref={headerRef} headerref={headerRef}
footerref={footerRef} footerref={footerRef}
onEscapeKeyDown={onEscapeKeyDown} onEscapeKeyDown={onEscapeKeyDown}
@ -401,19 +410,19 @@ const FilterModal = (props: Props) => {
</DialogClose> </DialogClose>
</div> </div>
<form> <form>
<div className="Fields"></div> <div className="Fields">
{chargeAttackField()} {chargeAttackField()}
{fullAutoField()} {fullAutoField()}
{autoGuardField()} {autoGuardField()}
{maxButtonsField()} {maxButtonsField()}
{maxTurnsField()} {maxTurnsField()}
{minCharactersField()} {minCharactersField()}
{minSummonsField()} {minSummonsField()}
{minWeaponsField()} {minWeaponsField()}
{nameQualityField()} {nameQualityField()}
{userQualityField()} {userQualityField()}
{originalOnlyField()} {originalOnlyField()}
</div> </div>
<div className="DialogFooter" ref={footerRef}> <div className="DialogFooter" ref={footerRef}>
<div className="Buttons Spaced"> <div className="Buttons Spaced">
<Button <Button