Skip to content

Commit c85b1fc

Browse files
committed
Improve contrast for dark mode phpinfo
Also use CSS variable names; all browsers I can find that support the prefers-color-scheme media query also support CSS variables. Also do some minor updates like the background texture.
1 parent c756e97 commit c85b1fc

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

ext/standard/css.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
#include "php.h"
1818
#include "info.h"
1919

20+
21+
/* Encoded from (without newlines):
22+
<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4'>
23+
<path style='stroke:#000;stroke-width:.5;stroke-opacity:.25' d='M 0,0 4,4 M 0,4 4,0'/>
24+
</svg>
25+
*/
26+
#define BACKGROUND_SVG_ENCODED \
27+
"%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%274%27%20height%3D%274%27%3E%3Cpath%20style%3D%27stroke%3A%23000%3Bstroke-width%3A.5%3Bstroke-opacity%3A.25%27%20d%3D%27M%200%2C0%204%2C4%20M%200%2C4%204%2C0%27%2F%3E%3C%2Fsvg%3E"
28+
2029
PHPAPI ZEND_COLD void php_info_print_css(void) /* {{{ */
2130
{
2231
PUTS("body {background-color: #fff; color: #222; font-family: sans-serif;}\n");
@@ -38,13 +47,17 @@ PHPAPI ZEND_COLD void php_info_print_css(void) /* {{{ */
3847
PUTS(".v i {color: #999;}\n");
3948
PUTS("img {float: right; border: 0;}\n");
4049
PUTS("hr {width: 934px; background-color: #ccc; border: 0; height: 1px;}\n");
41-
PUTS("@media (prefers-color-scheme: dark) {\n");
42-
PUTS(" body {background-color: #333; color: #ddd;}\n");
43-
PUTS(" td, th {border-color: #777;}\n");
44-
PUTS(" .e {background-color: #4F5B93;}\n");
45-
PUTS(" .h {background-color: #5b69a6;}\n");
46-
PUTS(" .v {background-color: #444;}\n");
47-
PUTS(" hr {background-color: #777;}\n");
48-
PUTS("}\n");
50+
PUTS(":root {--php-dark-grey: #333; --php-dark-blue: #4F5B93; --php-medium-blue: #8892BF; --php-light-blue: #E2E4EF; --php-accent-purple: #793862}");
51+
PUTS(
52+
"@media (prefers-color-scheme: dark) {\n"
53+
" body {background: var(--php-dark-grey) url('data:image/svg+xml;utf8," BACKGROUND_SVG_ENCODED "'); color: var(--php-light-blue)}\n"
54+
" .h td, td.e, th {border-color: #606A90}\n"
55+
" td {border-color: #505153}\n"
56+
" .e {background-color: #404A77}\n"
57+
" .h {background-color: var(--php-dark-blue)}\n"
58+
" .v {background-color: var(--php-dark-grey)}\n"
59+
" hr {background-color: #505153}\n"
60+
"}\n"
61+
);
4962
}
5063
/* }}} */

0 commit comments

Comments
 (0)