Skip to content

Commit 2920330

Browse files
committed
add support for mobile by making the sidebar take up the full width of the screen and reducing the font size
1 parent 38935c0 commit 2920330

File tree

9 files changed

+65
-25
lines changed

9 files changed

+65
-25
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
- [x] Add cspell spell checker
1212
- [x] Add husky pre-commit hooks
1313
- [x] Code chunking for improved performance
14-
- [ ] Use checkboxes in the directory tree to indicate which files are shown in the main section
14+
- [x] Use checkboxes in the directory tree to indicate which files are shown in the main section
1515
- [ ] Construct more resilient unit tests
1616
- [ ] i18n translations
1717
- [ ] Light/Dark mode
1818
- [ ] Make use of the `getTreeStatistics` function
1919

2020
### Product
2121

22-
- [ ] Make the size of the sidebar adjustable (by dragging it?)
22+
- [ ] ~~Make the size of the sidebar adjustable (by dragging it?)~~
23+
- [x] Add support for mobile by making the sidebar take up the full width of the screen and reducing the font size
2324
- [ ] Make the file names sticky as the user scrolls down when examining the diffs
2425
- [ ] Update the `FileChangeType` status next to the file names to have their own colours
25-
- [ ] Make some optimisations for mobile viewers

src/components/app/index.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
22
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
33
import MenuIcon from "@mui/icons-material/Menu";
4-
import { Box, Drawer, IconButton, Toolbar, Typography, useTheme } from "@mui/material";
4+
import { Box, Drawer, IconButton, Toolbar, Typography, useMediaQuery, useTheme } from "@mui/material";
55
import { useState } from "react";
66
import { Bounce, ToastContainer } from "react-toastify";
77

@@ -14,9 +14,10 @@ import DirectoryTree from "@/features/directoryTree";
1414
import { drawerWidth } from "@/utils/constants";
1515

