-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not show theme selector if only one theme is configured
There is no usecase for selecting from one theme.
- Loading branch information
Showing
2 changed files
with
43 additions
and
39 deletions.
There are no files selected for viewing
36 changes: 19 additions & 17 deletions
36
backend/app/views/spree/admin/shared/_theme_selection.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %> |
46 changes: 24 additions & 22 deletions
46
backend/app/views/spree/admin/shared/_theme_selection_solidus_admin.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %> |