Skip to content

Commit 2928b60

Browse files
authored
Merge pull request #524 from topcoder-platform/various-cert-details-fixes
Various cert details fixes -> dev
2 parents 23d1717 + 6b9e37f commit 2928b60

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

src-ts/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Routes } from 'react-router-dom'
33
import { toast, ToastContainer } from 'react-toastify'
44

55
import { Header } from './header'
6-
import { routeContext, RouteContextData } from './lib'
6+
import { routeContext, RouteContextData, useViewportUnitsFix } from './lib'
77

88
const App: FC<{}> = () => {
99

@@ -12,6 +12,8 @@ const App: FC<{}> = () => {
1212
const routeElements: Array<ReactElement> = allRoutes
1313
.map(route => getRouteElement(route))
1414

15+
useViewportUnitsFix()
16+
1517
return (
1618
<>
1719
<Header />

src-ts/lib/hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export * from './use-check-is-mobile.hook'
22
export * from './use-click-outside.hook'
33
export * from './use-on-hover-element.hook'
44
export * from './use-storage.hook'
5+
export * from './use-viewport-units-fix.hook'
56
export * from './use-window-size.hook'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

src-ts/lib/styles/_modals.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
display: flex;
1111
flex-direction: column;
1212
width: 100vw;
13-
height: 100vh;
13+
height: calc(var(--vh, 1vh) * 100);
1414
margin: auto;
1515
border-radius: 0;
1616
padding: $space-xxl $space-xxxxl $space-xxxxl;

src-ts/tools/learn/certification-details/certification-details-sidebar/CertificationDetailsSidebar.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ const CertificationDetailsSidebar: FC<CertificationDetailsSidebarProps> = (props
8282
</span>
8383
<span className='quote-main'>
8484
<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+
/>
8594
</span>
8695
</li>
8796
{!props.certProgress && (

0 commit comments

Comments
 (0)