Skip to content

Commit c283b71

Browse files
Merge pull request #381 from topcoder-platform/TCA-516_optimize-certificate-for-social
TCA-516 optimize certificate for social -> dev
2 parents 749ca2f + 0cc797a commit c283b71

File tree

11 files changed

+73
-26
lines changed

11 files changed

+73
-26
lines changed

src-ts/lib/styles/mixins/_layout.mixins.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
width: 100%;
2323
}
2424

25+
@mixin socialPreviewImg {
26+
width: 1200px;
27+
height: 630px;
28+
}
29+
2530
@mixin scrollbar {
2631
// firefox's solution for "customizing" scrollbars
2732
& {

src-ts/tools/learn/course-certificate/certificate-view/CertificateView.module.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
background: #fff;
5151

5252
box-shadow: 0 20px 36px rgba($tc-black, 0.22);
53+
54+
&:global(.large-container) {
55+
aspect-ratio: unset;
56+
@include socialPreviewImg;
57+
}
5358
}
5459

5560
.share-btn:global(.button.icon) {
@@ -72,4 +77,4 @@
7277
svg {
7378
@include icon-xxl;
7479
}
75-
}
80+
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import classNames from 'classnames'
12
import html2canvas from 'html2canvas'
23
import { FC, MutableRefObject, useEffect, useMemo, useRef } from 'react'
34
import { NavigateFunction, useNavigate } from 'react-router-dom'
@@ -26,12 +27,15 @@ import { Certificate } from './certificate'
2627
import styles from './CertificateView.module.scss'
2728
import { useCertificateScaling } from './use-certificate-scaling.hook'
2829

30+
export type CertificateViewStyle = 'large-container' | undefined
31+
2932
interface CertificateViewProps {
3033
certification: string,
3134
hideActions?: boolean,
3235
onCertificationNotCompleted: () => void
3336
profile: UserProfile,
3437
provider: string,
38+
viewStyle: CertificateViewStyle
3539
}
3640

3741
const CertificateView: FC<CertificateViewProps> = (props: CertificateViewProps) => {
@@ -169,7 +173,10 @@ const CertificateView: FC<CertificateViewProps> = (props: CertificateViewProps)
169173
/>
170174
</div>
171175
)}
172-
<div className={styles['certificate-wrap']} ref={certificateWrapRef}>
176+
<div
177+
className={classNames(styles['certificate-wrap'], props.viewStyle)}
178+
ref={certificateWrapRef}
179+
>
173180
<Certificate
174181
course={course?.title}
175182
userName={userName}
@@ -178,6 +185,7 @@ const CertificateView: FC<CertificateViewProps> = (props: CertificateViewProps)
178185
completedDate={completedCertificate?.completedDate ?? ''}
179186
elRef={certificateElRef}
180187
type={certificate?.trackType}
188+
viewStyle={props.viewStyle}
181189
/>
182190
</div>
183191
{!props.hideActions && (

src-ts/tools/learn/course-certificate/certificate-view/certificate/Certificate.module.scss

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
padding: calc($space-mx + $space-lg);
1212
display: flex;
1313
flex-direction: column;
14+
flex: 1;
15+
16+
&-inner {
17+
max-width: 385px;
18+
flex: 1;
19+
display: flex;
20+
flex-direction: column;
21+
}
22+
23+
.wrap:global(.large-container) & {
24+
padding-left: calc($space-mx + $space-mxx);
25+
}
1426

1527
h2 {
1628
color: $blue-160;
@@ -30,7 +42,7 @@
3042
font-size: 80px;
3143
line-height: 72px;
3244
}
33-
45+
3446
&:global(.theme-dev) {
3547
.username {
3648
color: $tc-dev-track-color;
@@ -97,6 +109,7 @@
97109

98110
display: flex;
99111
flex-direction: column;
112+
max-width: 500px;
100113
}
101114

102115
.course-card {
@@ -147,7 +160,7 @@
147160
margin-top: $space-sm;
148161
display: flex;
149162
justify-content: flex-end;
150-
163+
151164
svg {
152165
display: block;
153166
height: 16px;

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ interface CertificateProps {
1919
tcHandle?: string
2020
type?: LearnCertificateTrackType
2121
userName?: string
22+
viewStyle?: 'large-container'
2223
}
2324

2425
const Certificate: FC<CertificateProps> = (props: CertificateProps) => {
@@ -32,27 +33,29 @@ const Certificate: FC<CertificateProps> = (props: CertificateProps) => {
3233
return (
3334
<div
3435
{...elementSelector}
35-
className={styles['wrap']}
36+
className={classNames(styles['wrap'], props.viewStyle)}
3637
ref={props.elRef}
3738
>
3839
<div className={classNames(styles['details'], `theme-${certificateType.toLowerCase()}`)}>
39-
<h2 className='details grad'>Topcoder Academy</h2>
40-
<h3>Certificate of Course Completion</h3>
41-
<h1 className={classNames(styles['username'], 'grad')}>
42-
{props.userName}
43-
</h1>
44-
<div className={classNames('large-subtitle', styles['tc-handle'])}>
45-
<span>Topcoder Handle: </span>
46-
<span>{props.tcHandle}</span>
47-
</div>
48-
<div className={styles['logos']}>
49-
<div className={styles['logo']}>
50-
<TcLogoSvg />
51-
</div>
52-
<div className={styles['divider']} />
53-
<div className={styles['logo']}>
54-
<TcAcademyLogoSvg />
40+
<div className={styles['details-inner']}>
41+
<h2 className='details grad'>Topcoder Academy</h2>
42+
<h3>Certificate of Course Completion</h3>
43+
<h1 className={classNames(styles['username'], 'grad')}>
44+
{props.userName}
45+
</h1>
46+
<div className={classNames('large-subtitle', styles['tc-handle'])}>
47+
<span>Topcoder Handle: </span>
48+
<span>{props.tcHandle}</span>
5549
</div>
50+
<div className={styles['logos']}>
51+
<div className={styles['logo']}>
52+
<TcLogoSvg />
53+
</div>
54+
<div className={styles['divider']} />
55+
<div className={styles['logo']}>
56+
<TcAcademyLogoSvg />
57+
</div>
58+
</div>
5659
</div>
5760
</div>
5861
<div className={styles['badges']}>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as CertificateView } from './CertificateView'
2+
export type { CertificateViewStyle } from './CertificateView'

src-ts/tools/learn/course-certificate/user-certificate/UserCertificate.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import { Dispatch, FC, MutableRefObject, SetStateAction, useEffect, useLayoutEffect, useRef, useState } from 'react'
2-
import { Params, useParams } from 'react-router-dom'
2+
import { Params, useParams, useSearchParams } from 'react-router-dom'
33

44
import {
55
LoadingSpinner,
66
profileGetAsync,
77
UserProfile
88
} from '../../../../lib'
9-
import CertificateView from '../certificate-view/CertificateView'
9+
import { getViewStyleParamKey } from '../../learn.routes'
10+
import { CertificateView, CertificateViewStyle } from '../certificate-view'
1011

1112
import styles from './UserCertificate.module.scss'
1213

1314
const UserCertificate: FC<{}> = () => {
1415

1516
const wrapElRef: MutableRefObject<HTMLElement | any> = useRef()
1617
const routeParams: Params<string> = useParams()
18+
const [queryParams]: [URLSearchParams, any] = useSearchParams()
19+
1720
const [profile, setProfile]: [
1821
UserProfile | undefined,
1922
Dispatch<SetStateAction<UserProfile | undefined>>
@@ -59,6 +62,7 @@ const UserCertificate: FC<{}> = () => {
5962
provider={providerParam}
6063
onCertificationNotCompleted={() => { }}
6164
hideActions
65+
viewStyle={queryParams.get(getViewStyleParamKey()) as CertificateViewStyle}
6266
/>
6367
</div>
6468
)}

src-ts/tools/learn/learn-config/learn-config.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export interface LearnConfigModel {
22
API: string
3+
CERT_ALT_PARAMS: { [key: string]: string }
34
CERT_DOMAIN: string
45
CERT_ELEMENT_SELECTOR: {
56
attribute: string,

src-ts/tools/learn/learn-config/learn.default.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { LearnConfigModel } from './learn-config.model'
22

33
export const LearnConfigDefault: LearnConfigModel = {
44
API: 'http://localhost:3001/v5/learning-paths',
5+
CERT_ALT_PARAMS: {
6+
'view-style': 'large-container',
7+
},
58
CERT_DOMAIN: 'https://certificate.topcoder-dev.com',
69
CERT_ELEMENT_SELECTOR: {
710
attribute: 'data-id',

src-ts/tools/learn/learn-lib/user-certifications-provider/user-certifications-functions/user-certification-progress.store.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { logInfo } from '../../../../../lib'
21
import { LearnConfig } from '../../../learn-config'
32
import { getUserCertificateUrl } from '../../../learn.routes'
43
import { learnUrlGet, learnXhrGetAsync, learnXhrPostAsync, learnXhrPutAsync } from '../../functions'
@@ -16,15 +15,15 @@ export function completeCourse(
1615
): Promise<LearnUserCertificationProgress> {
1716

1817
// construct the certificate params
18+
const certificateAlternateParams: { [key: string]: string } = LearnConfig.CERT_ALT_PARAMS
1919
const certificateElement: string = `[${LearnConfig.CERT_ELEMENT_SELECTOR.attribute}=${LearnConfig.CERT_ELEMENT_SELECTOR.value}]`
2020
const certificateUrl: string = getUserCertificateUrl(provider, certification, handle)
2121

22-
logInfo(`Completing course w certificate URL = ${certificateUrl}`)
23-
2422
return updateAsync(
2523
certificationProgressId,
2624
UserCertificationUpdateProgressActions.completeCertificate,
2725
{
26+
certificateAlternateParams,
2827
certificateElement,
2928
certificateUrl,
3029
}

0 commit comments

Comments
 (0)