Skip to content

Commit

Permalink
Improve mobile experience
Browse files Browse the repository at this point in the history
  • Loading branch information
gausie committed Jul 15, 2023
1 parent c4234c9 commit c2e2830
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
6 changes: 3 additions & 3 deletions packages/greenbox-web/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default function Header({ meta, direct, loading, error, errorMessage }: P

return (
<AccordionItem>
<AccordionButton fontSize="4xl" as="section">
<HStack alignItems="center" flex={1}>
<AccordionButton fontSize="4xl" as="section" alignItems="start">
<HStack alignItems="center" flex={1} maxWidth="100%" wrap="wrap">
<Heading as="h1">Greenbox</Heading>
<Box>
<SwitchButton />
Expand All @@ -68,7 +68,7 @@ export default function Header({ meta, direct, loading, error, errorMessage }: P
) : null}
</Box>
</HStack>
<AccordionIcon />
<AccordionIcon height="1.1em" />
</AccordionButton>
<AccordionPanel>
<Stack>
Expand Down
19 changes: 14 additions & 5 deletions packages/greenbox-web/src/components/IotMs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Badge, Box, Flex, SimpleGrid, Text } from "@chakra-ui/react";
import { IotMStatus, ItemStatus, RawIotM } from "greenbox-data";
import { IotMStatus, RawIotM } from "greenbox-data";
import { useMemo } from "react";
import { useSelector } from "react-redux";

Expand All @@ -11,9 +11,14 @@ import Section from "./Section";

function Year({ year, complete }: { year: number; complete: boolean }) {
return (
<Flex key={`year-${year}`} alignItems="center" justifyContent="flex-end">
<Flex
gridColumn={["1 / span 3", null, 1]}
key={`year-${year}`}
alignItems="center"
justifyContent={[null, null, "flex-end"]}
>
<Badge
sx={{ transform: "rotate(270deg)" }}
transform={[null, null, "rotate(270deg)"]}
fontSize="sm"
bg={complete ? "complete" : undefined}
>
Expand Down Expand Up @@ -70,7 +75,11 @@ export default function IotMs({ iotms: playerIotMs }: Props) {
]}
max={iotms.length}
>
<SimpleGrid columns={[13]} spacing={1} gridTemplateColumns="auto repeat(12, minmax(0, 1fr))">
<SimpleGrid
spacing={1}
columns={[3, null, 13]}
gridTemplateColumns={[null, null, "auto repeat(12, minmax(0, 1fr))"]}
>
{iotmChunks.map((yearChunk, year) => {
const all = yearChunk
.filter(notNullOrUndefined)
Expand All @@ -87,7 +96,7 @@ export default function IotMs({ iotms: playerIotMs }: Props) {
status={idToIotM[iotm.id]?.[1] ?? 0}
/>
) : (
<Box key={`blank-${i}`} />
<Box display={["none", null, "block"]} key={`blank-${i}`} />
),
),
];
Expand Down
21 changes: 9 additions & 12 deletions packages/greenbox-web/src/components/MetaInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { HStack, IconButton, Text } from "@chakra-ui/react";
import { HStack, Text } from "@chakra-ui/react";
import { formatDistance, intlFormat } from "date-fns";
import { RawSnapshotData } from "greenbox-data";
import { useEffect, useMemo, useState } from "react";

import { FavouriteButton } from "./FavouriteButton";
import Image from "./Image";

type Props = {
meta: RawSnapshotData["meta"];
Expand Down Expand Up @@ -35,15 +34,13 @@ export default function MetaInfo({ meta, direct }: Props) {
const timeago = useMemo(() => formatDistance(date, now, { addSuffix: true }), [now, date]);

return (
<Text fontSize="large">
<HStack spacing="0.25em">
<span title={`r${meta.revision}`}>{direct ? "Private s" : "S"}napshot</span>
<span>by</span>
<b title={`Player #${meta.id}`}>{meta.name}</b>
<span>from</span>
<span title={humanDate}>{timeago}</span>
{!direct && <FavouriteButton />}
</HStack>
</Text>
<HStack fontSize="large" spacing="0.25em" wrap="wrap">
<Text title={`r${meta.revision}`}>{`${direct ? "Private s" : "S"}napshot`}</Text>{" "}
<Text>by</Text>{" "}
<Text fontWeight="bold" title={`Player #${meta.id}`}>
{meta.name}
</Text>{" "}
<Text>from</Text> <Text title={humanDate}>{timeago}</Text> {!direct && <FavouriteButton />}
</HStack>
);
}
24 changes: 12 additions & 12 deletions packages/greenbox-web/src/components/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ interface Props extends React.PropsWithChildren {
export default function Section({ title, icon, loading = false, values, max, children }: Props) {
return (
<AccordionItem isDisabled={loading}>
<Heading>
<AccordionButton fontSize="3xl">
<Stack direction="row" flex="1" textAlign="left">
<AlphaImage src={icon} />
<Box>{title}</Box>
</Stack>
<Box alignSelf="stretch" flex="1">
<Progress values={values} max={max} />
</Box>
{loading ? <Spinner /> : <AccordionIcon />}
</AccordionButton>
</Heading>
<AccordionButton fontSize="3xl">
<Stack direction="row" flex="1" textAlign="left">
<AlphaImage src={icon} />
<Heading fontSize={["xl", null, "3xl"]} fontWeight="normal">
{title}
</Heading>
</Stack>
<Box alignSelf="stretch" flex="1 1">
<Progress values={values} max={max} />
</Box>
{loading ? <Spinner /> : <AccordionIcon />}
</AccordionButton>
<AccordionPanel>{children}</AccordionPanel>
</AccordionItem>
);
Expand Down

0 comments on commit c2e2830

Please sign in to comment.