change compat mode to change the grid
This commit is contained in:
@@ -2,6 +2,8 @@ import { AccessToken } from "@/types";
|
|||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
import { CharacterRow } from "../Characters/CharacterRow";
|
import { CharacterRow } from "../Characters/CharacterRow";
|
||||||
import { PlanetaryInteractionRow } from "../PlanetaryInteraction/PlanetaryInteractionRow";
|
import { PlanetaryInteractionRow } from "../PlanetaryInteraction/PlanetaryInteractionRow";
|
||||||
|
import { useContext } from "react";
|
||||||
|
import { SessionContext } from "@/app/context/Context";
|
||||||
|
|
||||||
export const AccountCard = ({
|
export const AccountCard = ({
|
||||||
characters,
|
characters,
|
||||||
@@ -10,11 +12,13 @@ export const AccountCard = ({
|
|||||||
characters: AccessToken[];
|
characters: AccessToken[];
|
||||||
sessionReady: boolean;
|
sessionReady: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
|
const { compactMode } = useContext(SessionContext);
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
padding: 1,
|
padding: 1,
|
||||||
borderBottom: "solid 1px gray",
|
borderBottom: compactMode ? "" : "solid 1px gray",
|
||||||
|
borderRight: compactMode ? "solid 1px gray" : "",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography style={{ fontSize: "0.8rem" }} paddingLeft={2}>
|
<Typography style={{ fontSize: "0.8rem" }} paddingLeft={2}>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect } from "react";
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
CssBaseline,
|
CssBaseline,
|
||||||
@@ -23,7 +23,6 @@ const darkTheme = createTheme({
|
|||||||
|
|
||||||
export const MainGrid = ({ sessionReady }: { sessionReady: boolean }) => {
|
export const MainGrid = ({ sessionReady }: { sessionReady: boolean }) => {
|
||||||
const { characters } = useContext(CharacterContext);
|
const { characters } = useContext(CharacterContext);
|
||||||
const { compactMode } = useContext(SessionContext);
|
|
||||||
const groupByAccount = characters.reduce<Grouped>((group, character) => {
|
const groupByAccount = characters.reduce<Grouped>((group, character) => {
|
||||||
const { account } = character;
|
const { account } = character;
|
||||||
group[account ?? ""] = group[account ?? ""] ?? [];
|
group[account ?? ""] = group[account ?? ""] ?? [];
|
||||||
@@ -31,25 +30,23 @@ export const MainGrid = ({ sessionReady }: { sessionReady: boolean }) => {
|
|||||||
return group;
|
return group;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
const { compactMode } = useContext(SessionContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={darkTheme}>
|
<ThemeProvider theme={darkTheme}>
|
||||||
<CssBaseline />
|
<CssBaseline />
|
||||||
<Box sx={{ flexGrow: 1 }}>
|
<Box sx={{ flexGrow: 1 }}>
|
||||||
<ResponsiveAppBar />
|
<ResponsiveAppBar />
|
||||||
<Grid container spacing={1}>
|
<Grid container spacing={1}>
|
||||||
|
{Object.values(groupByAccount).map((g, id) => (
|
||||||
<Grid
|
<Grid
|
||||||
item
|
item
|
||||||
xs={12}
|
xs={compactMode ? 6 : 12}
|
||||||
style={{ display: compactMode ? "flex" : "block" }}
|
|
||||||
>
|
|
||||||
{Object.values(groupByAccount).map((g, id) => (
|
|
||||||
<AccountCard
|
|
||||||
key={`account-${id}-${g[0].account}`}
|
key={`account-${id}-${g[0].account}`}
|
||||||
characters={g}
|
>
|
||||||
sessionReady={sessionReady}
|
<AccountCard characters={g} sessionReady={sessionReady} />
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Box>
|
</Box>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
|
Reference in New Issue
Block a user