Merge pull request #9727 from colinux/fix-dark-theme-blinkblink
Fix thème sombre: ne clignote pas avec le thème clair au moment du render
This commit is contained in:
commit
6c4f6a52cb
3 changed files with 13 additions and 1 deletions
9
app/views/layouts/_setup_theme.html.haml
Normal file
9
app/views/layouts/_setup_theme.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
:javascript
|
||||
function setDarkBeforeRender() {
|
||||
const localScheme = localStorage.getItem('scheme')
|
||||
if (localScheme == 'dark' || (localScheme == 'system' && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
||||
document.documentElement.setAttribute('data-fr-theme', 'dark');
|
||||
}
|
||||
}
|
||||
setDarkBeforeRender();
|
||||
|
|
@ -35,6 +35,7 @@
|
|||
= stylesheet_link_tag 'application', media: 'all'
|
||||
|
||||
= yield(:invisible_captcha_styles)
|
||||
= render partial: 'layouts/setup_theme'
|
||||
|
||||
%body{ { id: content_for(:page_id), class: browser.platform.ios? ? 'ios' : nil, data: { controller: 'turbo number-input' } }.compact }
|
||||
= render partial: 'layouts/skiplinks'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
!!! 5
|
||||
%html{ lang: html_lang, class: yield(:root_class) }
|
||||
%html{ lang: html_lang, data: { fr_scheme: 'system' }, class: yield(:root_class) }
|
||||
%head
|
||||
%meta{ "http-equiv": "Content-Type", content: "text/html; charset=UTF-8" }
|
||||
%meta{ "http-equiv": "X-UA-Compatible", content: "IE=edge" }
|
||||
|
@ -23,6 +23,8 @@
|
|||
= vite_stylesheet_tag 'main', media: 'all'
|
||||
= stylesheet_link_tag 'application', media: 'all'
|
||||
|
||||
= render partial: 'layouts/setup_theme'
|
||||
|
||||
%body{ class: browser.platform.ios? ? 'ios' : nil, data: { controller: 'turbo' } }
|
||||
.page-wrapper
|
||||
%main.m-6
|
||||
|
|
Loading…
Reference in a new issue