Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[admin] dark mode #5511

Merged
merged 9 commits into from
Nov 15, 2023
Prev Previous commit
Next Next commit
Extract a locales helper in the nav account component
  • Loading branch information
elia committed Nov 15, 2023
commit 0b6faea6b19c079a8a30576585ccb1599bb0c731
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,21 @@
<label class="flex gap-2 items-center px-2">
<%= icon_tag("global-line", class: "w-full max-w-[20px] h-5 fill-current shrink") %>
<select class="w-full appearance-none grow bg-transparent outline-none" onchange="this.form.requestSubmit()" name="switch_to_locale">
<%= options_for_select(
available_locales
.map do |locale|
[
t(
"spree.i18n.this_file_language",
locale: locale,
default: locale.to_s,
fallback: false
),
locale
]
end
.sort,
selected: I18n.locale,
) %>
<%= options_for_select(locale_options_for_select(available_locales), selected: I18n.locale) %>
</select>
<%= icon_tag("expand-up-down-line", class: "w-full max-w-[20px] h-5 fill-current shrink") %>
</label>
<% end %>
</li>
<% end %>

<li class="h-8 flex items-center hover:bg-gray-25 rounded">
<%= link_to @account_path, class: 'flex gap-2 items-center px-2' do %>
<%= icon_tag("user-3-line", class: "w-5 h-5 fill-current shrink") %>
<span><%= t('.account') %></span>
<% end %>
</li>

<li class="h-8 flex items-center hover:bg-gray-25 rounded">
<%= button_to @logout_path, method: @logout_method, class: 'flex gap-2 items-center px-2' do %>
<%= icon_tag("logout-box-line", class: "w-5 h-5 fill-current shrink") %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ def initialize(user_label:, account_path:, logout_path:, logout_method:)
@logout_path = logout_path
@logout_method = logout_method
end

def locale_options_for_select(available_locales)
available_locales.map do |locale|
[
t("spree.i18n.this_file_language", locale: locale, default: locale.to_s, fallback: false),
locale,
]
end.sort
end
end