Skip to content

Commit

Permalink
Do not show theme selector if only one theme is configured
Browse files Browse the repository at this point in the history
There is no usecase for selecting from one theme.
  • Loading branch information
tvdeyen committed Apr 4, 2024
1 parent 96baef2 commit d7ce879
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
36 changes: 19 additions & 17 deletions backend/app/views/spree/admin/shared/_theme_selection.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<% theme_options_for_select = Spree::Backend::Config.themes.keys.map { |theme| [theme.to_s.humanize, theme] }.sort %>

<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "light-only") do %>
<%= hidden_field_tag :system_theme, :light %>
<label class="admin-navbar-selection">
<i class="fa fa-sun-o fa-fw" title="<%= I18n.t('spree.choose_dashboard_theme') %>"></i>
<select name="switch_to_theme" class="custom-select fullwidth" onchange="this.form.requestSubmit()">
<%= options_for_select(theme_options_for_select, session[:admin_light_theme] || Spree::Backend::Config.theme) %>
</select>
</label>
<% end %>
<% if theme_options_for_select.length > 1 %>
<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "light-only") do %>
<%= hidden_field_tag :system_theme, :light %>
<label class="admin-navbar-selection">
<i class="fa fa-sun-o fa-fw" title="<%= I18n.t('spree.choose_dashboard_theme') %>"></i>
<select name="switch_to_theme" class="custom-select fullwidth" onchange="this.form.requestSubmit()">
<%= options_for_select(theme_options_for_select, session[:admin_light_theme] || Spree::Backend::Config.theme) %>
</select>
</label>
<% end %>

<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "dark-only") do %>
<%= hidden_field_tag :system_theme, :dark %>
<label class="admin-navbar-selection">
<i class="fa fa-moon-o fa-fw" title="<%= I18n.t('spree.choose_dashboard_theme') %>"></i>
<select name="switch_to_theme" class="custom-select fullwidth" onchange="this.form.requestSubmit()">
<%= options_for_select(theme_options_for_select, session[:admin_dark_theme] || Spree::Backend::Config.dark_theme) %>
</select>
</label>
<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "dark-only") do %>
<%= hidden_field_tag :system_theme, :dark %>
<label class="admin-navbar-selection">
<i class="fa fa-moon-o fa-fw" title="<%= I18n.t('spree.choose_dashboard_theme') %>"></i>
<select name="switch_to_theme" class="custom-select fullwidth" onchange="this.form.requestSubmit()">
<%= options_for_select(theme_options_for_select, session[:admin_dark_theme] || Spree::Backend::Config.dark_theme) %>
</select>
</label>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<% theme_options_for_select = Spree::Backend::Config.themes.keys.map { |theme| [theme.to_s.humanize, theme] }.sort %>

<li>
<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "light-only") do %>
<%= hidden_field_tag :system_theme, :light %>
<label>
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-sun-line"></use></svg>
<select name="switch_to_theme" onchange="this.form.requestSubmit()">
<%= options_for_select(theme_options_for_select, session[:admin_light_theme] || Spree::Backend::Config.theme) %>
</select>
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-expand-up-down-line"></use></svg>
</label>
<% end %>
<% if theme_options_for_select.length > 1 %>
<li>
<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "light-only") do %>
<%= hidden_field_tag :system_theme, :light %>
<label>
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-sun-line"></use></svg>
<select name="switch_to_theme" onchange="this.form.requestSubmit()">
<%= options_for_select(theme_options_for_select, session[:admin_light_theme] || Spree::Backend::Config.theme) %>
</select>
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-expand-up-down-line"></use></svg>
</label>
<% end %>

<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "dark-only") do %>
<%= hidden_field_tag :system_theme, :dark %>
<label>
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-moon-line"></use></svg>
<select name="switch_to_theme" onchange="this.form.requestSubmit()">
<%= options_for_select(theme_options_for_select, session[:admin_dark_theme] || Spree::Backend::Config.dark_theme) %>
</select>
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-expand-up-down-line"></use></svg>
</label>
<% end %>
</li>
<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "dark-only") do %>
<%= hidden_field_tag :system_theme, :dark %>
<label>
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-moon-line"></use></svg>
<select name="switch_to_theme" onchange="this.form.requestSubmit()">
<%= options_for_select(theme_options_for_select, session[:admin_dark_theme] || Spree::Backend::Config.dark_theme) %>
</select>
<svg aria-hidden="true"><use xlink:href="<%= image_path('spree/backend/themes/solidus_admin/remixicon.symbol.svg') %>#ri-expand-up-down-line"></use></svg>
</label>
<% end %>
</li>
<% end %>

0 comments on commit d7ce879

Please sign in to comment.