Skip to content

Commit 396fcaf

Browse files
committed
TCA-1090 - grow certificate to fit view width
1 parent 7f22cd4 commit 396fcaf

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src-ts/tools/learn/learn-lib/certificate-page-layout/CertificatePageLayout.module.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
display: flex;
88

99
background: $tc-grad15;
10+
overflow: hidden;
1011
}
1112

1213
.content-wrap {
@@ -29,6 +30,8 @@
2930
display: flex;
3031
flex-direction: column;
3132
align-items: center;
33+
z-index: 1;
34+
position: relative;
3235

3336
gap: $space-sm;
3437

@@ -52,7 +55,7 @@
5255
.certificate-wrap {
5356
aspect-ratio: $tca-certif-aspect-ratio;
5457
width: 100%;
55-
max-width: 880px;
58+
max-width: 1216px;
5659
position: relative;
5760

5861
&:global(.large-container) {

src-ts/tools/learn/learn-lib/certificate-page-layout/CertificatePageLayout.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ const CertificatePageLayout: FC<CertificatePageLayoutProps> = (props: Certificat
5353
const certificateWrapRef: MutableRefObject<HTMLDivElement | any> = useRef()
5454
const navigateBack: NavigateBackFunction = useNavigateBack()
5555

56-
useCertificateScaling(props.isReady ? certificateWrapRef : undefined, 880, 880)
56+
useCertificateScaling(
57+
props.isReady ? certificateWrapRef : undefined,
58+
880,
59+
880,
60+
viewStyle ? 1 : Math.min(),
61+
)
5762

5863
const handleBackBtnClick: () => void = useCallback(() => {
5964
navigateBack(props.fallbackBackUrl ?? '')

src-ts/tools/learn/learn-lib/use-certificate-scaling-hook/useCertificateScaling.hook.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export function useCertificateScaling(
44
certificateRef?: MutableRefObject<HTMLDivElement | undefined>,
55
originalSizeLg: number = 1250,
66
originalSizeSm: number = 975,
7+
scaleLimit: number = 1,
78
): void {
89

910
// the certificate isn't responsive: should look the same on mobile and desktop
@@ -19,12 +20,12 @@ export function useCertificateScaling(
1920
// 975 and 1250 are the original container sizes,
2021
// and we're dividing by that to get the needed zoom level
2122
const ratioSize: number = window.innerWidth <= 745 ? originalSizeSm : originalSizeLg
22-
const scaleLevel: number = Math.min(1, parentWidth / ratioSize)
23+
const scaleLevel: number = Math.min(scaleLimit, parentWidth / ratioSize)
2324
Object.assign(certificateEl.style, { transform: `scale(${scaleLevel})`, transformOrigin: '0 0' })
2425
}
2526

2627
window.addEventListener('resize', handleResize, false)
2728
handleResize()
2829
return () => window.removeEventListener('resize', handleResize, false)
29-
}, [certificateRef, originalSizeLg, originalSizeSm])
30+
}, [certificateRef, originalSizeLg, originalSizeSm, scaleLimit])
3031
}

0 commit comments

Comments
 (0)