Skip to content
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

feat(curriculum): add scrim-inline custom element #11823

Merged
merged 8 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 8 additions & 0 deletions client/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,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
14 changes: 10 additions & 4 deletions client/src/curriculum/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ 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";

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

export function CurriculumLanding(appProps: HydrationData<any, CurriculumDoc>) {
const doc = useCurriculumDoc(appProps as CurriculumData);
Expand Down Expand Up @@ -135,7 +136,12 @@ function About({ section }) {
<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 fallback={<scrim-inline />}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if threre's an easy way we could wrap ScrimInline programmatically in scrim-inline.ts

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little bit of a chicken and egg problem in that we need to load scrim-inline.ts async in order for it to not bloat our bundle size, but the Suspense stuff all needs to be loaded sync for it to actually work: so the helper function would need to live in another file. If this becomes a common pattern for us, I think we can do that then.

<ScrimInline url={SCRIM_URL} />
</Suspense>
</div>
<p>
Learn our curriculum with high quality, interactive courses from our
partner{" "}
Expand All @@ -149,7 +155,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
Loading