diff --git a/app/controllers/public/api/v1/portals/base_controller.rb b/app/controllers/public/api/v1/portals/base_controller.rb index 68619baf8..d9fec27b1 100644 --- a/app/controllers/public/api/v1/portals/base_controller.rb +++ b/app/controllers/public/api/v1/portals/base_controller.rb @@ -1,5 +1,6 @@ class Public::Api::V1::Portals::BaseController < PublicController before_action :show_plain_layout + before_action :set_color_scheme around_action :set_locale after_action :allow_iframe_requests @@ -9,6 +10,14 @@ class Public::Api::V1::Portals::BaseController < PublicController @is_plain_layout_enabled = params[:show_plain_layout] == 'true' end + def set_color_scheme + @theme = if %w[dark light].include?(params[:theme]) + params[:theme] + else + '' + end + end + def set_locale(&) switch_locale_with_portal(&) if params[:locale].present? switch_locale_with_article(&) if params[:article_slug].present? diff --git a/app/helpers/portal_helper.rb b/app/helpers/portal_helper.rb new file mode 100644 index 000000000..3551b5ac6 --- /dev/null +++ b/app/helpers/portal_helper.rb @@ -0,0 +1,11 @@ +module PortalHelper + def generate_portal_bg_color(portal_color, theme) + base_color = theme == 'dark' ? 'black' : 'white' + "color-mix(in srgb, #{portal_color} 10%, #{base_color})" + end + + def generate_portal_bg(portal_color, theme) + bg_image = theme == 'dark' ? 'grid_dark.svg' : 'grid.svg' + "background: url(/assets/images/hc/#{bg_image}) #{generate_portal_bg_color(portal_color, theme)}" + end +end diff --git a/app/javascript/portal/components/PublicSearchInput.vue b/app/javascript/portal/components/PublicSearchInput.vue index a1b36fd66..53099a08e 100644 --- a/app/javascript/portal/components/PublicSearchInput.vue +++ b/app/javascript/portal/components/PublicSearchInput.vue @@ -1,16 +1,16 @@