Skip to content

Commit

Permalink
feat(curriculum): add scrim-inline custom element (#11823)
Browse files Browse the repository at this point in the history
use on curriculum homepage within react
also update the design a little bit
add id to glean ping
  • Loading branch information
LeoMcA authored Sep 24, 2024
1 parent d4c742f commit 8e3a00f
Show file tree
Hide file tree
Showing 17 changed files with 424 additions and 261 deletions.
8 changes: 8 additions & 0 deletions client/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ function config(webpackEnv) {
// match the requirements. When no loader matches it will fall
// back to the "file" loader at the end of the loader list.
oneOf: [
{
resourceQuery: /raw/,
type: "asset/source",
},
{
resourceQuery: /url/,
type: "asset/resource",
},
{
test: [/\.avif$/, /\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
type: "asset/resource",
Expand Down
Binary file removed client/public/assets/curriculum/scrim.png
Binary file not shown.
Binary file added client/src/assets/curriculum/scrim-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/curriculum/scrim-play.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions client/src/curriculum/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@
list-style-type: disc;
margin: 0.5rem 0;
}

scrim-inline {
display: block;
height: 14.25rem;
width: 22rem;
}
}
}
}
27 changes: 26 additions & 1 deletion client/src/curriculum/landing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,40 @@
grid-area: arrow;
}

.scrim {
.scrim-wrapper {
display: flex;
flex-direction: column;
grid-area: scrim;
justify-content: center;
justify-self: center;
margin-top: 1rem;
max-width: 24rem;

@media (min-width: $screen-lg) {
justify-self: end;
margin-top: 0;
}

.scrim-border {
background-image: var(--curriculum-scrim-bg);
background-position: bottom right;
background-repeat: no-repeat;
height: 16rem;
width: 100%;
}

scrim-inline {
background: #000;
display: block;
height: 14.25rem;
max-width: calc(100vw - var(--gutter) * 2);
width: 22rem;
}

p {
margin: 0;
padding: 1rem 0;
}
}
}
}
Expand Down
15 changes: 11 additions & 4 deletions client/src/curriculum/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import { CurriculumDoc, CurriculumData } from "../../../libs/types/curriculum";
import { ModulesListList } from "./modules-list";
import { useCurriculumDoc } from "./utils";
import { RenderCurriculumBody } from "./body";
import { useMemo } from "react";
import { lazy, Suspense, useMemo } from "react";
import { DisplayH2 } from "../document/ingredients/utils";
import { CurriculumLayout } from "./layout";

import "./index.scss";
import "./landing.scss";
import { ProseSection } from "../../../libs/types/document";
import { PartnerBanner } from "./partner-banner";
import { ScrimIframe } from "./scrim";
import { useIsServer } from "../hooks";

const ScrimInline = lazy(() => import("./scrim-inline"));

export function CurriculumLanding(appProps: HydrationData<any, CurriculumDoc>) {
const doc = useCurriculumDoc(appProps as CurriculumData);
Expand Down Expand Up @@ -129,13 +131,18 @@ const SCRIM_URL = "https://v2.scrimba.com/s06icdv?via=mdn";
function About({ section }) {
const { title, content, id } = section.value;
const html = useMemo(() => ({ __html: content }), [content]);
const isServer = useIsServer();

return (
<section key={id} className="landing-about-container">
<div className="landing-about">
<DisplayH2 id={id} title={title} />
<div className="about-content" dangerouslySetInnerHTML={html}></div>
<div className="arrow"></div>
<ScrimIframe url={SCRIM_URL}>
<section className="scrim-wrapper">
<div className="scrim-border">
<Suspense>{!isServer && <ScrimInline url={SCRIM_URL} />}</Suspense>
</div>
<p>
Learn our curriculum with high quality, interactive courses from our
partner{" "}
Expand All @@ -149,7 +156,7 @@ function About({ section }) {
</a>
{" !"}
</p>
</ScrimIframe>
</section>
</div>
</section>
);
Expand Down
6 changes: 6 additions & 0 deletions client/src/curriculum/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import { PrevNext } from "./prev-next";
import { RenderCurriculumBody } from "./body";
import { CurriculumLayout } from "./layout";
import { topic2css, useCurriculumDoc } from "./utils";
import { useEffect } from "react";

import "./index.scss";
import "./module.scss";

export function CurriculumModule(props: HydrationData<any, CurriculumDoc>) {
const doc = useCurriculumDoc(props as CurriculumData);

useEffect(() => {
import("./scrim-inline");
}, []);

return (
<CurriculumLayout
doc={doc}
Expand Down
Loading

0 comments on commit 8e3a00f

Please sign in to comment.