Skip to content

Commit e7a4d40

Browse files
authored
Merge pull request #552 from topcoder-platform/TCA-1090_grow-to-fit-certificate
TCA-1090 grow to fit certificate -> dev
2 parents 1ba2b83 + b35e236 commit e7a4d40

File tree

13 files changed

+30
-45
lines changed

13 files changed

+30
-45
lines changed

src-ts/tools/learn/certification-details/enrolled-modal/EnrolledModal.module.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
.enrolledModal {
1111
color: $tc-white;
1212
background: url(./bg.jpg) center no-repeat, $tc-grad20;
13+
max-width: 560px;
1314

1415
@include ltemd {
1516
background: url(./bg-mobile.jpg) 0 0 no-repeat, $tc-grad20;
@@ -37,9 +38,8 @@
3738
}
3839

3940
h2 {
40-
@include ltemd {
41-
font-size: 24px;
42-
line-height: 28px;
43-
}
41+
text-transform: none;
42+
font-size: 26px;
43+
line-height: 32px;
4444
}
4545
}

src-ts/tools/learn/certification-details/enrolled-modal/EnrolledModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const EnrolledModal: FC<EnrolledModalProps> = (props: EnrolledModalProps) => {
2323
<BaseModal
2424
onClose={props.onClose}
2525
open={isOpen}
26-
size='sm'
26+
size='lg'
2727
classNames={{ modal: styles.enrolledModal, root: styles.modalRoot }}
2828
>
2929
<>
@@ -33,6 +33,7 @@ const EnrolledModal: FC<EnrolledModalProps> = (props: EnrolledModalProps) => {
3333
<Button
3434
buttonStyle='outline'
3535
label='Go to the certification details'
36+
size='sm'
3637
onClick={props.onClose}
3738
/>
3839
</>
Loading

src-ts/tools/learn/certification-details/enrollment-page/EnrollmentPage.tsx

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
SetStateAction,
77
useCallback,
88
useContext,
9-
useEffect,
109
useLayoutEffect,
1110
useRef,
1211
useState,
@@ -21,13 +20,10 @@ import {
2120
} from '../../../../lib'
2221
import {
2322
enrollTCACertificationAsync,
24-
TCACertificationCheckCompleted,
25-
TCACertificationProgress,
2623
TCACertificationProgressProviderData,
2724
TCACertificationProviderData,
2825
useGetTCACertification,
2926
useGetTCACertificationProgress,
30-
useTCACertificationCheckCompleted,
3127
} from '../../learn-lib'
3228
import { perks } from '../certification-details-modal/certif-details-content/data'
3329
import { PerksSection } from '../perks-section'
@@ -60,7 +56,6 @@ const EnrollmentPage: FC<{}> = () => {
6056
const {
6157
progress,
6258
ready: progressReady,
63-
refetch: refetchProgress,
6459
setCertificateProgress,
6560
}: TCACertificationProgressProviderData = useGetTCACertificationProgress(
6661
profile?.userId as unknown as string,
@@ -70,17 +65,6 @@ const EnrollmentPage: FC<{}> = () => {
7065

7166
const ready: boolean = profileReady && certificationReady && progressReady && !!profile
7267

73-
const firstResourceProgress: TCACertificationProgress['resourceProgresses'][0] | undefined
74-
= progress?.resourceProgresses?.[0]
75-
76-
const {
77-
ready: certCheckReady,
78-
}: TCACertificationCheckCompleted = useTCACertificationCheckCompleted(
79-
firstResourceProgress?.resourceProgressType ?? '',
80-
firstResourceProgress?.resourceProgressId ?? '',
81-
{ enabled: !!firstResourceProgress?.resourceProgressType },
82-
)
83-
8468
if (ready && profile && !userInfo.current) {
8569
userInfo.current = { ...profile }
8670
}
@@ -117,17 +101,8 @@ const EnrollmentPage: FC<{}> = () => {
117101

118102
function closeEnrolledModal(): void {
119103
setIsEnrolledModalOpen(false)
120-
}
121-
122-
useEffect(() => {
123-
if (!certCheckReady || isEnrolledModalOpen) {
124-
return
125-
}
126-
127-
refetchProgress()
128104
navToCertificationDetails()
129-
// eslint-disable-next-line react-hooks/exhaustive-deps
130-
}, [certCheckReady, isEnrolledModalOpen])
105+
}
131106

132107
function renderMainContent(): ReactNode {
133108
return ready ? (

src-ts/tools/learn/course-certificate/certificate-view/CertificateView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const CertificateView: FC<CertificateViewProps> = (props: CertificateViewProps)
9696
elRef={certificateElRef}
9797
provider={course?.resourceProvider.name}
9898
tcHandle={props.profile.handle}
99-
type={certificate?.certificationCategory.track}
99+
type={certificate?.certificationCategory?.track}
100100
userName={userName}
101101
/>
102102
)

src-ts/tools/learn/course-details/course-curriculum/curriculum-summary/CurriculumSummary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const CurriculumSummary: FC<CurriculumSummaryProps> = (props: CurriculumSummaryP
5656
<div className={styles.title}>
5757
{title}
5858
</div>
59-
<ProgressBar progress={progress ?? 0} />
59+
<ProgressBar progress={completed ? 100 : (progress ?? 0)} />
6060
</>
6161
)}
6262

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/tca-certification-completed-modal/TCACertificationCompletedModal.module.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
.completedModal.completedModal {
44
color: $tc-white;
5-
background: url(./bg.jpg) center no-repeat, $tc-grad20;
5+
background: url(./bg.jpg) no-repeat center / cover, $tc-grad20;
6+
max-width: 560px;
67

78
@include ltemd {
89
background: url(./bg-mobile.jpg) 0 0 no-repeat, $tc-grad20;
@@ -30,9 +31,8 @@
3031
}
3132

3233
h2 {
33-
@include ltemd {
34-
font-size: 24px;
35-
line-height: 28px;
36-
}
34+
text-transform: none;
35+
font-size: 26px;
36+
line-height: 32px;
3737
}
3838
}

src-ts/tools/learn/learn-lib/tca-certification-completed-modal/TCACertificationCompletedModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const TCACertificationCompletedModal: FC<TCACertificationCompletedModalProps>
4141
<BaseModal
4242
onClose={handleClose}
4343
open={isOpen}
44-
size='sm'
44+
size='lg'
4545
classNames={{ modal: styles.completedModal, root: styles.modalRoot }}
4646
>
4747
<>
@@ -53,7 +53,7 @@ const TCACertificationCompletedModal: FC<TCACertificationCompletedModalProps>
5353
Certification
5454
!
5555
</h2>
56-
<Button buttonStyle='outline' label='Check it out now!' onClick={handleClick} />
56+
<Button buttonStyle='outline' label='Check it out now!' size='sm' onClick={handleClick} />
5757
</>
5858

5959
</BaseModal>
Loading

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
}

src-ts/tools/learn/welcome/courses-card/CoursesCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const CoursesCard: FC<CoursesCardProps> = (props: CoursesCardProps) => {
9090
<div className={styles.cardHeaderDividerWrap}>
9191
{(isInProgress || isCompleted) && (
9292
<ProgressBar
93-
progress={(props.progress?.courseProgressPercentage ?? 0) / 100}
93+
progress={(isCompleted ? 100 : (props.progress?.courseProgressPercentage ?? 0)) / 100}
9494
track={props.certification.certificationCategory.track}
9595
/>
9696
)}

0 commit comments

Comments
 (0)