Skip to content

Commit e0f1d2a

Browse files
committed
removed flickering
1 parent 4d0c080 commit e0f1d2a

File tree

2 files changed

+16
-85
lines changed

2 files changed

+16
-85
lines changed

templates/development.css

Lines changed: 6 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ body {
2727
color: var(--page-text-color);
2828
background: var(--page-bg-color);
2929
line-height: 1;
30+
display: none;
3031
}
3132

3233
ul {
@@ -36,6 +37,9 @@ ul {
3637

3738

3839
/* light theme */
40+
.light-theme {
41+
display: block;
42+
}
3943
:root {
4044
--page-bg-color: #fff;
4145
--page-text-color: #505050;
@@ -809,6 +813,8 @@ main {
809813
--button-color: #fff;
810814
--button-bg-hover: #5c636a;
811815
--button-color-hover: #fff;
816+
817+
display: block;
812818
}
813819

814820
.dark-theme header {
@@ -873,77 +879,4 @@ main {
873879
display: inline;
874880
}
875881

876-
@media (prefers-color-scheme: dark) {
877-
body:not(.light-theme) {
878-
--page-bg-color: rgba(46,46,46, 0.9);
879-
--page-text-color: #fff;
880-
--icon-color: #989898;
881-
--icon-hover-color: #fff;
882-
}
883-
884-
body:not(.light-theme) header {
885-
--header-bg-color: #2e2e2e;
886-
--previous-text-color: rgba(255, 255, 255, 0.8);
887-
--previous-arrow-color: #fff;
888-
}
889-
890-
body:not(.light-theme) .exception-card {
891-
--exception-card-bg-color: #222;
892-
--exception-card-border-color: #591e15;
893-
--exception-class-text-color: #fff;
894-
--exception-class-friendly-text-color: rgba(255, 255, 255, 0.5);
895-
--exception-class-friendly-link-color: #E57373;
896-
--exception-message-text-color: rgba(255, 255, 255, 0.8);
897-
}
898-
899-
body:not(.light-theme) header .solution {
900-
--text-color: rgba(255, 255, 255, 0.8);
901-
--link-color: #03a9f4;
902-
--link-hover-color: #39b9f3;
903-
--blockquote-text-color: #999;
904-
--blockquote-border-color: #484c50;
905-
--code-bg-color: #2d333b;
906-
--pre-bg-color: #2d333b;
907-
--table-border-color: #484c50;
908-
--separator-color: #484c50;
909-
}
910-
911-
body:not(.light-theme) .call-stack {
912-
--bg-color: #1e1e1e;
913-
--border-color: transparent;
914-
--box-shadow: 0 13px 20px rgba(0, 0, 0, 0.25);
915-
--link-color: rgba(255, 255, 255, 0.5);
916-
--error-line-bg-color: #422c2c;
917-
--hover-line-bg-color: #292929;
918-
--element-wrap-border-color: #141414;
919-
--element-wrap-text-color: #fff;
920-
--element-wrap-hover-text-color: #9cdcfe;
921-
--vendor-bg-color: rgba(46,46,46, 0.9);
922-
--vendor-border-color: #666;
923-
--vendor-state-bg-color: #666;
924-
--vendor-content-bg-color: rgba(46,46,46, 0.9);
925-
}
926-
927-
body:not(.light-theme) .hljs {
928-
--hljs-text-color: #fff;
929-
--hljs-comment-text-color: #999;
930-
--hljs-keyword-text-color: #88aece;
931-
--hljs-attribute-text-color: #c59bc1;
932-
--hljs-name-text-color: #f08d49;
933-
--hljs-string-text-color: #b5bd68;
934-
--hljs-code-text-color: #cccccc;
935-
--hljs-delition-text-color: #de7176;
936-
--hljs-addition-text-color: #76c490;
937-
}
938-
939-
body:not(.light-theme) #dark-mode {
940-
display: none;
941-
}
942-
943-
body:not(.light-theme) #light-mode {
944-
display: inline;
945-
}
946-
}
947-
948-
949882
/* end dark-theme */

templates/development.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ class="copy-clipboard"
191191
<?= file_get_contents(__DIR__ . '/highlight.min.js') ?>
192192
</script>
193193
<script>
194+
const LIGHT_THEME = 'light-theme';
195+
const DARK_THEME = 'dark-theme';
196+
194197
window.onload = function() {
195198
const codeBlocks = document.querySelectorAll('.solution pre code,.codeBlock');
196199
const callStackItems = document.getElementsByClassName('call-stack-item');
@@ -348,45 +351,40 @@ class="copy-clipboard"
348351
}
349352

350353
function enableDarkTheme() {
351-
document.body.classList.remove('light-theme');
352-
document.body.classList.add('dark-theme');
353-
setCookie('yii-exception-theme', 'dark-theme');
354+
applyTheme(DARK_THEME);
355+
setCookie('yii-exception-theme', DARK_THEME);
354356
}
355357

356358
function enableLightTheme() {
357-
document.body.classList.remove('dark-theme');
358-
document.body.classList.add('light-theme');
359-
setCookie('yii-exception-theme', 'light-theme');
359+
applyTheme(LIGHT_THEME);
360+
setCookie('yii-exception-theme', LIGHT_THEME);
360361
}
361362
};
362363

363364
// Highlight lines that have text in them but still support text selection:
364365
document.onmousedown = function() { document.getElementsByTagName('body')[0].classList.add('mousedown'); }
365366
document.onmouseup = function() { document.getElementsByTagName('body')[0].classList.remove('mousedown'); }
366367

367-
<?php if (empty($theme)): ?>
368368
const themeMedia = window.matchMedia('(prefers-color-scheme: dark)');
369369
const theme = getCookie('yii-exception-theme');
370370

371371
if (theme) {
372372
applyTheme(theme);
373373
} else {
374-
applyTheme((themeMedia.matches ? 'dark-theme' : 'light-theme'));
374+
applyTheme((themeMedia.matches ? DARK_THEME : LIGHT_THEME));
375375
}
376376

377377
themeMedia.addEventListener('change', event => {
378378
if (!theme) {
379-
applyTheme((event.matches ? 'dark-theme' : 'light-theme'));
379+
applyTheme((event.matches ? DARK_THEME : LIGHT_THEME));
380380
}
381381
});
382382

383383
function applyTheme(theme){
384-
document.body.classList.remove('dark-theme', 'light-theme');
384+
document.body.classList.remove(DARK_THEME, LIGHT_THEME);
385385
document.body.classList.add(theme);
386386
}
387387

388-
<?php endif; ?>
389-
390388
function setCookie(name, value) {
391389
const date = new Date(2100, 0, 1);
392390
const expires = "; expires=" + date.toUTCString();

0 commit comments

Comments
 (0)