diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index d59133582..872bc9665 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -44,26 +44,24 @@ @apply !text-white; } -.relationship .relationship\:bg-gray-700, -.relationship.relationship\:bg-gray-700 { - @apply bg-gray-700; -} - -.relationship .relationship\:bg-gray-200, -.relationship.relationship\:bg-gray-200 { - @apply bg-gray-200; -} - -@media (prefers-color-scheme: dark) { - .relationship .dark\:relationship\:bg-gray-700, - .relationship.dark\:relationship\:bg-gray-700 { +:root:not(.dark) { + .relationship .relationship\:bg-gray-700, + .relationship.relationship\:bg-gray-700 { @apply bg-gray-700; } + .relationship .relationship\:bg-gray-200, + .relationship.relationship\:bg-gray-200 { + @apply bg-gray-200; + } } -.relationship .relationship\:hidden, -.relationship.relationship\:hidden { - @apply !hidden; +@media (prefers-color-scheme: dark), (root: dark) { + .dark\:relationship\:bg-gray-700.relationship { + @apply bg-gray-700 !important; + } + .dark\:relationship\:bg-gray-900.relationship { + @apply bg-gray-900; + } } .relationship .relationship\:pl-4, diff --git a/app/assets/stylesheets/includes/daisyui_tooltip.css b/app/assets/stylesheets/includes/daisyui_tooltip.css index 2087c7897..7f1d725a9 100644 --- a/app/assets/stylesheets/includes/daisyui_tooltip.css +++ b/app/assets/stylesheets/includes/daisyui_tooltip.css @@ -193,13 +193,42 @@ dialog button:focus-visible { --tw-prose-pre-code: #ffffff !important; } +/* dark_mode overrides */ @media (prefers-color-scheme: dark) { + :root.light { + color-scheme: light; + } + :root .prose { + --tw-prose-body: rgb(236, 236, 236); + } +} +:root.dark { + :root .prose { + --tw-prose-body: rgb(236, 236, 236); + } +} +:root.dark { :root .prose { --tw-prose-body: rgb(236, 236, 236); } } -/* show only on touch devices */ +:root.dark { + :where(.menu li:not(.menu-title):not(.disabled) > :not(ul):not(details):not(.menu-title)):not(.active):hover, + :where(.menu li:not(.menu-title):not(.disabled) > details > summary:not(.menu-title)):not(.active):hover { + background-color: rgb(59 59 61); + } +} + +:root.dark { + :where(.menu li:not(.menu-title):not(.disabled) > :not(ul):not(details):not(.menu-title)):not(.active):hover, + :where(.menu li:not(.menu-title):not(.disabled) > details > summary:not(.menu-title)):not(.active):hover { + background-color: rgb(59 59 61); + } +} + +/* hide tooltip on touch devices */ + @media (hover: none), (hover: on-demand), (-moz-touch-enabled: 1), (pointer: coarse) { .tooltip:hover:after, .tooltip:hover:active:before, diff --git a/app/controllers/settings/people_controller.rb b/app/controllers/settings/people_controller.rb index d51dbf3a5..a0221cdbf 100644 --- a/app/controllers/settings/people_controller.rb +++ b/app/controllers/settings/people_controller.rb @@ -17,7 +17,7 @@ def update def person_params params.require(:person).permit(:email, personable_attributes: [ - :id, :first_name, :last_name, :password, :openai_key, :anthropic_key + :id, :first_name, :last_name, :password, :openai_key, :anthropic_key, preferences: [:dark_mode] ]) end @@ -27,4 +27,4 @@ def check_personable_id return render :edit, status: :unauthorized end end -end \ No newline at end of file +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 40c8b9c57..6bdefe82b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -47,7 +47,7 @@ def person_params end def user_params - params.require(:user).permit(preferences: [:nav_closed]) + params.require(:user).permit(preferences: [:nav_closed, :dark_mode]) end def ensure_registration diff --git a/app/models/user.rb b/app/models/user.rb index a727a8331..f45957a1d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -13,4 +13,13 @@ class User < ApplicationRecord has_many :conversations, dependent: :destroy serialize :preferences, coder: JsonSerializer + + before_create :set_default_preferences + + private + + def set_default_preferences + self.preferences ||= {} + self.preferences[:dark_mode] ||= 'system' + end end diff --git a/app/views/assistants/_assistant.html.erb b/app/views/assistants/_assistant.html.erb index 770623881..1a06efc6f 100644 --- a/app/views/assistants/_assistant.html.erb +++ b/app/views/assistants/_assistant.html.erb @@ -7,8 +7,9 @@