1616
export default function App() {
17-
const { direction, spacing } = useTheme();
17+
const { breakpoints, direction, spacing } = useTheme();
18+
const isMobile = useMediaQuery(breakpoints.down("sm"));
1819

19-
const [open, setOpen] = useState<boolean>(true);
20+
const [open, setOpen] = useState<boolean>(!isMobile);
2021

2122
return (
2223
<>
@@ -59,11 +60,17 @@ export default function App() {
5960
variant="persistent"
6061
anchor="left"
6162
sx={{
62-
width: drawerWidth,
63+
width: {
64+
xs: "100%",
65+
sm: drawerWidth,
66+
},
6367
flexShrink: 0,
6468

6569
"& .MuiDrawer-paper": {
66-
width: drawerWidth,
70+
width: {
71+
xs: "100%",
72+
sm: drawerWidth,
73+
},
6774
boxSizing: "border-box",
6875
overflowY: "hidden",
6976
},

src/components/styled/header/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ interface HeaderProps extends AppBarProps {
88

99
export const Header = styled(AppBar, {
1010
shouldForwardProp: (prop) => prop !== "open",
11-
})<HeaderProps>(() => ({
11+
})<HeaderProps>(({ theme }) => ({
1212
width: "100%",
1313
marginLeft: 0,
1414
variants: [
1515
{
1616
props: ({ open }) => open,
1717
style: {
18-
width: `calc(100% - ${drawerWidth}px)`,
19-
marginLeft: `${drawerWidth}px`,
18+
[theme.breakpoints.up("sm")]: {
19+
width: `calc(100% - ${drawerWidth}px)`,
20+
marginLeft: `${drawerWidth}px`,
21+
},
2022
},
2123
},
2224
],

src/components/styled/main/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ export const Main = styled("main", {
77
})<{ open?: boolean }>(({ theme, open }) => ({
88
flexGrow: 1,
99
padding: theme.spacing(3),
10-
marginLeft: open ? `${drawerWidth}px` : 0,
11-
width: open ? `calc(100% - ${drawerWidth}px)` : "100%",
1210
height: "100%",
1311
overflowY: "auto",
12+
marginLeft: open ? `${drawerWidth}px` : 0,
13+
width: open ? `calc(100% - ${drawerWidth}px)` : "100%",
14+
[theme.breakpoints.down("sm")]: {
15+
marginLeft: 0,
16+
width: "100%",
17+
},
1418
}));

src/features/diffViewer/common/diffTableHeader/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ export default function DiffTableHeader({ hunk, isUnifiedView = false }: DiffTab
1818
<TableRow sx={{ bgcolor: "grey.50", userSelect: "none" }}>
1919
<MinimalTableCell
2020
sx={{
21-
minWidth: spacing(7),
21+
minWidth: {
22+
xs: spacing(6),
23+
sm: spacing(7),
24+
},
2225
position: "sticky",
2326
left: 0,
2427
textAlign: "right",
@@ -30,7 +33,10 @@ export default function DiffTableHeader({ hunk, isUnifiedView = false }: DiffTab
3033
{isUnifiedView && (
3134
<MinimalTableCell
3235
sx={{
33-
minWidth: spacing(7),
36+
minWidth: {
37+
xs: spacing(6),
38+
sm: spacing(7),
39+
},
3440
position: "sticky",
3541
left: 0,
3642
textAlign: "right",

src/features/diffViewer/splitViewer/splitTableRow/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ export default function SplitTableRow({ side, line }: SplitTableRowProps) {
5757
<MinimalTableCell
5858
sx={{
5959
bgcolor: bgColor,
60-
minWidth: spacing(7),
60+
minWidth: {
61+
xs: spacing(6),
62+
sm: spacing(7),
63+
},
6164
position: "sticky",
6265
left: 0,
6366
textAlign: "right",

src/features/diffViewer/unifiedViewer/unifiedTableRow/index.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ export default function UnifiedTableRow({ line }: UnifiedTableRowProps) {
7979
<MinimalTableCell
8080
sx={{
8181
bgcolor: bgColor,
82-
minWidth: spacing(7),
82+
minWidth: {
83+
xs: spacing(6),
84+
sm: spacing(7),
85+
},
8386
position: "sticky",
8487
left: 0,
8588
textAlign: "right",
@@ -104,9 +107,15 @@ export default function UnifiedTableRow({ line }: UnifiedTableRowProps) {
104107
<MinimalTableCell
105108
sx={{
106109
bgcolor: bgColor,
107-
minWidth: spacing(7),
108110
position: "sticky",
109-
left: spacing(7),
111+
minWidth: {
112+
xs: spacing(6),
113+
sm: spacing(7),
114+
},
115+
left: {
116+
xs: spacing(6),
117+
sm: spacing(7),
118+
},
110119
textAlign: "right",
111120
userSelect: "none",
112121
borderRight: 1,

src/main.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import "@fontsource/inter/300.css";
2-
import "@fontsource/inter/400.css";
3-
import "@fontsource/inter/500.css";
4-
import "@fontsource/inter/700.css";
51
import "@fontsource/source-code-pro/300.css";
62
import "@fontsource/source-code-pro/400.css";
73
import "@fontsource/source-code-pro/500.css";

src/theme/index.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { createTheme, responsiveFontSizes } from "@mui/material/styles";
33
import { customBlue, customGreen, customRed, customYellow } from "./customColors";
44

55
// https://mui.com/material-ui/customization/typography/
6-
let theme = createTheme({
6+
let theme = createTheme({});
7+
8+
theme = createTheme({
79
typography: {
810
fontFamily: [
911
'"Source Code Pro"',
10-
"Inter",
12+
// "Inter",
1113
"-apple-system",
1214
"BlinkMacSystemFont",
1315
'"Segoe UI"',
@@ -27,6 +29,17 @@ let theme = createTheme({
2729
yellow: customYellow,
2830
},
2931
components: {
32+
// Add global font size scaling for mobile
33+
MuiCssBaseline: {
34+
styleOverrides: {
35+
html: {
36+
fontSize: 16, // Desktop
37+
[theme.breakpoints.down("sm")]: {
38+
fontSize: 13, // Mobile
39+
},
40+
},
41+
},
42+
},
3043
MuiTable: {
3144
styleOverrides: {
3245
root: {

0 commit comments

Comments
 (0)