File tree Expand file tree Collapse file tree 5 files changed +35
-2
lines changed Expand file tree Collapse file tree 5 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Routes } from 'react-router-dom'
3
3
import { toast , ToastContainer } from 'react-toastify'
4
4
5
5
import { Header } from './header'
6
- import { routeContext , RouteContextData } from './lib'
6
+ import { routeContext , RouteContextData , useViewportUnitsFix } from './lib'
7
7
8
8
const App : FC < { } > = ( ) => {
9
9
@@ -12,6 +12,8 @@ const App: FC<{}> = () => {
12
12
const routeElements : Array < ReactElement > = allRoutes
13
13
. map ( route => getRouteElement ( route ) )
14
14
15
+ useViewportUnitsFix ( )
16
+
15
17
return (
16
18
< >
17
19
< Header />
Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ export * from './use-check-is-mobile.hook'
2
2
export * from './use-click-outside.hook'
3
3
export * from './use-on-hover-element.hook'
4
4
export * from './use-storage.hook'
5
+ export * from './use-viewport-units-fix.hook'
5
6
export * from './use-window-size.hook'
Original file line number Diff line number Diff line change
1
+ import { MutableRefObject , useRef } from 'react'
2
+
3
+ import { useWindowSize , WindowSize } from './use-window-size.hook'
4
+
5
+ /**
6
+ * On mobile, vh units are not consistent accross devices/browsers,
7
+ * this hook listen to window resize and fixes sets a --vh CSS variable
8
+ * on the document root, so we can access it everywhere
9
+ *
10
+ * @see https://css-tricks.com/the-trick-to-viewport-units-on-mobile
11
+ */
12
+ export function useViewportUnitsFix ( ) : void {
13
+ const { height } : WindowSize = useWindowSize ( )
14
+ const wasHeight : MutableRefObject < number > = useRef ( height )
15
+
16
+ if ( wasHeight . current !== height ) {
17
+ // We execute the same script as before
18
+ const vh : number = window . innerHeight * 0.01
19
+ document . documentElement . style . setProperty ( '--vh' , `${ vh } px` )
20
+ }
21
+ }
Original file line number Diff line number Diff line change 10
10
display : flex ;
11
11
flex-direction : column ;
12
12
width : 100vw ;
13
- height : 100 vh ;
13
+ height : calc ( var ( --vh , 1 vh ) * 100 ) ;
14
14
margin : auto ;
15
15
border-radius : 0 ;
16
16
padding : $space-xxl $space-xxxxl $space-xxxxl ;
Original file line number Diff line number Diff line change @@ -82,6 +82,15 @@ const CertificationDetailsSidebar: FC<CertificationDetailsSidebarProps> = (props
82
82
</ span >
83
83
< span className = 'quote-main' >
84
84
< CompletionTimeRange range = { props . certification . completionTimeRange } />
85
+ < Tooltip
86
+ content = { renderTooltipContents ( < IconSolid . ClockIcon /> , [
87
+ 'Assuming 4 hour' ,
88
+ 'learning per day' ,
89
+ ] ) }
90
+ place = 'bottom'
91
+ trigger = { < IconOutline . InformationCircleIcon /> }
92
+ triggerOn = 'hover'
93
+ />
85
94
</ span >
86
95
</ li >
87
96
{ ! props . certProgress && (
You can’t perform that action at this time.
0 commit comments