Skip to content

Commit

Permalink
better mobile support
Browse files Browse the repository at this point in the history
don't remove features from mobile, even if it breaks the site
  • Loading branch information
SheepTester committed May 10, 2024
1 parent d366b86 commit 88b8d95
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 70 deletions.
30 changes: 24 additions & 6 deletions src/GZCTF/ClientApp/src/components/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { createStyles } from '@mantine/emotion'
import {
mdiAccountCircleOutline,
mdiAccountGroupOutline,
mdiBullhornOutline,
mdiCached,
mdiFlagOutline,
mdiHomeVariantOutline,
mdiLogout,
mdiTranslate,
mdiWeatherNight,
Expand Down Expand Up @@ -94,6 +97,27 @@ const AppHeader: FC = () => {
<Menu.Dropdown>
{user && !error ? (
<>
<Menu.Item
component={Link}
to="/"
leftSection={<Icon path={mdiHomeVariantOutline} size={1} />}
>
{t('common.tab.home')}
</Menu.Item>
<Menu.Item
component={Link}
to="/posts"
leftSection={<Icon path={mdiBullhornOutline} size={1} />}
>
{t('common.tab.post')}
</Menu.Item>
<Menu.Item
component={Link}
to="/games"
leftSection={<Icon path={mdiFlagOutline} size={1} />}
>
{t('common.tab.game')}
</Menu.Item>
<Menu.Item
component={Link}
to="/teams"
Expand All @@ -108,12 +132,6 @@ const AppHeader: FC = () => {
>
{t('common.tab.account.profile')}
</Menu.Item>
<Menu.Item
onClick={clearLocalCache}
leftSection={<Icon path={mdiCached} size={1} />}
>
{t('common.tab.account.clean_cache')}
</Menu.Item>
<Menu.Item
color="red"
onClick={logout}
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/IconTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const IconTabs: FC<IconTabsProps> = (props) => {
))

return (
<Group gap={0} justify="space-between" w="100%" wrap="nowrap">
<Group gap={0} justify="space-between" w="100%">
{aside}
{withIcon && (
<LogoHeader
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/TeamCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TeamCard: FC<TeamCardProps> = (props) => {
<Group align="stretch" style={{ flexWrap: 'nowrap', alignItems: 'center' }}>
<Stack style={{ flexGrow: 1 }}>
<Group align="stretch" justify="space-between">
<Avatar alt="avatar" color="cyan" size="lg" radius="md" src={team.avatar}>
<Avatar alt="avatar" color="orange" size="lg" radius="md" src={team.avatar}>
{team.name?.slice(0, 1) ?? 'T'}
</Avatar>

Expand Down
44 changes: 21 additions & 23 deletions src/GZCTF/ClientApp/src/components/TeamRank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const TeamRank: FC<CardProps> = (props) => {
<Card {...props} shadow="sm" p="md">
<Stack gap={8}>
<Group gap="sm" wrap="nowrap">
<Avatar alt="avatar" color="cyan" size={50} radius="md" src={teamInfo?.rank?.avatar}>
<Avatar alt="avatar" color="orange" size={50} radius="md" src={teamInfo?.rank?.avatar}>
{teamInfo?.rank?.name?.slice(0, 1) ?? 'T'}
</Avatar>
<Skeleton visible={!teamInfo}>
Expand Down Expand Up @@ -105,28 +105,26 @@ const TeamRank: FC<CardProps> = (props) => {
</Stack>
</Group>
<Progress value={solved * 100} />
{!isMobile && (
<PasswordInput
value={teamInfo?.teamToken}
readOnly
leftSection={<Icon path={mdiKey} size={1} />}
variant="unstyled"
onClick={() => {
clipboard.copy(teamInfo?.teamToken)
showNotification({
color: 'teal',
message: t('team.notification.token.copied'),
icon: <Icon path={mdiCheck} size={1} />,
})
}}
styles={{
innerInput: {
cursor: 'copy',
fontFamily: theme.fontFamilyMonospace,
},
}}
/>
)}
<PasswordInput
value={teamInfo?.teamToken}
readOnly
leftSection={<Icon path={mdiKey} size={1} />}
variant="unstyled"
onClick={() => {
clipboard.copy(teamInfo?.teamToken)
showNotification({
color: 'teal',
message: t('team.notification.token.copied'),
icon: <Icon path={mdiCheck} size={1} />,
})
}}
styles={{
innerInput: {
cursor: 'copy',
fontFamily: theme.fontFamilyMonospace,
},
}}
/>
</Stack>
</Card>
)
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/ClientApp/src/components/WithNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const WithNavBar: FC<WithNavBarProps> = ({
const isMobile = useIsMobile()

return (
<WithWiderScreen minWidth={minWidth}>
<WithWiderScreen minWidth={0}>
<Watermark
text={user?.userId ?? ''}
textColor={colorScheme === 'dark' ? theme.colors.gray[3] : theme.colors.gray[7]}
Expand Down
36 changes: 17 additions & 19 deletions src/GZCTF/ClientApp/src/pages/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,23 @@ const Home: FC = () => {
<PostCard key={post.id} post={post} onTogglePinned={onTogglePinned} />
))}
</Stack>
{!isMobile && (
<nav className={classes.wrapper}>
<div className={classes.inner}>
<Stack>
<Group>
<Icon
path={mdiFlagCheckered}
size={1.5}
color={theme.colors[theme.primaryColor][4]}
/>
<Title order={3}>
<Trans i18nKey="common.content.home.recent_games" />
</Title>
</Group>
{recentGames?.map((game) => <RecentGame key={game.id} game={game} />)}
</Stack>
</div>
</nav>
)}
<nav className={classes.wrapper}>
<div className={classes.inner}>
<Stack>
<Group>
<Icon
path={mdiFlagCheckered}
size={1.5}
color={theme.colors[theme.primaryColor][4]}
/>
<Title order={3}>
<Trans i18nKey="common.content.home.recent_games" />
</Title>
</Group>
{recentGames?.map((game) => <RecentGame key={game.id} game={game} />)}
</Stack>
</div>
</nav>
</Group>
</Stack>
</Stack>
Expand Down
13 changes: 5 additions & 8 deletions src/GZCTF/ClientApp/src/pages/games/[id]/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,11 @@ const GameDetail: FC = () => {
{t('game.button.leave')}
</Button>
)}
{status === ParticipationStatus.Accepted &&
started &&
!isMobile &&
(!finished || game?.practiceMode) && (
<Button onClick={() => navigate(`/games/${numId}/challenges`)}>
{t('game.button.challenges')}
</Button>
)}
{status === ParticipationStatus.Accepted && started && (!finished || game?.practiceMode) && (
<Button onClick={() => navigate(`/games/${numId}/challenges`)}>
{t('game.button.challenges')}
</Button>
)}
</>
)

Expand Down
17 changes: 6 additions & 11 deletions src/GZCTF/ClientApp/src/pages/posts/[postId]/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,12 @@ const PostEdit: FC = () => {
<WithRole requiredRole={Role.Admin}>
<Stack mt={isMobile ? 25 : 30}>
<Group justify={isMobile ? 'right' : 'space-between'}>
{!isMobile && (
<Title
order={1}
c={alpha(
colorScheme === 'dark' ? theme.colors.light[6] : theme.colors.gray[7],
0.5
)}
>
{`> ${postId === 'new' ? t('post.button.new') : t('post.button.edit')}`}
</Title>
)}
<Title
order={1}
c={alpha(colorScheme === 'dark' ? theme.colors.light[6] : theme.colors.gray[7], 0.5)}
>
{`> ${postId === 'new' ? t('post.button.new') : t('post.button.edit')}`}
</Title>
<Group justify="right">
{postId?.length === 8 && (
<>
Expand Down

0 comments on commit 88b8d95

Please sign in to comment.