Skip to content
Open
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
11 changes: 8 additions & 3 deletions website/src/components/playground-component/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ export const WebsitePlayground = ({ versionData }: WebsitePlaygroundProps) => {
}, [theme]);

const importItem = useImportCommandBarItem();
const imports = Object.keys(versionData.importMap.imports).filter(
(x) => (x.match(/\//g) || []).length < 2, // Don't include sub imports as libraries.
const imports = useMemo(
() =>
Object.keys(versionData.importMap.imports).filter(
(x) => (x.match(/\//g) || []).length < 2, // Don't include sub imports as libraries.
),
[versionData.importMap.imports],
);
const importConfig = useMemo(() => ({ useShim: true }), []);
return (
<StandalonePlayground
{...TypeSpecPlaygroundConfig}
Expand All @@ -40,7 +45,7 @@ export const WebsitePlayground = ({ versionData }: WebsitePlaygroundProps) => {
"@typespec/http-client-python": { debounce: 500, newChangeDiff: true },
"@typespec/http-client-csharp": { debounce: 500, newChangeDiff: true },
}}
importConfig={{ useShim: true }}
importConfig={importConfig}
editorOptions={editorOptions}
footer={<PlaygroundFooter versionData={versionData} />}
fallback={<LoadingSpinner message="Loading libraries..." />}
Expand Down
16 changes: 16 additions & 0 deletions website/src/layouts/base-layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ const initJsIntegrity = computeSriHash("1ds-init.js");
<link rel="og:image" type="image/svg+xml" href={baseUrl("/img/social.svg")} />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>typespec.io</title>
<script is:inline>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

intresting, I only seem to see this when switching from docs -> playground, do you see that in more places?

This seems like duplicate code f rom theme.ts so wondering here if we are maybe not missing an import somewhere or we can combine the logic at least

(function () {
var raw =
localStorage.getItem("theme") ||
(window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
var theme = raw === "dark" ? "dark" : "light";
document.documentElement.setAttribute("data-theme", theme);
if (theme === "dark") {
document.documentElement.classList.remove("light");
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
document.documentElement.classList.add("light");
}
})();
</script>
<script
src="https://consentdeliveryfd.azurefd.net/mscc/lib/v2/wcp-consent.js"
crossorigin="anonymous"
Expand Down
Loading