Skip to content

Commit b805923

Browse files
authored
Merge pull request #919 from WatWowMap/fix-gym-badge
fix: gym badge page styling
2 parents c0f74fb + 19997aa commit b805923

8 files changed

Lines changed: 189 additions & 43 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"@graphql-tools/load": "^8.0.0",
109109
"@monaco-editor/react": "^4.5.1",
110110
"@mui/icons-material": "^5.14.0",
111+
"@mui/lab": "^5.0.0-alpha.160",
111112
"@mui/material": "^5.14.0",
112113
"@rainb0w-clwn/passport-telegram-official": "^2.0.2",
113114
"@rm/config": "*",

src/assets/css/main.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,13 @@ input[type='time']::-webkit-calendar-picker-indicator {
483483
grid-template-columns: 25% 75%;
484484
}
485485

486+
.profile-container {
487+
display: grid;
488+
grid-template-columns: 100%;
489+
grid-template-rows: 100;
490+
height: 100%;
491+
}
492+
486493
@media screen and (max-width: 600px) {
487494
.container {
488495
display: grid;
@@ -501,6 +508,11 @@ input[type='time']::-webkit-calendar-picker-indicator {
501508
grid-template-rows: max-content 1fr;
502509
}
503510

511+
.gym-badge-grid {
512+
display: grid;
513+
grid-template-rows: max-content max-content 1fr;
514+
}
515+
504516
.vgrid-item {
505517
display: grid;
506518
grid-template-columns: 1fr 1fr 1fr;

src/components/layout/dialogs/filters/Advanced.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default function AdvancedFilter() {
7878
if (!save) {
7979
setFilters({ ...backup.current })
8080
} else if (id === 'global' && selectedIds?.length && category) {
81-
applyToAll(true, category, selectedIds, false)
81+
applyToAll(filters, category, selectedIds, false)
8282
}
8383
}
8484

@@ -96,7 +96,7 @@ export default function AdvancedFilter() {
9696
color: 'secondary',
9797
},
9898
],
99-
[standard, setFilters],
99+
[standard, filters, setFilters],
100100
)
101101

102102
/** @type {import('@mui/material').SwitchProps['onChange']} */

src/components/layout/dialogs/profile/GymBadges.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function UserGymBadges() {
4444
}, [data])
4545

