Skip to content

Commit

Permalink
add header menu lang
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Nov 22, 2024
1 parent 5689c09 commit 5dc49dd
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ gem "decidim-term_customizer", github: "mainio/decidim-module-term_customizer"
gem "bootsnap", "~> 1.3"

gem "puma", ">= 6.3.1"
gem "deface", ">= 1.9"

gem "wicked_pdf", "~> 2.1"

Expand Down
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ GEM
activesupport (>= 6.1)
sprockets (>= 3.0.0)
ssrf_filter (1.1.2)
stringio (3.1.1)
stringio (3.1.2)
strscan (3.1.0)
temple (0.10.3)
terminal-table (3.0.2)
Expand Down Expand Up @@ -906,6 +906,7 @@ DEPENDENCIES
decidim-dev!
decidim-templates!
decidim-term_customizer!
deface (>= 1.9)
letter_opener_web (~> 2.0)
listen (~> 3.1)
net-imap (~> 0.2.3)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- insert_top ".main-bar__links-desktop" -->

<% if available_locales.length > 1 %>
<div class="main-header__language-container">
<button id="trigger-dropdown-language-top" data-component="dropdown" data-target="dropdown-menu-language-top" class="main-header__language-trigger">
<div><%= icon "global-line" %> <%= icon "arrow-down-s-line" %></div>
<div><%= t("name", scope: "locale" ) %></div>
<span class="sr-only">
<% available_locales.each do |locale| %>
<span lang="<%= locale %>">
<%= I18n.with_locale(locale) { t("layouts.decidim.language_chooser.choose_language") } %>
</span>
<% end %>
</span>
</button>

<div id="dropdown-menu-language-top" class="main-header__language-chooser" aria-hidden="true">
<ul class="main-header__language" role="menu">
<% (available_locales - [I18n.locale.to_s]).each do |locale| %>
<li role="presentation">
<%= link_to locale_name(locale), decidim.locale_path(locale:), method: :post, role: "menuitem", lang: locale %>
</li>
<% end %>
</ul>
</div>
</div>
<% end %>
27 changes: 27 additions & 0 deletions app/packs/stylesheets/decidim/decidim_application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,30 @@
// By default this is empty.

@import "../partials/fonts";

.main-bar__links-desktop {
@media (min-width: 768px){
[data-target*=dropdown] {
@apply block min-w-16;;
div {
@apply block text-secondary text-sm text-center;
svg {
@apply inline-block;
}
}
}
}
.main-header__language-chooser {
@apply relative z-10;

> ul {
@apply absolute left-0 bg-white p-4 shadow-md text-left;
>li {
@apply text-secondary text-md hover:underline hover:bg-secondary hover:text-white transition;
>a {
@apply p-2 w-full block;
}
}
}
}
}

0 comments on commit 5dc49dd

Please sign in to comment.