Skip to content

Commit 8b2a59e

Browse files
authored
chore(mode): test of mode switcher to reduce light flash (#4699)
* chore(mode): test of mode switcher to reduce light flash * fix(theme-selector): add meta tag for color-scheme * fix(theme-selector): simplify function
1 parent eed961b commit 8b2a59e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • packages/documentation-framework/templates

packages/documentation-framework/templates/html.ejs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
<!DOCTYPE html>
22
<html lang="en-US">
33
<head>
4+
<script>
5+
{
6+
try {
7+
let mode = localStorage.getItem('theme-preference');
8+
if (!mode || mode === 'system') {
9+
mode = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
10+
}
11+
if (mode === 'dark') {
12+
document.documentElement.classList.add('pf-v6-theme-dark');
13+
}
14+
} catch (e) {}
15+
}
16+
</script>
417
<meta charset="utf-8">
518
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
619
<meta name="description" content="PatternFly is Red Hat's open source design system. It consists of components, documentation, and code for building enterprise applications at scale.">
@@ -12,6 +25,7 @@
1225
<link rel="manifest" href="/assets/manifest.json">
1326
<meta name="mobile-web-app-capable" content="yes">
1427
<meta name="theme-color" content="#151515">
28+
<meta name="color-scheme" content="light dark">
1529
<meta name="application-name" content="PatternFly docs">
1630
<%= htmlWebpackPlugin.tags.headTags %>
1731
</head>

0 commit comments

Comments
 (0)