Skip to content

Commit 52e11be

Browse files
authored
Merge pull request #597 from topcoder-platform/TCA-1260_hide-fcc-frame-while-loading
TCA-1260 - Hide the FCC frame while the contents are loading -> dev
2 parents 376514c + bd1a81a commit 52e11be

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src-ts/tools/learn/free-code-camp/FreeCodeCamp.module.scss

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@
4848
}
4949
}
5050

51+
.course-iframe {
52+
position: relative;
53+
display: flex;
54+
flex: 1 1 auto;
55+
width: 100%;
56+
}
57+
58+
.course-frame-loader {
59+
margin-left: $space-xxxxl;
60+
margin-right: $space-xxxxl;
61+
width: calc(100% - 2 * $space-xxxxl);
62+
63+
+ iframe {
64+
opacity: 0;
65+
visibility: hidden;
66+
}
67+
}
68+
5169
.wrapBreadcrumb {
5270
position: relative;
5371

@@ -66,4 +84,4 @@
6684
bottom: $space-lg;
6785
}
6886
}
69-
}
87+
}

src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ const FreeCodeCamp: FC<{}> = () => {
7676
= useState(textFormatGetSafeString(routeParams.module))
7777
const [lessonParam, setLessonParam]: [string, Dispatch<SetStateAction<string>>]
7878
= useState(textFormatGetSafeString(routeParams.lesson))
79+
const [fccFrameReady, setFccFrameReady]: [boolean, Dispatch<SetStateAction<boolean>>]
80+
= useState(false)
7981

8082
const {
8183
certificationProgress: certificateProgress,
@@ -205,6 +207,8 @@ const FreeCodeCamp: FC<{}> = () => {
205207
}
206208

207209
const handleFccLessonReady: (lessonPath: string) => void = useCallback((lessonPath: string) => {
210+
// mark fcc frame as being ready once we get the first "lesson ready"
211+
setFccFrameReady(true)
208212

209213
const [nLessonPath, modulePath, coursePath]: Array<string> = lessonPath.replace(/\/$/, '')
210214
.split('/')
@@ -622,12 +626,16 @@ const FreeCodeCamp: FC<{}> = () => {
622626
onNavigate={handleNavigate}
623627
/>
624628
<hr />
625-
<FccFrame
626-
lesson={lesson}
627-
onFccLessonChange={handleFccLessonReady}
628-
onFccLessonComplete={handleFccLessonComplete}
629-
onFccLastLessonNavigation={handleFccLastLessonNavigation}
630-
/>
629+
630+
<div className={styles['course-iframe']}>
631+
<LoadingSpinner className={styles['course-frame-loader']} hide={fccFrameReady} />
632+
<FccFrame
633+
lesson={lesson}
634+
onFccLessonChange={handleFccLessonReady}
635+
onFccLessonComplete={handleFccLessonComplete}
636+
onFccLastLessonNavigation={handleFccLastLessonNavigation}
637+
/>
638+
</div>
631639
</div>
632640
</div>
633641
)}

0 commit comments

Comments
 (0)