Skip to content

Commit a30abc5

Browse files
pamparam83vjik
andauthored
fixed show dark mode (#142)
Co-authored-by: Sergei Predvoditelev <[email protected]>
1 parent 5eb18b6 commit a30abc5

File tree

3 files changed

+55
-23
lines changed

3 files changed

+55
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 4.0.1 under development
44

5-
- no changes in this release.
5+
- Bug #142: Fix dark mode argument display issues (@pamparam83)
66

77
## 4.0.0 February 05, 2025
88

templates/development.css

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,10 +875,22 @@ main {
875875

876876
@media (prefers-color-scheme: dark) {
877877
body:not(.light-theme) {
878-
--page-bg-color: rgba(46,46,46, 0.9);
878+
--page-bg-color: rgba(46, 46, 46, 0.9);
879879
--page-text-color: #fff;
880+
--page-text-muted-color: #aaa;
880881
--icon-color: #989898;
881882
--icon-hover-color: #fff;
883+
884+
--table-line-even-bg: #555;
885+
--table-line-even-color: #eee;
886+
--table-line-odd-bg: #999;
887+
--table-line-odd-color: #eee;
888+
--table-line-hover: #141414;
889+
890+
--button-bg: #6c757d;
891+
--button-color: #fff;
892+
--button-bg-hover: #5c636a;
893+
--button-color-hover: #fff;
882894
}
883895

884896
body:not(.light-theme) header {
@@ -924,6 +936,10 @@ main {
924936
--vendor-content-bg-color: rgba(46,46,46, 0.9);
925937
}
926938

939+
body:not(.light-theme) .functionArguments {
940+
--function-arguments-bg: #303030;
941+
--function-arguments-border-color: #272727;
942+
}
927943
body:not(.light-theme) .hljs {
928944
--hljs-text-color: #fff;
929945
--hljs-comment-text-color: #999;
@@ -945,5 +961,4 @@ main {
945961
}
946962
}
947963

948-
949964
/* end dark-theme */

templates/development.php

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

3+
use Psr\Http\Message\ServerRequestInterface;
34
use Yiisoft\ErrorHandler\CompositeException;
45
use Yiisoft\ErrorHandler\Exception\ErrorException;
6+
use Yiisoft\ErrorHandler\Renderer\HtmlRenderer;
57
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
68

79
/**
8-
* @var $this \Yiisoft\ErrorHandler\Renderer\HtmlRenderer
9-
* @var $request \Psr\Http\Message\ServerRequestInterface|null
10-
* @var $throwable \Throwable
10+
* @var $this HtmlRenderer
11+
* @var $request ServerRequestInterface|null
12+
* @var $throwable Throwable
1113
*/
1214

1315
$theme = $_COOKIE['yii-exception-theme'] ?? '';
@@ -35,6 +37,16 @@
3537
<?= file_get_contents(__DIR__ . '/development.css') ?>
3638
</style>
3739
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700">
40+
<noscript>
41+
<style>
42+
.call-stack-vendor-items, .functionArguments {
43+
display: block !important;
44+
}
45+
.call-stack-vendor-collapse .flex-1 {
46+
display: none;
47+
}
48+
</style>
49+
</noscript>
3850
</head>
3951
<body<?= !empty($theme) ? " class=\"{$this->htmlEncode($theme)}\"" : '' ?>>
4052
<header>
@@ -189,6 +201,9 @@ class="copy-clipboard"
189201
<?= file_get_contents(__DIR__ . '/highlight.min.js') ?>
190202
</script>
191203
<script>
204+
const LIGHT_THEME = 'light-theme';
205+
const DARK_THEME = 'dark-theme';
206+
192207
window.onload = function() {
193208
const codeBlocks = document.querySelectorAll('.solution pre code,.codeBlock');
194209
const callStackItems = document.getElementsByClassName('call-stack-item');
@@ -346,15 +361,13 @@ class="copy-clipboard"
346361
}
347362

348363
function enableDarkTheme() {
349-
document.body.classList.remove('light-theme');
350-
document.body.classList.add('dark-theme');
351-
setCookie('yii-exception-theme', 'dark-theme');
364+
applyTheme(DARK_THEME);
365+
setCookie('yii-exception-theme', DARK_THEME);
352366
}
353367

354368
function enableLightTheme() {
355-
document.body.classList.remove('dark-theme');
356-
document.body.classList.add('light-theme');
357-
setCookie('yii-exception-theme', 'light-theme');
369+
applyTheme(LIGHT_THEME);
370+
setCookie('yii-exception-theme', LIGHT_THEME);
358371
}
359372
};
360373

@@ -363,28 +376,32 @@ function enableLightTheme() {
363376
document.onmouseup = function() { document.getElementsByTagName('body')[0].classList.remove('mousedown'); }
364377

365378
<?php if (empty($theme)): ?>
366-
var theme = getCookie('yii-exception-theme');
367-
379+
const theme = getCookie('yii-exception-theme');
368380
if (theme) {
369-
document.body.classList.add(theme);
381+
applyTheme(theme);
370382
}
371383
<?php endif; ?>
372384

385+
function applyTheme(theme){
386+
document.body.classList.remove(DARK_THEME, LIGHT_THEME);
387+
document.body.classList.add(theme);
388+
}
389+
373390
function setCookie(name, value) {
374-
var date = new Date(2100, 0, 1);
375-
var expires = "; expires=" + date.toUTCString();
391+
const date = new Date(2100, 0, 1);
392+
const expires = "; expires=" + date.toUTCString();
376393

377394
document.cookie = name + "=" + (value || "") + expires + "; path=/";
378395
}
379396

380397
function getCookie(name) {
381-
var nameEQ = name + "=";
382-
var ca = document.cookie.split(';');
398+
const nameEQ = name + "=";
399+
const ca = document.cookie.split(';');
383400

384-
for (var i=0; i < ca.length; i++) {
385-
var c = ca[i];
386-
while (c.charAt(0)==' ') c = c.substring(1,c.length);
387-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
401+
for (let i=0; i < ca.length; i++) {
402+
let c = ca[i];
403+
while (c.charAt(0) === ' ') c = c.substring(1,c.length);
404+
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length);
388405
}
389406

390407
return null;

0 commit comments

Comments
 (0)