Skip to content

docs(website): correct theme color blink when playground is initialized #4870

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

Merged
merged 1 commit into from
Apr 26, 2022
Merged
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
5 changes: 5 additions & 0 deletions packages/website/src/components/editor/useSandboxServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {

import { sandboxSingleton } from './loadSandbox';
import { editorEmbedId } from './EditorEmbed';
import { useColorMode } from '@docusaurus/theme-common';

export interface SandboxServicesProps {
readonly jsx?: boolean;
Expand All @@ -34,6 +35,7 @@ export const useSandboxServices = (
): Error | SandboxServices | undefined => {
const [services, setServices] = useState<Error | SandboxServices>();
const [loadedTs, setLoadedTs] = useState<string>(props.ts);
const { isDarkTheme } = useColorMode();
Copy link
Member

Choose a reason for hiding this comment

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

isDarkTheme is deprecated—you should see a warning in the console in development (it probably is not transparent enough, considering most people don't develop with their consoles open all the time). You should use const { colorMode } = useColorMode() instead


useEffect(() => {
if (props.ts !== loadedTs) {
Expand Down Expand Up @@ -74,6 +76,9 @@ export const useSandboxServices = (
main,
ts,
);
sandboxInstance.monaco.editor.setTheme(
isDarkTheme ? 'vs-dark' : 'vs-light',
);

const libMap = await sandboxInstance.tsvfs.createDefaultMapFromCDN(
sandboxInstance.getCompilerOptions(),
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy