File tree Expand file tree Collapse file tree 2 files changed +39
-19
lines changed Expand file tree Collapse file tree 2 files changed +39
-19
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
14
14
useColorModeValue ,
15
15
useBreakpointValue ,
16
16
useDisclosure ,
17
+ useMediaQuery ,
17
18
} from "@chakra-ui/react" ;
18
19
import {
19
20
HamburgerIcon ,
@@ -51,8 +52,12 @@ const NAV_ITEMS: Array<NavItem> = [
51
52
52
53
export default function Topbar ( ) {
53
54
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
+ } ) ;
55
59
60
+ const router = useRouter ( ) ;
56
61
return (
57
62
< Box
58
63
as = "header"
@@ -96,12 +101,15 @@ export default function Topbar() {
96
101
href = { "/" }
97
102
textAlign = { useBreakpointValue ( { base : "center" , md : "left" } ) }
98
103
>
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 }
104
111
</ Link >
112
+
105
113
< Flex
106
114
justify = { "flex-end" }
107
115
alignItems = "center"
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
15
15
Divider ,
16
16
Box ,
17
17
Badge ,
18
+ useMediaQuery ,
18
19
} from "@chakra-ui/react" ;
19
20
import { type ReactElement } from "react" ;
20
21
import Layout from "@/components/Layout" ;
@@ -24,7 +25,10 @@ import { useAppContext } from "@/contexts/AppContext";
24
25
25
26
const GettingStartedPage : NextPageWithLayout < Lessons > = ( ) => {
26
27
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
+ } ) ;
28
32
return (
29
33
< Flex
30
34
py = { 5 }
@@ -92,18 +96,26 @@ const GettingStartedPage: NextPageWithLayout<Lessons> = () => {
92
96
fontSize : "xl" ,
93
97
} }
94
98
>
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 >
107
119
</ Button >
108
120
</ Link >
109
121
</ ListItem >
You can’t perform that action at this time.
0 commit comments