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(compat): migrate BCD table to lit #12580

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
23 changes: 17 additions & 6 deletions client/src/document/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { Suspense } from "react";
import { useNavigate } from "react-router-dom";
import useSWR, { mutate } from "swr";

Expand All @@ -9,7 +9,6 @@ import { useDocumentURL, useDecorateCodeExamples, useRunSample } from "./hooks";
import { Doc } from "../../../libs/types/document";
// Ingredients
import { Prose } from "./ingredients/prose";
import { LazyBrowserCompatibilityTable } from "./lazy-bcd-table";
import { SpecificationSection } from "./ingredients/spec-section";

// Misc
Expand Down Expand Up @@ -43,9 +42,13 @@ import { BaselineIndicator } from "./baseline-indicator";
import { PlayQueue } from "../playground/queue";
import { useGleanClick } from "../telemetry/glean-context";
import { CLIENT_SIDE_NAVIGATION } from "../telemetry/constants";
import { Spinner } from "../ui/atoms/spinner";
// import { useUIStatus } from "../ui-context";

// Lazy sub-components
const LazyBrowserCompatibilityTable = React.lazy(
() => import("../lit/compat/lazy-bcd-table")
);
const Toolbar = React.lazy(() => import("./toolbar"));
const MathMLPolyfillMaybe = React.lazy(() => import("./mathml-polyfill"));

Expand Down Expand Up @@ -261,15 +264,23 @@ export function Document(props /* TODO: define a TS interface for this */) {
}

export function RenderDocumentBody({ doc }) {
const locale = useLocale();

return doc.body.map((section, i) => {
if (section.type === "prose") {
return <Prose key={section.value.id} section={section.value} />;
} else if (section.type === "browser_compatibility") {
const { id, title, isH3, query } = section.value;
return (
<LazyBrowserCompatibilityTable
key={`browser_compatibility${i}`}
{...section.value}
/>
<Suspense fallback={<Spinner />} key={`browser_compatibility${i}`}>
<LazyBrowserCompatibilityTable
_id={id}
_title={title}
ish3={isH3}
query={query}
locale={locale}
/>
</Suspense>
);
} else if (section.type === "specifications") {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const HIDDEN_BROWSERS = ["ie"];
* shown. In all other categories, if compat data has info about Deno / Node.js
* those are also shown. Deno is always shown if Node.js is shown.
*/
function gatherPlatformsAndBrowsers(
export function gatherPlatformsAndBrowsers(
category: string,
data: BCD.Identifier,
browserInfo: BCD.Browsers
Expand Down
Loading
Loading