From a40b20123a78f3d565a47ed9266c16da3b979bdb Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Thu, 22 Feb 2024 23:19:38 -0500
Subject: [PATCH] feat: pkmn filter diagram
---
jsconfig.json | 31 +--
packages/locales/lib/human/en.json | 11 +-
src/components/layout/Nav.jsx | 2 +
.../layout/dialogs/filters/PkmnFilterHelp.jsx | 195 ++++++++++++++++++
src/components/layout/drawer/BoolToggle.jsx | 4 +-
src/components/layout/drawer/Pokemon.jsx | 9 +
src/components/layout/general/Icons.jsx | 2 +-
src/hooks/useLayoutStore.js | 3 +
8 files changed, 233 insertions(+), 24 deletions(-)
create mode 100644 src/components/layout/dialogs/filters/PkmnFilterHelp.jsx
diff --git a/jsconfig.json b/jsconfig.json
index 88e79d180..eee01f5e6 100644
--- a/jsconfig.json
+++ b/jsconfig.json
@@ -1,29 +1,20 @@
{
"compilerOptions": {
"target": "ESNext",
- "module": "CommonJS",
+ "module": "ESNext",
+ "moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
+ "allowSyntheticDefaultImports": true,
"baseUrl": ".",
- "jsx": "react",
+ "lib": ["ESNext", "dom"],
+ "jsx": "react-jsx",
"paths": {
- "@assets/*": [
- "./src/assets/*"
- ],
- "@components/*": [
- "./src/components/*"
- ],
- "@services/*": [
- "./src/services/*"
- ],
- "@hooks/*": [
- "./src/hooks/*"
- ],
+ "@assets/*": ["./src/assets/*"],
+ "@components/*": ["./src/components/*"],
+ "@services/*": ["./src/services/*"],
+ "@hooks/*": ["./src/hooks/*"]
}
},
- "exclude": [
- "node_modules",
- "**/node_modules/*",
- "dist"
- ]
-}
\ No newline at end of file
+ "exclude": ["node_modules", "**/node_modules/*", "dist"]
+}
diff --git a/packages/locales/lib/human/en.json b/packages/locales/lib/human/en.json
index 546538aa4..01b3a9f39 100644
--- a/packages/locales/lib/human/en.json
+++ b/packages/locales/lib/human/en.json
@@ -725,5 +725,14 @@
"extra": "Extra",
"select": "Select",
"searching": "searching...",
- "no_options": "No Options..."
+ "no_options": "No Options...",
+ "and": "AND",
+ "or": "OR",
+ "only_global": "Only Global",
+ "global_caption": "Ignores All Other Filters",
+ "global_and_individual": "Global & Individual Filters",
+ "gender_filters_all": "Gender Applies to All",
+ "and_caption": "Linked Together",
+ "or_caption": "Filters Independently",
+ "filter_help": "Filter Help"
}
diff --git a/src/components/layout/Nav.jsx b/src/components/layout/Nav.jsx
index 77498c276..6b2b740fc 100644
--- a/src/components/layout/Nav.jsx
+++ b/src/components/layout/Nav.jsx
@@ -22,6 +22,7 @@ import BadgeSelection from './dialogs/BadgeSelection'
import WebhookAdvanced from './dialogs/webhooks/WebhookAdv'
import SlotSelection from './dialogs/filters/SlotSelection'
import { HelpDialog } from './dialogs/Help'
+import { PkmnFilterHelp } from './dialogs/filters/PkmnFilterHelp'
export const Nav = React.memo(
() => {
@@ -50,6 +51,7 @@ export const Nav = React.memo(
+
>
)}
>
diff --git a/src/components/layout/dialogs/filters/PkmnFilterHelp.jsx b/src/components/layout/dialogs/filters/PkmnFilterHelp.jsx
new file mode 100644
index 000000000..acb56ec9b
--- /dev/null
+++ b/src/components/layout/dialogs/filters/PkmnFilterHelp.jsx
@@ -0,0 +1,195 @@
+// @ts-check
+import * as React from 'react'
+import DialogContent from '@mui/material/DialogContent'
+import Box from '@mui/material/Box'
+import Typography from '@mui/material/Typography'
+import Grid2 from '@mui/material/Unstable_Grid2'
+import { useTranslation } from 'react-i18next'
+import { Chip, Divider, useMediaQuery } from '@mui/material'
+
+import Header from '@components/layout/general/Header'
+import Footer from '@components/layout/general/Footer'
+import { useMemory } from '@hooks/useMemory'
+import { useLayoutStore } from '@hooks/useLayoutStore'
+
+import { DialogWrapper } from '../DialogWrapper'
+
+const GAP = 2
+
+/** @type {(theme: import('@mui/material').Theme) => import('@mui/system').SystemStyleObject} */
+const SX_PROPS = (theme) => ({
+ borderColor: theme.palette.grey[theme.palette.mode === 'dark' ? 600 : 300],
+ border: '3px solid',
+ borderRadius: 4,
+})
+
+const SUB_SX_PROPS = /** @type {typeof SX_PROPS} */ (
+ (theme) => ({
+ borderColor: theme.palette.grey[theme.palette.mode === 'dark' ? 600 : 300],
+ borderBottom: '3px solid',
+ p: 0.5,
+ })
+)
+
+const AND_ITEMS = [
+ 'iv',
+ 'level',
+ 'cp',
+ 'slider_atk_iv',
+ 'slider_def_iv',
+ 'slider_sta_iv',
+]
+
+const OR_ITEMS = [
+ 'slider_little',
+ 'slider_great',
+ 'slider_ultra',
+ 'size_1',
+ 'size_5',
+]
+
+/** @param {{ children: string } & import('@mui/material').TypographyProps} props */
+function ChildText({ children, ...props }) {
+ const { t } = useTranslation()
+ return (
+
+ {t(children)}
+
+ )
+}
+
+/** @param {{ title: string, children: React.ReactNode, bgcolor: import('@mui/material').BoxProps['bgcolor'], fullSize?: boolean }} props */
+function Card({ title, children, bgcolor, fullSize }) {
+ const { t, i18n } = useTranslation()
+ return (
+
+
+
+ {t(title)}
+
+ {i18n.exists(`${title}_caption`) && (
+
+ {t(`${title}_caption`)}
+
+ )}
+
+ {children}
+
+ )
+}
+
+const handleClose = () => useLayoutStore.setState({ pkmnFilterHelp: false })
+
+const OPTIONS =
+ /** @type {import('@components/layout/general/Footer').FooterButton[]} */ ([
+ { name: 'close', color: 'error', action: handleClose },
+ ])
+
+export function PkmnFilterHelp() {
+ const { t } = useTranslation()
+ const perms = useMemory((s) => s.auth.perms)
+ const isMobile = useMediaQuery(
+ (/** @type {import('@mui/material').Theme} */ theme) =>
+ theme.breakpoints.down('md'),
+ )
+
+ if (!perms.pokemon) return null
+ return (
+
+
+
+
+
+
+ {t('global_and_individual')}
+
+
+
+
+
+ {AND_ITEMS.map((child) => (
+
+ {child}
+
+ ))}
+
+
+
+ {OR_ITEMS.map((child) => (
+
+ {child}
+
+ ))}
+
+
+
+
+ {!isMobile && (
+
+ )}
+
+
+ {t('only_global')}
+
+
+ {t('global_caption')}
+
+
+
+
+
+
+
+
+
+ )
+}
diff --git a/src/components/layout/drawer/BoolToggle.jsx b/src/components/layout/drawer/BoolToggle.jsx
index dac4d14cd..c43e0d614 100644
--- a/src/components/layout/drawer/BoolToggle.jsx
+++ b/src/components/layout/drawer/BoolToggle.jsx
@@ -68,7 +68,7 @@ export function BoolBase({
export const BoolToggle = React.memo(BoolBase)
-/** @param {{ items: readonly [string, string], secondColor?: BoolToggleProps['switchColor'] } & BoolToggleProps} props */
+/** @param {{ items: readonly [string, string], secondColor?: BoolToggleProps['switchColor'], label?: `${string}-${string}` } & Omit} props */
export function DualBoolToggle({
items,
switchColor,
@@ -77,7 +77,7 @@ export function DualBoolToggle({
label,
...props
}) {
- const labels = label?.split('-') || []
+ const labels = label?.split('-', 2) || []
return (
{items.map((item, i) => (
diff --git a/src/components/layout/drawer/Pokemon.jsx b/src/components/layout/drawer/Pokemon.jsx
index 1d21716d2..7a34530a2 100644
--- a/src/components/layout/drawer/Pokemon.jsx
+++ b/src/components/layout/drawer/Pokemon.jsx
@@ -17,11 +17,13 @@ import {
InputLabel,
} from '@mui/material'
import { useTranslation } from 'react-i18next'
+import Help from '@mui/icons-material/HelpOutline'
import { useMemory } from '@hooks/useMemory'
import { useStorage, useDeepStore } from '@hooks/useStorage'
import Utility from '@services/Utility'
import { XXS_XXL, NUNDO_HUNDO } from '@assets/constants'
+import { useLayoutStore } from '@hooks/useLayoutStore'
import { StringFilterMemo } from '../dialogs/filters/StringFilter'
import SliderTile from '../dialogs/filters/SliderTile'
@@ -29,6 +31,7 @@ import TabPanel from '../general/TabPanel'
import { BoolToggle, DualBoolToggle } from './BoolToggle'
import { GenderListItem } from '../dialogs/filters/Gender'
import { SelectorListMemo } from './SelectorList'
+import { BasicListButton } from '../general/BasicListButton'
function PokemonDrawer() {
const legacyFilter = useStorage((s) => s.userSettings.pokemon.legacyFilter)
@@ -167,6 +170,12 @@ function PokemonDrawer() {
>
)}
+ useLayoutStore.setState({ pkmnFilterHelp: true })}
+ >
+
+
>
)
}
diff --git a/src/components/layout/general/Icons.jsx b/src/components/layout/general/Icons.jsx
index b96ee2be8..4dd4dda00 100644
--- a/src/components/layout/general/Icons.jsx
+++ b/src/components/layout/general/Icons.jsx
@@ -3,7 +3,7 @@ import Save from '@mui/icons-material/Save'
import Add from '@mui/icons-material/Add'
import People from '@mui/icons-material/People'
import BugReport from '@mui/icons-material/BugReport'
-import Help from '@mui/icons-material/Help'
+import Help from '@mui/icons-material/HelpOutline'
import Ballot from '@mui/icons-material/Ballot'
import Tune from '@mui/icons-material/Tune'
import FormatSize from '@mui/icons-material/FormatSize'
diff --git a/src/hooks/useLayoutStore.js b/src/hooks/useLayoutStore.js
index 4bfcf80bb..8188197c7 100644
--- a/src/hooks/useLayoutStore.js
+++ b/src/hooks/useLayoutStore.js
@@ -1,3 +1,4 @@
+// @ts-check
import { create } from 'zustand'
import Utility from '@services/Utility'
@@ -13,6 +14,7 @@ import { useStorage } from './useStorage'
* motd: boolean,
* donorPage: boolean,
* search: boolean,
+ * pkmnFilterHelp: boolean,
* userProfile: boolean,
* resetFilters: boolean,
* feedback: boolean,
@@ -42,6 +44,7 @@ export const useLayoutStore = create(() => ({
nestSubmissions: '0',
help: { open: false, category: '' },
motd: false,
+ pkmnFilterHelp: false,
donorPage: false,
search: false,
userProfile: false,