From 2610f037c167d5bf90b6840992361f68a452f1ac Mon Sep 17 00:00:00 2001 From: pamparam Date: Sun, 16 Mar 2025 18:26:47 +0300 Subject: [PATCH 01/10] fixed show dark mode --- templates/development.php | 40 +++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/templates/development.php b/templates/development.php index 669dc1e..c2ca0a3 100644 --- a/templates/development.php +++ b/templates/development.php @@ -1,13 +1,15 @@ - var theme = getCookie('yii-exception-theme'); + const themeMedia = window.matchMedia('(prefers-color-scheme: dark)'); + const theme = getCookie('yii-exception-theme'); if (theme) { + applyTheme(theme); + } else { + applyTheme((themeMedia.matches ? 'dark-theme' : 'light-theme')); + } + + themeMedia.addEventListener('change', event => { + if (!theme) { + applyTheme((event.matches ? 'dark-theme' : 'light-theme')); + } + }); + + function applyTheme(theme){ document.body.classList.add(theme); } + function setCookie(name, value) { - var date = new Date(2100, 0, 1); - var expires = "; expires=" + date.toUTCString(); + const date = new Date(2100, 0, 1); + const expires = "; expires=" + date.toUTCString(); document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function getCookie(name) { - var nameEQ = name + "="; - var ca = document.cookie.split(';'); + const nameEQ = name + "="; + const ca = document.cookie.split(';'); - for (var i=0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0)==' ') c = c.substring(1,c.length); - if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + for (let i=0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === ' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length); } return null; From d089db7c8fade34d8c26785fd6acf4c5305fca30 Mon Sep 17 00:00:00 2001 From: pamparam Date: Mon, 17 Mar 2025 17:01:46 +0300 Subject: [PATCH 02/10] remove old classes theme --- templates/development.php | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/development.php b/templates/development.php index c2ca0a3..d684f4a 100644 --- a/templates/development.php +++ b/templates/development.php @@ -381,6 +381,7 @@ function enableLightTheme() { }); function applyTheme(theme){ + document.body.classList.remove('dark-theme', 'light-theme'); document.body.classList.add(theme); } From fb7129907cfcf686483d056291676f79f83bca29 Mon Sep 17 00:00:00 2001 From: pamparam Date: Mon, 17 Mar 2025 17:11:05 +0300 Subject: [PATCH 03/10] remove prefers-color-scheme: dark from css --- templates/development.css | 72 --------------------------------------- 1 file changed, 72 deletions(-) diff --git a/templates/development.css b/templates/development.css index a06d841..7064f65 100644 --- a/templates/development.css +++ b/templates/development.css @@ -873,77 +873,5 @@ main { display: inline; } -@media (prefers-color-scheme: dark) { - body:not(.light-theme) { - --page-bg-color: rgba(46,46,46, 0.9); - --page-text-color: #fff; - --icon-color: #989898; - --icon-hover-color: #fff; - } - - body:not(.light-theme) header { - --header-bg-color: #2e2e2e; - --previous-text-color: rgba(255, 255, 255, 0.8); - --previous-arrow-color: #fff; - } - - body:not(.light-theme) .exception-card { - --exception-card-bg-color: #222; - --exception-card-border-color: #591e15; - --exception-class-text-color: #fff; - --exception-class-friendly-text-color: rgba(255, 255, 255, 0.5); - --exception-class-friendly-link-color: #E57373; - --exception-message-text-color: rgba(255, 255, 255, 0.8); - } - - body:not(.light-theme) header .solution { - --text-color: rgba(255, 255, 255, 0.8); - --link-color: #03a9f4; - --link-hover-color: #39b9f3; - --blockquote-text-color: #999; - --blockquote-border-color: #484c50; - --code-bg-color: #2d333b; - --pre-bg-color: #2d333b; - --table-border-color: #484c50; - --separator-color: #484c50; - } - - body:not(.light-theme) .call-stack { - --bg-color: #1e1e1e; - --border-color: transparent; - --box-shadow: 0 13px 20px rgba(0, 0, 0, 0.25); - --link-color: rgba(255, 255, 255, 0.5); - --error-line-bg-color: #422c2c; - --hover-line-bg-color: #292929; - --element-wrap-border-color: #141414; - --element-wrap-text-color: #fff; - --element-wrap-hover-text-color: #9cdcfe; - --vendor-bg-color: rgba(46,46,46, 0.9); - --vendor-border-color: #666; - --vendor-state-bg-color: #666; - --vendor-content-bg-color: rgba(46,46,46, 0.9); - } - - body:not(.light-theme) .hljs { - --hljs-text-color: #fff; - --hljs-comment-text-color: #999; - --hljs-keyword-text-color: #88aece; - --hljs-attribute-text-color: #c59bc1; - --hljs-name-text-color: #f08d49; - --hljs-string-text-color: #b5bd68; - --hljs-code-text-color: #cccccc; - --hljs-delition-text-color: #de7176; - --hljs-addition-text-color: #76c490; - } - - body:not(.light-theme) #dark-mode { - display: none; - } - - body:not(.light-theme) #light-mode { - display: inline; - } -} - /* end dark-theme */ From 4d0c08006a1dd491bba6be989dbb8474d4828a49 Mon Sep 17 00:00:00 2001 From: pamparam Date: Mon, 17 Mar 2025 17:20:50 +0300 Subject: [PATCH 04/10] returned prefers-color-scheme: dark --- templates/development.css | 72 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/templates/development.css b/templates/development.css index 7064f65..a06d841 100644 --- a/templates/development.css +++ b/templates/development.css @@ -873,5 +873,77 @@ main { display: inline; } +@media (prefers-color-scheme: dark) { + body:not(.light-theme) { + --page-bg-color: rgba(46,46,46, 0.9); + --page-text-color: #fff; + --icon-color: #989898; + --icon-hover-color: #fff; + } + + body:not(.light-theme) header { + --header-bg-color: #2e2e2e; + --previous-text-color: rgba(255, 255, 255, 0.8); + --previous-arrow-color: #fff; + } + + body:not(.light-theme) .exception-card { + --exception-card-bg-color: #222; + --exception-card-border-color: #591e15; + --exception-class-text-color: #fff; + --exception-class-friendly-text-color: rgba(255, 255, 255, 0.5); + --exception-class-friendly-link-color: #E57373; + --exception-message-text-color: rgba(255, 255, 255, 0.8); + } + + body:not(.light-theme) header .solution { + --text-color: rgba(255, 255, 255, 0.8); + --link-color: #03a9f4; + --link-hover-color: #39b9f3; + --blockquote-text-color: #999; + --blockquote-border-color: #484c50; + --code-bg-color: #2d333b; + --pre-bg-color: #2d333b; + --table-border-color: #484c50; + --separator-color: #484c50; + } + + body:not(.light-theme) .call-stack { + --bg-color: #1e1e1e; + --border-color: transparent; + --box-shadow: 0 13px 20px rgba(0, 0, 0, 0.25); + --link-color: rgba(255, 255, 255, 0.5); + --error-line-bg-color: #422c2c; + --hover-line-bg-color: #292929; + --element-wrap-border-color: #141414; + --element-wrap-text-color: #fff; + --element-wrap-hover-text-color: #9cdcfe; + --vendor-bg-color: rgba(46,46,46, 0.9); + --vendor-border-color: #666; + --vendor-state-bg-color: #666; + --vendor-content-bg-color: rgba(46,46,46, 0.9); + } + + body:not(.light-theme) .hljs { + --hljs-text-color: #fff; + --hljs-comment-text-color: #999; + --hljs-keyword-text-color: #88aece; + --hljs-attribute-text-color: #c59bc1; + --hljs-name-text-color: #f08d49; + --hljs-string-text-color: #b5bd68; + --hljs-code-text-color: #cccccc; + --hljs-delition-text-color: #de7176; + --hljs-addition-text-color: #76c490; + } + + body:not(.light-theme) #dark-mode { + display: none; + } + + body:not(.light-theme) #light-mode { + display: inline; + } +} + /* end dark-theme */ From e0f1d2ab5ed53682fe1d304f21639f5d8b71af01 Mon Sep 17 00:00:00 2001 From: pamparam Date: Thu, 20 Mar 2025 16:36:31 +0300 Subject: [PATCH 05/10] removed flickering --- templates/development.css | 79 +++------------------------------------ templates/development.php | 22 +++++------ 2 files changed, 16 insertions(+), 85 deletions(-) diff --git a/templates/development.css b/templates/development.css index a06d841..18fabc2 100644 --- a/templates/development.css +++ b/templates/development.css @@ -27,6 +27,7 @@ body { color: var(--page-text-color); background: var(--page-bg-color); line-height: 1; + display: none; } ul { @@ -36,6 +37,9 @@ ul { /* light theme */ +.light-theme { + display: block; +} :root { --page-bg-color: #fff; --page-text-color: #505050; @@ -809,6 +813,8 @@ main { --button-color: #fff; --button-bg-hover: #5c636a; --button-color-hover: #fff; + + display: block; } .dark-theme header { @@ -873,77 +879,4 @@ main { display: inline; } -@media (prefers-color-scheme: dark) { - body:not(.light-theme) { - --page-bg-color: rgba(46,46,46, 0.9); - --page-text-color: #fff; - --icon-color: #989898; - --icon-hover-color: #fff; - } - - body:not(.light-theme) header { - --header-bg-color: #2e2e2e; - --previous-text-color: rgba(255, 255, 255, 0.8); - --previous-arrow-color: #fff; - } - - body:not(.light-theme) .exception-card { - --exception-card-bg-color: #222; - --exception-card-border-color: #591e15; - --exception-class-text-color: #fff; - --exception-class-friendly-text-color: rgba(255, 255, 255, 0.5); - --exception-class-friendly-link-color: #E57373; - --exception-message-text-color: rgba(255, 255, 255, 0.8); - } - - body:not(.light-theme) header .solution { - --text-color: rgba(255, 255, 255, 0.8); - --link-color: #03a9f4; - --link-hover-color: #39b9f3; - --blockquote-text-color: #999; - --blockquote-border-color: #484c50; - --code-bg-color: #2d333b; - --pre-bg-color: #2d333b; - --table-border-color: #484c50; - --separator-color: #484c50; - } - - body:not(.light-theme) .call-stack { - --bg-color: #1e1e1e; - --border-color: transparent; - --box-shadow: 0 13px 20px rgba(0, 0, 0, 0.25); - --link-color: rgba(255, 255, 255, 0.5); - --error-line-bg-color: #422c2c; - --hover-line-bg-color: #292929; - --element-wrap-border-color: #141414; - --element-wrap-text-color: #fff; - --element-wrap-hover-text-color: #9cdcfe; - --vendor-bg-color: rgba(46,46,46, 0.9); - --vendor-border-color: #666; - --vendor-state-bg-color: #666; - --vendor-content-bg-color: rgba(46,46,46, 0.9); - } - - body:not(.light-theme) .hljs { - --hljs-text-color: #fff; - --hljs-comment-text-color: #999; - --hljs-keyword-text-color: #88aece; - --hljs-attribute-text-color: #c59bc1; - --hljs-name-text-color: #f08d49; - --hljs-string-text-color: #b5bd68; - --hljs-code-text-color: #cccccc; - --hljs-delition-text-color: #de7176; - --hljs-addition-text-color: #76c490; - } - - body:not(.light-theme) #dark-mode { - display: none; - } - - body:not(.light-theme) #light-mode { - display: inline; - } -} - - /* end dark-theme */ diff --git a/templates/development.php b/templates/development.php index d684f4a..5ce96df 100644 --- a/templates/development.php +++ b/templates/development.php @@ -191,6 +191,9 @@ class="copy-clipboard"