Skip to content

Commit 026ab76

Browse files
committed
feat: hide academy logo on mobile and mobile badge fix
1 parent 010bdf4 commit 026ab76

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

src/components/Topbar.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
useColorModeValue,
1515
useBreakpointValue,
1616
useDisclosure,
17+
useMediaQuery,
1718
} from "@chakra-ui/react";
1819
import {
1920
HamburgerIcon,
@@ -51,8 +52,12 @@ const NAV_ITEMS: Array<NavItem> = [
5152

5253
export default function Topbar() {
5354
const { isOpen, onToggle } = useDisclosure();
54-
const router = useRouter();
55+
const [isMobile] = useMediaQuery("(max-width: 768px)", {
56+
ssr: true,
57+
fallback: true, // return false on the server, and re-evaluate on the client side
58+
});
5559

60+
const router = useRouter();
5661
return (
5762
<Box
5863
as="header"
@@ -96,12 +101,15 @@ export default function Topbar() {
96101
href={"/"}
97102
textAlign={useBreakpointValue({ base: "center", md: "left" })}
98103
>
99-
{router.pathname.endsWith("/[slug]") ? (
100-
<SchoolOfCodeLogo />
101-
) : (
102-
<SchoolOfCodeLogo autoStart={true} loop={true} />
103-
)}
104+
{!isMobile ? (
105+
router.pathname.endsWith("/[slug]") ? (
106+
<SchoolOfCodeLogo />
107+
) : (
108+
<SchoolOfCodeLogo autoStart={true} loop={true} />
109+
)
110+
) : null}
104111
</Link>
112+
105113
<Flex
106114
justify={"flex-end"}
107115
alignItems="center"

src/pages/getting-started.tsx

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Divider,
1616
Box,
1717
Badge,
18+
useMediaQuery,
1819
} from "@chakra-ui/react";
1920
import { type ReactElement } from "react";
2021
import Layout from "@/components/Layout";
@@ -24,7 +25,10 @@ import { useAppContext } from "@/contexts/AppContext";
2425

2526
const GettingStartedPage: NextPageWithLayout<Lessons> = () => {
2627
const { projects, fundamentals } = useAppContext();
27-
28+
const [isMobile] = useMediaQuery("(max-width: 768px)", {
29+
ssr: true,
30+
fallback: true, // return false on the server, and re-evaluate on the client side
31+
});
2832
return (
2933
<Flex
3034
py={5}
@@ -92,18 +96,26 @@ const GettingStartedPage: NextPageWithLayout<Lessons> = () => {
9296
fontSize: "xl",
9397
}}
9498
>
95-
{lesson.frontMatter.title}
96-
{lesson && lesson.completed && lesson.completed === true ? (
97-
<Badge
98-
ml="1"
99-
alignItems={"flex-end"}
100-
colorScheme="green"
101-
position="absolute"
102-
right={3}
103-
>
104-
Completed
105-
</Badge>
106-
) : null}
99+
<Flex direction={!isMobile ? "row" : "column"}>
100+
<Box>{lesson.frontMatter.title}</Box>
101+
<Box>
102+
{lesson &&
103+
lesson.completed &&
104+
lesson.completed === true ? (
105+
<>
106+
<Badge
107+
ml="1"
108+
alignItems={"flex-end"}
109+
colorScheme="green"
110+
position={!isMobile ? "absolute" : "relative"}
111+
right={3}
112+
>
113+
Completed
114+
</Badge>
115+
</>
116+
) : null}
117+
</Box>
118+
</Flex>
107119
</Button>
108120
</Link>
109121
</ListItem>

0 commit comments

Comments
 (0)