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
9 changes: 9 additions & 0 deletions src/browser/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let
currentMathjaxRenderLatex = DEFAULT_MATHJAX_RENDER_LATEX,
currentMedia = DEFAULT_MEDIA,
currentRtl = false,
currentTheme = 'light',
currentViewportHeight = 0,
currentViewportWidth = 0,
shouldResetMouse = false;
Expand Down Expand Up @@ -47,6 +48,7 @@ export async function reset(opts = {}) {
lang: DEFAULT_LANG,
mathjax: {},
rtl: !!opts.lang?.startsWith('ar'),
theme: 'light',
pagePadding: DEFAULT_PAGE_PADDING,
media: DEFAULT_MEDIA
};
Expand Down Expand Up @@ -89,6 +91,13 @@ export async function reset(opts = {}) {
currentRtl = opts.rtl;
}

if (opts.theme !== currentTheme) {
const theme = ['light', 'dark'].includes(opts.theme) ? opts.theme : 'light';
document.documentElement.dataset.theme = theme;
awaitNextFrame = true;
currentTheme = theme;
}

opts.lang ??= '';
if (documentLocaleSettings.language !== opts.lang) {
document.documentElement.lang = opts.lang;
Expand Down
2 changes: 1 addition & 1 deletion src/server/wtr-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class WTRConfig {
font-size: 20px;
}
body {
background-color: #ffffff;
background-color: var(--d2l-color-background-base);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be:

background-color: var(--d2l-color-container-base, #ffffff);

On the next line, I might suggest also setting:

color: var(--d2l-color-text-static-standard, #202122);

Copy link
Contributor

Choose a reason for hiding this comment

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

Those are the palette variables that are currently proposed: BrightspaceUI/core#6585.

Copy link
Member

Choose a reason for hiding this comment

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

These --d2l-color-* variables will never actually be defined though right? Like nothing's including core's color palette and can't because this repo can't depend on core.

Copy link
Contributor Author

@GZolla GZolla Feb 18, 2026

Choose a reason for hiding this comment

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

Well, if colors are not included then dark mode would not work either. Since to use dark mode you would need to include it, this just makes the background and color with dark mode work with tests

Copy link
Contributor

Choose a reason for hiding this comment

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

As soon as a component imports colors.js, these variables will be defined.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah true, haha so ironically the testing library can't test its own dark mode

color: var(--d2l-color-ferrite, #202122);
font-family: 'Lato', sans-serif;
letter-spacing: 0.01rem;
Expand Down