Skip to content
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

Avoid theme flicker in dark mode. #901

Merged
merged 2 commits into from
Feb 8, 2024
Merged
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
1 change: 1 addition & 0 deletions FSharp.Formatting.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<link href="https://fonts.googleapis.com/css2?family=Fira+Code&display=swap" rel="stylesheet">
<script src="https://code.iconify.design/iconify-icon/1.0.7/iconify-icon.min.js"></script>
<link href="{{root}}{{fsdocs-favicon-src}}" rel="icon" sizes="32x32" type="image/png"/>
<script type="application/javascript" src="{{root}}content/fsdocs-theme-set-dark.js"></script>
<link href="{{root}}content/fsdocs-default.css" rel="stylesheet" type="text/css"/>
<link href="{{root}}content/fsdocs-theme.css" rel="stylesheet" type="text/css"/>
{{fsdocs-head-extra}}
Expand Down
5 changes: 5 additions & 0 deletions docs/content/fsdocs-theme-set-dark.js
Original file line number Diff line number Diff line change
@@ -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');
}
3 changes: 0 additions & 3 deletions docs/content/fsdocs-theme-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down