From 6849c368f017f4cb8f037f7378f1a6dc5c7298ad Mon Sep 17 00:00:00 2001 From: angusmcleod Date: Mon, 8 Feb 2021 13:07:21 +1100 Subject: [PATCH] Support discourse client theme color schemes This allows for color scheme switching via theme switching (e.g. for user selected dark modes). See further https://thepavilion.io/t/allow-wizard-themes-to-support-default-dark-mode-variables/3710 --- controllers/custom_wizard/wizard.rb | 4 ++-- views/layouts/wizard.html.erb | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/controllers/custom_wizard/wizard.rb b/controllers/custom_wizard/wizard.rb index aa786510..0cc46037 100644 --- a/controllers/custom_wizard/wizard.rb +++ b/controllers/custom_wizard/wizard.rb @@ -4,7 +4,7 @@ class CustomWizard::WizardController < ::ApplicationController before_action :ensure_plugin_enabled helper_method :wizard_page_title - helper_method :theme_ids + helper_method :wizard_theme_ids def wizard CustomWizard::Wizard.create(params[:wizard_id].underscore, current_user) @@ -14,7 +14,7 @@ class CustomWizard::WizardController < ::ApplicationController wizard ? (wizard.name || wizard.id) : I18n.t('wizard.custom_title') end - def theme_ids + def wizard_theme_ids wizard ? [wizard.theme_id] : nil end diff --git a/views/layouts/wizard.html.erb b/views/layouts/wizard.html.erb index f1069af3..15ffbe65 100644 --- a/views/layouts/wizard.html.erb +++ b/views/layouts/wizard.html.erb @@ -1,9 +1,11 @@ + <%= discourse_color_scheme_stylesheets %> + <%= discourse_stylesheet_link_tag :wizard, theme_id: nil %> <%= discourse_stylesheet_link_tag :wizard_custom %> - <%- if theme_ids.present? %> - <%= discourse_stylesheet_link_tag (mobile_view? ? :mobile_theme : :desktop_theme) %> + <%- if wizard_theme_ids.present? %> + <%= discourse_stylesheet_link_tag (mobile_view? ? :mobile_theme : :desktop_theme), theme_ids: wizard_theme_ids %> <%- end %> <%= preload_script "locales/#{I18n.locale}" %> @@ -27,7 +29,7 @@ <%= tag.meta id: 'data-discourse-setup', data: client_side_setup_data %> - "> + "> <%= render partial: "layouts/head" %>