Kovah / LinkAce

LinkAce is a self-hosted archive to collect links of your favorite websites.
https://www.linkace.org
GNU General Public License v3.0
2.55k stars 160 forks source link

Login page cannot do dark mode #619

Closed chrissawyerfan4 closed 1 year ago

chrissawyerfan4 commented 1 year ago

Bug Description

A dark mode can be configured for non-logged-in visitors but this is not always applied

How to reproduce

Open the /login path

Expected behavior

Dark mode setting for guest users is applied

LinkAce version

dev

Setup Method

PHP

Operating System

Linux (Ubuntu, CentOS,...)

Patch

diff --git a/resources/views/partials/configure-darkmode.blade.php b/resources/views/partials/configure-darkmode.blade.php
index 85ef640..0a57ea4 100644
--- a/resources/views/partials/configure-darkmode.blade.php
+++ b/resources/views/partials/configure-darkmode.blade.php
@@ -1,10 +1,6 @@
-@if(usersettings('darkmode_setting') === '1'
-    || (request()->is('guest/*') && systemsettings('guest_darkmode_setting') === '1'))
+@if(usersettings('darkmode_setting') === '1')
     <link href="{{ mix('assets/dist/css/app-dark.css') }}" rel="stylesheet">
-@elseif(usersettings('darkmode_setting') === '2'
-    || (request()->is('guest/*') && systemsettings('guest_darkmode_setting') === '2'))
+@else
     <link rel="stylesheet" media="(prefers-color-scheme: light)" href="{{ mix('assets/dist/css/app.css') }}">
     <link rel="stylesheet" media="(prefers-color-scheme: dark)" href="{{ mix('assets/dist/css/app-dark.css') }}">
-@else
-    <link href="{{ mix('assets/dist/css/app.css') }}" rel="stylesheet">
 @endif

This will just let the client (browser) preference choose if the user is not logged in. Note that older browsers do not know of this preference, leading to no CSS file being loaded at all for these clients! I ran into this but didn't expect the project would want to support this given the stance on using still supported (by e.g. Debian) PHP 7.x. This issue could be fixed by always including the preferred scheme (for me: dark) and then using the media query to see whether light should be included to override it. This is double the CSS weight, but seeing as that's still lighter-weight than the font file that the software also ships with by default, I suppose that's not something people care too much about.

Kovah commented 1 year ago

Thanks for the report, fix will be released with the next version.