Skip to content

Commit 1910a58

Browse files
committed
Fix: #138 - Implement mobile responsiveness for the tour page UI.
1 parent 78df994 commit 1910a58

File tree

4 files changed

+83
-36
lines changed

4 files changed

+83
-36
lines changed

app/mobile/page.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.main {
1+
/* .main {
22
display: flex;
33
flex-direction: column;
44
justify-content: center;
@@ -9,4 +9,4 @@
99
1010
.message {
1111
font-weight: 500;
12-
}
12+
} */

app/mobile/page.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
"use client";
1+
// "use client";
22

3-
import React, { useEffect } from "react";
4-
import styles from "./page.module.css";
5-
import classnames from "classnames";
6-
import { outfitFont } from "../styles/fonts";
3+
// import React, { useEffect } from "react";
4+
// import styles from "./page.module.css";
5+
// import classnames from "classnames";
6+
// import { outfitFont } from "../styles/fonts";
77

8-
export default function Mobile() {
9-
useEffect(() => {
10-
// if not on mobile, redirect to the main page
11-
if (window.innerWidth > 768) {
12-
window.location.href = "/";
13-
}
14-
}, []);
15-
return (
16-
<div className={styles.main}>
17-
<div className={classnames(styles.message, outfitFont.className)}>
18-
We are sorry,
19-
<br />
20-
Tour of JSON Schema is not optimized for mobile devices. Please use a
21-
desktop computer for the best experience.
22-
</div>
23-
</div>
24-
);
25-
}
8+
// export default function Mobile() {
9+
// useEffect(() => {
10+
// // if not on mobile, redirect to the main page
11+
// if (window.innerWidth > 768) {
12+
// window.location.href = "/";
13+
// }
14+
// }, []);
15+
// return (
16+
// <div className={styles.main}>
17+
// <div className={classnames(styles.message, outfitFont.className)}>
18+
// We are sorry,
19+
// <br />
20+
// Tour of JSON Schema is not optimized for mobile devices. Please use a
21+
// desktop computer for the best experience.
22+
// </div>
23+
// </div>
24+
// );
25+
// }

app/providers.tsx

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,56 @@
11
"use client";
22
import { ChakraProvider } from "@chakra-ui/react";
33
import { theme } from "./styles/theme";
4-
import { useEffect } from "react";
4+
import styles from "./styles/page.module.css";
5+
import classnames from "classnames";
6+
7+
import { useEffect, useState } from "react";
8+
import { outfitFont } from "./styles/fonts";
9+
10+
const MOBILE_BREAKPOINT = 768;
511

612
export function Providers({ children }: { children: React.ReactNode }) {
7-
// useEffect(() => {
8-
// if (window.innerWidth < 768 && !window.location.href.includes("/mobile")) {
9-
// window.location.href = "/mobile";
10-
// }
11-
// }, []);
12-
13-
return <ChakraProvider theme={theme}>{children}</ChakraProvider>;
14-
}
13+
// 1. Initialize state for mobile status
14+
const [isMobile, setIsMobile] = useState(false);
15+
const [hasChecked, setHasChecked] = useState(false);
16+
17+
useEffect(() => {
18+
// 2. Function to check the screen width
19+
const checkMobileStatus = () => {
20+
setIsMobile(window.innerWidth <= MOBILE_BREAKPOINT);
21+
setHasChecked(true);
22+
};
23+
24+
checkMobileStatus();
25+
26+
27+
window.addEventListener('resize', checkMobileStatus);
28+
29+
return () => {
30+
window.removeEventListener('resize', checkMobileStatus);
31+
};
32+
}, []);
33+
34+
if (!hasChecked) {
35+
return null;
36+
}
37+
38+
if (!isMobile) {
39+
return (
40+
<ChakraProvider theme={theme}>
41+
{children}
42+
</ChakraProvider>
43+
);
44+
}
45+
46+
return (
47+
<div className={styles.main}>
48+
<div className={classnames(styles.message, outfitFont.className)}>
49+
We are sorry,
50+
<br />
51+
Tour of JSON Schema is not optimized for mobile devices. Please use a
52+
desktop computer for the best experience.
53+
</div>
54+
</div>
55+
);
56+
}

app/styles/page.module.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
.main {
22
display: flex;
33
flex-direction: column;
4-
height: inherit;
5-
4+
justify-content: center;
65
align-items: center;
6+
height: 100%;
7+
padding-inline: 12px;
78
}
89

910
.wrapper {
@@ -86,3 +87,7 @@
8687
.footerText {
8788
font-weight: 700;
8889
}
90+
91+
.message {
92+
font-weight: 500;
93+
}

0 commit comments

Comments
 (0)