feat: enhance language switcher dropdown
- Update dropdown to support dynamic locales from I18n - Limit dropdown height with overflow handling for better UX This change improves the language switcher by dynamically loading available locales from the I18n configuration. It also enhances the user experience by limiting the height of the dropdown and enabling scrolling, making it easier to navigate through multiple language options.
This commit is contained in:
parent
9ef2a92d60
commit
5f98d9ebfd
@ -6,8 +6,8 @@
|
||||
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</label>
|
||||
<ul tabindex="0" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-32">
|
||||
<% [:en, :'zh-CN', :ja, :ko].each do |locale| %>
|
||||
<ul tabindex="0" class="dropdown-content menu p-2 max-h-80 overflow-y-auto flex-nowrap shadow bg-base-100 rounded-box w-32">
|
||||
<% I18n.available_locales.each do |locale| %>
|
||||
<%= link_to url_for(locale: locale),
|
||||
class: "px-4 py-2 hover:bg-base-200 rounded-lg #{I18n.locale == locale ? 'bg-base-200' : ''}" do %>
|
||||
<%= t("language.#{locale}") %>
|
||||
|
Loading…
Reference in New Issue
Block a user