From 90d7cfa6f5f7c67d15c555a485774c5f73db9e17 Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 8 Feb 2024 09:39:31 +0100 Subject: [PATCH 1/2] Avoid theme flicker in dark mode. --- FSharp.Formatting.sln | 1 + docs/_template.html | 1 + docs/content/fsdocs-theme-set-dark.js | 5 +++++ docs/content/fsdocs-theme-toggle.js | 3 --- 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 docs/content/fsdocs-theme-set-dark.js diff --git a/FSharp.Formatting.sln b/FSharp.Formatting.sln index 14dbe4c4f..b57604b97 100644 --- a/FSharp.Formatting.sln +++ b/FSharp.Formatting.sln @@ -125,6 +125,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{FAD5 docs\content\fsdocs-search.js = docs\content\fsdocs-search.js docs\content\fsdocs-tips.js = docs\content\fsdocs-tips.js docs\content\fsdocs-theme-toggle.js = docs\content\fsdocs-theme-toggle.js + docs\content\fsdocs-theme-set-dark.js = docs\content\fsdocs-theme-set-dark.js EndProjectSection EndProject Global diff --git a/docs/_template.html b/docs/_template.html index 2f1910216..9b6ac0aa3 100644 --- a/docs/_template.html +++ b/docs/_template.html @@ -21,6 +21,7 @@ + {{fsdocs-head-extra}} diff --git a/docs/content/fsdocs-theme-set-dark.js b/docs/content/fsdocs-theme-set-dark.js new file mode 100644 index 000000000..b6eeaba3f --- /dev/null +++ b/docs/content/fsdocs-theme-set-dark.js @@ -0,0 +1,5 @@ +const prefersDark = window.matchMedia("@media (prefers-color-scheme: dark)").matches; +let currentTheme = localStorage.getItem('theme') ?? (prefersDark ? 'dark' : 'light'); +if (currentTheme === 'dark') { + window.document.documentElement.setAttribute("data-theme", 'dark'); +} diff --git a/docs/content/fsdocs-theme-toggle.js b/docs/content/fsdocs-theme-toggle.js index 5254e3ad2..5e32f9e3c 100644 --- a/docs/content/fsdocs-theme-toggle.js +++ b/docs/content/fsdocs-theme-toggle.js @@ -2,9 +2,6 @@ const prefersDark = window.matchMedia("@media (prefers-color-scheme: dark)").matches; let currentTheme = localStorage.getItem('theme') ?? (prefersDark ? 'dark' : 'light'); -if (currentTheme === 'dark') { - window.document.documentElement.setAttribute("data-theme", 'dark'); -} export class ThemeToggle extends LitElement { static properties = { From 7b84ed27b87964d0a9678b6291cc447fcf9d726c Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 8 Feb 2024 09:42:21 +0100 Subject: [PATCH 2/2] Add changelog entry --- RELEASE_NOTES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 033820f45..ef1abf52c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,10 @@ # Changelog +## 20.0.0-beta-002 - 2024-02-08 + +### Fixed +* Avoid theme flicker in dark mode. [#901](https://github.com/fsprojects/FSharp.Formatting/pull/901) + ## 20.0.0-beta-001 - 2024-01-31 ### Changed