]> git.joonet.de Git - adminer.git/commitdiff
CSS: Allow more custom styles with dark mode (fix #925)
authorJakub Vrana <jakub@vrana.cz>
Tue, 18 Mar 2025 16:49:33 +0000 (17:49 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 18 Mar 2025 16:49:33 +0000 (17:49 +0100)
CHANGELOG.md
adminer/include/design.inc.php

index 6527108c0960c05f6b0895b5dcb7a2a524e896e8..306273a1022f1e82de993e98aa22fc7559fa4612 100644 (file)
@@ -3,6 +3,7 @@
 - PostgreSQL: Display description of system variables
 - PostgreSQL: Avoid warning about crdb_version (bug #924, regression from 5.0.5)
 - CSS: Sticky table headers (bug #918)
+- CSS: Allow more custom styles with dark mode (bug #925)
 - IMAP: New plugin driver created for fun
 
 ## Adminer 5.0.6 (released 2025-03-17)
index a96581b414385eb3bcf7f5fb351f0e198d5c22d2..5e23ff45563a79530a8c9afe28091edae84f8f30 100644 (file)
@@ -31,7 +31,11 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
 <link rel="stylesheet" href="../adminer/static/default.css">
 <?php
        $css = $adminer->css();
-       $dark = (count($css) == 1 ? !!preg_match('~-dark~', $css[0]) : null);
+       $has_dark = in_array("adminer-dark.css", $css);
+       $dark = (in_array("adminer.css", $css)
+               ? ($has_dark ? null : false) // both styles - autoswitching, only adminer.css - light
+               : ($has_dark ?: null) // only adminer-dark.css - dark, neither - autoswitching
+       );
        if ($dark !== false) {
                echo "<link rel='stylesheet'" . ($dark ? "" : " media='(prefers-color-scheme: dark)'") . " href='../adminer/static/dark.css'>\n";
        }