-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4df1a9
commit a40b201
Showing
8 changed files
with
233 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} | ||
"exclude": ["node_modules", "**/node_modules/*", "dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
195 changes: 195 additions & 0 deletions
195
src/components/layout/dialogs/filters/PkmnFilterHelp.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<import('@mui/material').Theme>} */ | ||
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 ( | ||
<Typography variant="h6" align="center" width="100%" {...props}> | ||
{t(children)} | ||
</Typography> | ||
) | ||
} | ||
|
||
/** @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 ( | ||
<Grid2 | ||
direction="column" | ||
sx={SX_PROPS} | ||
m={GAP} | ||
overflow="hidden" | ||
xs={12} | ||
sm={fullSize ? 12 : 6} | ||
> | ||
<Box width="100%" bgcolor={`${bgcolor}.main`} sx={SUB_SX_PROPS}> | ||
<Typography variant="h5" color="white" align="center"> | ||
{t(title)} | ||
</Typography> | ||
{i18n.exists(`${title}_caption`) && ( | ||
<Typography | ||
variant="caption" | ||
color="white" | ||
width="100%" | ||
textAlign="center" | ||
component="p" | ||
> | ||
{t(`${title}_caption`)} | ||
</Typography> | ||
)} | ||
</Box> | ||
<Box p={GAP / 2}>{children}</Box> | ||
</Grid2> | ||
) | ||
} | ||
|
||
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 ( | ||
<DialogWrapper dialog="pkmnFilterHelp" maxWidth="md"> | ||
<Header titles="Filter Help" action={handleClose} /> | ||
<DialogContent sx={{ p: 0, height: '100%', alignItems: 'center' }}> | ||
<Grid2 | ||
container | ||
alignItems="stretch" | ||
justifyContent="space-around" | ||
height="100%" | ||
p={GAP} | ||
columns={13} | ||
> | ||
<Grid2 xs={12} md={8} my={GAP / 2}> | ||
<Typography | ||
variant="h4" | ||
px={GAP} | ||
pt={GAP} | ||
pb={{ xs: 0, md: GAP + 0.5 }} | ||
> | ||
{t('global_and_individual')} | ||
</Typography> | ||
<Divider flexItem sx={{ my: 2, borderColor: 'darkgrey' }} /> | ||
<Card title="gender_filters_all" bgcolor="success" fullSize> | ||
<Grid2 container columns={16} justifyContent="center"> | ||
<Card title="and" bgcolor="primary"> | ||
{AND_ITEMS.map((child) => ( | ||
<ChildText | ||
key={child} | ||
color={perms.iv ? 'inherit' : 'GrayText'} | ||
> | ||
{child} | ||
</ChildText> | ||
))} | ||
</Card> | ||
<Card title="or" bgcolor="secondary"> | ||
<Box py={1} /> | ||
{OR_ITEMS.map((child) => ( | ||
<ChildText | ||
key={child} | ||
color={ | ||
(child.startsWith('slider') ? perms.pvp : perms.iv) | ||
? 'inherit' | ||
: 'GrayText' | ||
} | ||
> | ||
{child} | ||
</ChildText> | ||
))} | ||
</Card> | ||
</Grid2> | ||
</Card> | ||
</Grid2> | ||
{!isMobile && ( | ||
<Divider | ||
orientation="vertical" | ||
flexItem | ||
sx={{ borderColor: 'darkgrey' }} | ||
/> | ||
)} | ||
<Grid2 xs={12} md={4} my={GAP / 2} container direction="column"> | ||
<Typography variant="h4" px={GAP} pt={GAP}> | ||
{t('only_global')} | ||
</Typography> | ||
<Typography variant="caption" width="100%" component="p" px={GAP}> | ||
{t('global_caption')} | ||
</Typography> | ||
<Divider flexItem sx={{ my: 2, borderColor: 'darkgrey' }} /> | ||
<Chip | ||
label={t('zero_iv')} | ||
color="primary" | ||
disabled={!perms.iv} | ||
sx={[SX_PROPS, { my: 1, mx: GAP }]} | ||
/> | ||
<Chip | ||
label={t('hundo_iv')} | ||
color="primary" | ||
disabled={!perms.iv} | ||
sx={[SX_PROPS, { my: 1, mx: GAP }]} | ||
/> | ||
</Grid2> | ||
</Grid2> | ||
</DialogContent> | ||
<Footer options={OPTIONS} /> | ||
</DialogWrapper> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters