Add auto/manual color scheme stylesheets depending on user preferences
This commit is contained in:
parent
8a020b3ec7
commit
2ca74ab3ef
10 changed files with 28 additions and 7 deletions
|
@ -20,4 +20,3 @@ $table-border-factor: .1;
|
|||
$list-group-hover-bg: rgba(var(--bs-emphasis-color-rgb), .075);
|
||||
|
||||
$enable-negative-margins: true;
|
||||
$color-mode-type: media-query;
|
||||
|
|
3
app/assets/stylesheets/screen-auto-ltr.scss
Normal file
3
app/assets/stylesheets/screen-auto-ltr.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
@use "common" with (
|
||||
$color-mode-type: media-query
|
||||
);
|
3
app/assets/stylesheets/screen-auto-rtl.rtlcss.scss
Normal file
3
app/assets/stylesheets/screen-auto-rtl.rtlcss.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
@use "common" with (
|
||||
$color-mode-type: media-query
|
||||
);
|
|
@ -1 +0,0 @@
|
|||
@import "common";
|
3
app/assets/stylesheets/screen-manual-ltr.scss
Normal file
3
app/assets/stylesheets/screen-manual-ltr.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
@use "common" with (
|
||||
$color-mode-type: data
|
||||
);
|
3
app/assets/stylesheets/screen-manual-rtl.rtlcss.scss
Normal file
3
app/assets/stylesheets/screen-manual-rtl.rtlcss.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
@use "common" with (
|
||||
$color-mode-type: data
|
||||
);
|
|
@ -1 +0,0 @@
|
|||
@import "common";
|
|
@ -281,7 +281,15 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
helper_method :preferred_editor
|
||||
def preferred_site_color_scheme
|
||||
if current_user
|
||||
current_user.preferences.find_by(:k => "site.color_scheme")&.v || "auto"
|
||||
else
|
||||
"auto"
|
||||
end
|
||||
end
|
||||
|
||||
helper_method :preferred_editor, :preferred_site_color_scheme
|
||||
|
||||
def update_totp
|
||||
if Settings.key?(:totp_key)
|
||||
|
|
|
@ -5,7 +5,11 @@
|
|||
<%= javascript_include_tag "turbo", :type => "module" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<%= javascript_include_tag "i18n/#{I18n.locale}" %>
|
||||
<%= stylesheet_link_tag "screen-#{dir}", :media => "screen" %>
|
||||
<% if preferred_site_color_scheme == "auto" %>
|
||||
<%= stylesheet_link_tag "screen-auto-#{dir}", :media => "screen" %>
|
||||
<% else %>
|
||||
<%= stylesheet_link_tag "screen-manual-#{dir}", :media => "screen" %>
|
||||
<% end %>
|
||||
<%= stylesheet_link_tag "print-#{dir}", :media => "print" %>
|
||||
<%= stylesheet_link_tag "leaflet-all", :media => "screen, print" %>
|
||||
<%= render :partial => "layouts/meta" %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="<%= I18n.locale %>" dir="<%= dir %>">
|
||||
<%= tag.html :lang => I18n.locale, :dir => dir, :data => { :bs_theme => (preferred_site_color_scheme if preferred_site_color_scheme != "auto") } do %>
|
||||
<%= render :partial => "layouts/head" %>
|
||||
<body class="<%= body_class %>">
|
||||
<%= render :partial => "layouts/header" %>
|
||||
|
@ -8,4 +8,4 @@
|
|||
<noscript><p><img src="<%= request.protocol %><%= Settings.matomo["location"] %>/matomo.php?idsite=<%= Settings.matomo["site"] %>" class="matomo" alt="" /></p></noscript>
|
||||
<% end -%>
|
||||
</body>
|
||||
</html>
|
||||
<% end %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue