Merge pull request #5092 from NamelessContributor/issue-5084

Add auto theme preference (fix #5084)
This commit is contained in:
evazion
2022-04-09 03:48:39 -05:00
committed by GitHub
3 changed files with 16 additions and 5 deletions

View File

@@ -104,7 +104,7 @@ html {
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
} }
html { html, body[data-current-user-theme="light"] {
--body-background-color: var(--white); --body-background-color: var(--white);
--text-color: var(--black); --text-color: var(--black);
@@ -322,7 +322,7 @@ html {
} }
/* variables that aren't defined in the dark theme fall back to the :root theme */ /* variables that aren't defined in the dark theme fall back to the :root theme */
body[data-current-user-theme="dark"] { @mixin dark-theme {
--body-background-color: var(--grey-9); --body-background-color: var(--grey-9);
--text-color: var(--grey-2); --text-color: var(--grey-2);
@@ -525,3 +525,14 @@ body[data-current-user-theme="dark"] {
--banned-artist-label-color: var(--red-5); --banned-artist-label-color: var(--red-5);
--deleted-artist-label-color: var(--grey-6); --deleted-artist-label-color: var(--grey-6);
} }
body[data-current-user-theme="dark"] {
@include dark-theme;
}
@media (prefers-color-scheme: dark) {
body {
@include dark-theme;
}
}

View File

@@ -14,7 +14,7 @@
# @see https://en.wikipedia.org/wiki/HSLuv # @see https://en.wikipedia.org/wiki/HSLuv
# @see https://github.com/hsluv/hsluv # @see https://github.com/hsluv/hsluv
# @see https://danbooru.donmai.us/static/colors # @see https://danbooru.donmai.us/static/colors
# @see app/javascript/src/styles/base/040_colors.css # @see app/javascript/src/styles/base/040_colors.scss
module ColorPalette module ColorPalette
module_function module_function

View File

@@ -91,12 +91,12 @@ class User < ApplicationRecord
attribute :unread_dmail_count, default: 0 attribute :unread_dmail_count, default: 0
attribute :favorite_count, default: 0 attribute :favorite_count, default: 0
attribute :per_page, default: 20 attribute :per_page, default: 20
attribute :theme, default: :light attribute :theme, default: :auto
attribute :upload_points, default: Danbooru.config.initial_upload_points.to_i attribute :upload_points, default: Danbooru.config.initial_upload_points.to_i
attribute :bit_prefs, default: 0 attribute :bit_prefs, default: 0
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs" has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
enum theme: { light: 0, dark: 100 }, _suffix: true enum theme: { auto: 0, light: 50, dark: 100 }, _suffix: true
attr_reader :password attr_reader :password