4646
return data ? (
47-
<Box className="user-profile-badge-grid">
47+
<Box className="gym-badge-grid">
4848
<Typography variant="h5" align="center" gutterBottom>
4949
{t('gym_badges')}
5050
</Typography>
@@ -61,7 +61,7 @@ export function UserGymBadges() {
6161
</Grid>
6262
))}
6363
</Grid>
64-
<VirtualGrid data={data?.badges || []} xs={4} md={3} useWindowScroll>
64+
<VirtualGrid data={data?.badges || []} xs={4} md={3}>
6565
{(_, badge) => <BadgeTile {...badge} />}
6666
</VirtualGrid>
6767
</Box>
@@ -75,7 +75,7 @@ function BadgeTile({ badge, ...gym }) {
7575
const badgeIcon = useMemory((s) => s.Icons.getMisc(`badge_${badge}`))
7676

7777
return badge ? (
78-
<Box className="vgrid-item" minHeight={225}>
78+
<Box className="vgrid-item" minHeight={200}>
7979
<IconButton
8080
className="vgrid-icon"
8181
disabled={gym.deleted}

src/components/layout/dialogs/profile/index.jsx

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import * as React from 'react'
2-
import { DialogContent, AppBar, Tabs, Tab, Box } from '@mui/material'
32
import { useTranslation } from 'react-i18next'
3+
import TabContext from '@mui/lab/TabContext'
4+
import TabList from '@mui/lab/TabList'
5+
import TabPanel from '@mui/lab/TabPanel'
6+
import Tab from '@mui/material/Tab'
7+
import Box from '@mui/material/Box'
8+
import DialogContent from '@mui/material/DialogContent'
49

510
import { useMemory } from '@hooks/useMemory'
611
import { useLayoutStore } from '@hooks/useLayoutStore'
712
import Utility from '@services/Utility'
813

914
import Header from '../../general/Header'
1015
import Footer from '../../general/Footer'
11-
import TabPanel from '../../general/TabPanel'
1216
import { DialogWrapper } from '../DialogWrapper'
1317
import { UserBackups } from './Backups'
1418
import { UserPermissions } from './Permissions'
@@ -24,8 +28,9 @@ export default function UserProfile() {
2428

2529
const locale = localStorage.getItem('i18nextLng') || 'en'
2630

27-
const [tab, setTab] = React.useState(0)
31+
const [tab, setTab] = React.useState('profile')
2832
const [tabsHeight, setTabsHeight] = React.useState(0)
33+
2934
const handleTabChange = (_event, newValue) => {
3035
setTab(newValue)
3136
}
@@ -42,36 +47,37 @@ export default function UserProfile() {
4247
action={handleClose}
4348
/>
4449
<DialogContent sx={{ p: 0 }}>
45-
<AppBar
46-
position="static"
47-
ref={(ref) => ref && setTabsHeight(ref.clientHeight)}
48-
>
49-
<Tabs value={tab} onChange={handleTabChange}>
50+
<TabContext value={tab}>
51+
<TabList
52+
onChange={handleTabChange}
53+
ref={(ref) => ref && setTabsHeight(ref.clientHeight)}
54+
>
5055
{['profile', 'badges', 'access'].map((each) => (
51-
<Tab key={each} label={t(each)} />
56+
<Tab key={each} label={t(each)} value={each} />
5257
))}
53-
</Tabs>
54-
</AppBar>
55-
<Box
56-
overflow="auto"
57-
maxHeight={{
58-
xs: `calc(100% - ${tabsHeight}px)`,
59-
sm: `calc(75vh - ${tabsHeight}px)`,
60-
}}
61-
minHeight="70vh"
62-
>
63-
<TabPanel value={tab} index={0}>
64-
<LinkAccounts />
65-
<ExtraUserFields />
66-
<UserBackups />
67-
</TabPanel>
68-
<TabPanel value={tab} index={1}>
69-
<UserGymBadges />
70-
</TabPanel>
71-
<TabPanel value={tab} index={2}>
72-
<UserPermissions />
73-
</TabPanel>
74-
</Box>
58+
</TabList>
59+
<Box
60+
overflow="auto"
61+
height={{
62+
xs: `calc(100% - ${tabsHeight}px)`,
63+
sm: `calc(70vh - ${tabsHeight}px)`,
64+
}}
65+
>
66+
<TabPanel value="profile">
67+
<LinkAccounts />
68+
<ExtraUserFields />
69+
<UserBackups />
70+
</TabPanel>
71+
<TabPanel value="badges" sx={{ height: '100%', px: 0 }}>
72+
<Box className="profile-container">
73+
<UserGymBadges />
74+
</Box>
75+
</TabPanel>
76+
<TabPanel value="access">
77+
<UserPermissions />
78+
</TabPanel>
79+
</Box>
80+
</TabContext>
7581
</DialogContent>
7682
<Footer
7783
options={[

src/components/layout/general/Menu.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,24 @@ export default function Menu({
9898
{
9999
name: 'disable_all',
100100
action: () =>
101-
applyToAll(false, category, filteredArr, !webhookCategory),
101+
applyToAll(
102+
{ enabled: false },
103+
category,
104+
filteredArr,
105+
!webhookCategory,
106+
),
102107
icon: 'Clear',
103108
color: 'error',
104109
},
105110
{
106111
name: 'enable_all',
107-
action: () => applyToAll(true, category, filteredArr, !webhookCategory),
112+
action: () =>
113+
applyToAll(
114+
{ enabled: true },
115+
category,
116+
filteredArr,
117+
!webhookCategory,
118+
),
108119
icon: 'Check',
109120
color: 'success',
110121
},

src/services/filtering/applyToAll.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ export const STANDARD_BACKUP =
1313
})
1414

1515
/**
16-
* @param {boolean} show
17-
* @param {import('@rm/types').Categories} category
16+
* @template {import('@rm/types').Categories} T
17+
* @param {T extends 'pokemon' ? import('@rm/types/lib').PokemonFilter : import('@rm/types').BaseFilter} newFilter
18+
* @param {T} category
1819
* @param {string[]} [selectedIds]
1920
* @param {boolean} [includeSlots]
2021
*/
2122
export function applyToAll(
22-
show,
23+
newFilter,
2324
category,
2425
selectedIds = [],
2526
includeSlots = false,
@@ -41,13 +42,15 @@ export function applyToAll(
4142
[
4243
key,
4344
idSet.has(key)
44-
? { size: 'md', ...filter, enabled: show, all: !!easyMode }
45+
? { size: 'md', ...filter, ...newFilter, all: !!easyMode }
4546
: filter,
4647
],
4748
]
4849
if (key.startsWith('t') && +key.charAt(1) !== 0 && includeSlots) {
4950
filters.push(
50-
...Object.entries(Utility.generateSlots(key, show, userFilters)),
51+
...Object.entries(
52+
Utility.generateSlots(key, newFilter.enabled, userFilters),
53+
),
5154
)
5255
}
5356
return filters

0 commit comments

Comments
 (0)