Skip to content

TCA-1090 grow to fit certificate -> dev #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
.enrolledModal {
color: $tc-white;
background: url(./bg.jpg) center no-repeat, $tc-grad20;
max-width: 560px;

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

h2 {
@include ltemd {
font-size: 24px;
line-height: 28px;
}
text-transform: none;
font-size: 26px;
line-height: 32px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const EnrolledModal: FC<EnrolledModalProps> = (props: EnrolledModalProps) => {
<BaseModal
onClose={props.onClose}
open={isOpen}
size='sm'
size='lg'
classNames={{ modal: styles.enrolledModal, root: styles.modalRoot }}
>
<>
Expand All @@ -33,6 +33,7 @@ const EnrolledModal: FC<EnrolledModalProps> = (props: EnrolledModalProps) => {
<Button
buttonStyle='outline'
label='Go to the certification details'
size='sm'
onClick={props.onClose}
/>
</>
Expand Down
Binary file modified src-ts/tools/learn/certification-details/enrolled-modal/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
SetStateAction,
useCallback,
useContext,
useEffect,
useLayoutEffect,
useRef,
useState,
Expand All @@ -21,13 +20,10 @@ import {
} from '../../../../lib'
import {
enrollTCACertificationAsync,
TCACertificationCheckCompleted,
TCACertificationProgress,
TCACertificationProgressProviderData,
TCACertificationProviderData,
useGetTCACertification,
useGetTCACertificationProgress,
useTCACertificationCheckCompleted,
} from '../../learn-lib'
import { perks } from '../certification-details-modal/certif-details-content/data'
import { PerksSection } from '../perks-section'
Expand Down Expand Up @@ -60,7 +56,6 @@ const EnrollmentPage: FC<{}> = () => {
const {
progress,
ready: progressReady,
refetch: refetchProgress,
setCertificateProgress,
}: TCACertificationProgressProviderData = useGetTCACertificationProgress(
profile?.userId as unknown as string,
Expand All @@ -70,17 +65,6 @@ const EnrollmentPage: FC<{}> = () => {

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

const firstResourceProgress: TCACertificationProgress['resourceProgresses'][0] | undefined
= progress?.resourceProgresses?.[0]

const {
ready: certCheckReady,
}: TCACertificationCheckCompleted = useTCACertificationCheckCompleted(
firstResourceProgress?.resourceProgressType ?? '',
firstResourceProgress?.resourceProgressId ?? '',
{ enabled: !!firstResourceProgress?.resourceProgressType },
)

if (ready && profile && !userInfo.current) {
userInfo.current = { ...profile }
}
Expand Down Expand Up @@ -117,17 +101,8 @@ const EnrollmentPage: FC<{}> = () => {

function closeEnrolledModal(): void {
setIsEnrolledModalOpen(false)
}

useEffect(() => {
if (!certCheckReady || isEnrolledModalOpen) {
return
}

refetchProgress()
navToCertificationDetails()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [certCheckReady, isEnrolledModalOpen])
}

function renderMainContent(): ReactNode {
return ready ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const CertificateView: FC<CertificateViewProps> = (props: CertificateViewProps)
elRef={certificateElRef}
provider={course?.resourceProvider.name}
tcHandle={props.profile.handle}
type={certificate?.certificationCategory.track}
type={certificate?.certificationCategory?.track}
userName={userName}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const CurriculumSummary: FC<CurriculumSummaryProps> = (props: CurriculumSummaryP
<div className={styles.title}>
{title}
</div>
<ProgressBar progress={progress ?? 0} />
<ProgressBar progress={completed ? 100 : (progress ?? 0)} />
</>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
display: flex;

background: $tc-grad15;
overflow: hidden;
}

.content-wrap {
Expand All @@ -29,6 +30,8 @@
display: flex;
flex-direction: column;
align-items: center;
z-index: 1;
position: relative;

gap: $space-sm;

Expand All @@ -52,7 +55,7 @@
.certificate-wrap {
aspect-ratio: $tca-certif-aspect-ratio;
width: 100%;
max-width: 880px;
max-width: 1216px;
position: relative;

&:global(.large-container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ const CertificatePageLayout: FC<CertificatePageLayoutProps> = (props: Certificat
const certificateWrapRef: MutableRefObject<HTMLDivElement | any> = useRef()
const navigateBack: NavigateBackFunction = useNavigateBack()

useCertificateScaling(props.isReady ? certificateWrapRef : undefined, 880, 880)
useCertificateScaling(
props.isReady ? certificateWrapRef : undefined,
880,
880,
viewStyle ? 1 : Math.min(),
)

const handleBackBtnClick: () => void = useCallback(() => {
navigateBack(props.fallbackBackUrl ?? '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

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

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

h2 {
@include ltemd {
font-size: 24px;
line-height: 28px;
}
text-transform: none;
font-size: 26px;
line-height: 32px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TCACertificationCompletedModal: FC<TCACertificationCompletedModalProps>
<BaseModal
onClose={handleClose}
open={isOpen}
size='sm'
size='lg'
classNames={{ modal: styles.completedModal, root: styles.modalRoot }}
>
<>
Expand All @@ -53,7 +53,7 @@ const TCACertificationCompletedModal: FC<TCACertificationCompletedModalProps>
Certification
!
</h2>
<Button buttonStyle='outline' label='Check it out now!' onClick={handleClick} />
<Button buttonStyle='outline' label='Check it out now!' size='sm' onClick={handleClick} />
</>

</BaseModal>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export function useCertificateScaling(
certificateRef?: MutableRefObject<HTMLDivElement | undefined>,
originalSizeLg: number = 1250,
originalSizeSm: number = 975,
scaleLimit: number = 1,
): void {

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

window.addEventListener('resize', handleResize, false)
handleResize()
return () => window.removeEventListener('resize', handleResize, false)
}, [certificateRef, originalSizeLg, originalSizeSm])
}, [certificateRef, originalSizeLg, originalSizeSm, scaleLimit])
}
2 changes: 1 addition & 1 deletion src-ts/tools/learn/welcome/courses-card/CoursesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const CoursesCard: FC<CoursesCardProps> = (props: CoursesCardProps) => {
<div className={styles.cardHeaderDividerWrap}>
{(isInProgress || isCompleted) && (
<ProgressBar
progress={(props.progress?.courseProgressPercentage ?? 0) / 100}
progress={(isCompleted ? 100 : (props.progress?.courseProgressPercentage ?? 0)) / 100}
track={props.certification.certificationCategory.track}
/>
)}
Expand Down