-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a language selector in the header navigation (#551)
* Desktop menu function and style * Overrides checksum matching for rspec * Header language selector for mobile view * Lint stylesheets * Stylesheet unit fix * Spacing in _main.html.erb * Cleaned up the language selector [full language name, down-arrow icon] * Mobile language menu fix * Restore Gemfile.lock * Fix style and tests specs as per suggestions * Style lint fix * Expected result of header/main override spec * typo and dropdown menu fully visible
- Loading branch information
Showing
8 changed files
with
224 additions
and
84 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
app/views/layouts/decidim/header/_header_language_selector.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<% if available_locales.length > 1 %> | ||
<div class="main-header__language-container"> | ||
<button id="trigger-dropdown-language-chooser" data-component="dropdown" data-target="dropdown-menu-language-chooser" class="main-footer__language-trigger"> | ||
<%= icon "global-line" %> | ||
<div class="flex flex-row"> | ||
<span><%= t("name", scope: "locale") %></span> | ||
<%= icon "arrow-down-s-line" %> | ||
<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-chooser" aria-hidden="false" role="menu" aria-labelledby="trigger-dropdown-language-chooser" tabindex="-1"> | ||
<ul class="main-footer__language absolute" role="menu"> | ||
<% (available_locales - [I18n.locale.to_s]).each do |locale| %> | ||
<li class="text-secondary text-md hover:bg-secondary hover:text-white transition" role="presentation"> | ||
<%= link_to locale_name(locale), decidim.locale_path(locale:), method: :post, role: "menuitem", lang: locale, class: "w-full block" %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</div> | ||
<% end %> |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<div id="main-bar" class="main-bar__container"> | ||
<div class="main-bar"> | ||
<div class="main-bar__logo"> | ||
<%= render partial: "layouts/decidim/logo", locals: { organization: current_organization } %> | ||
</div> | ||
|
||
<div class="main-bar__search"> | ||
<%= render partial: "layouts/decidim/header/main_search" %> | ||
</div> | ||
|
||
<div class="main-bar__links-desktop"> | ||
<%= render partial: "layouts/decidim/header/header_language_selector" %> | ||
<%= render partial: "layouts/decidim/header/main_links_desktop" %> | ||
</div> | ||
|
||
<div class="lg:hidden"> | ||
<%# Main dropdown mobile %> | ||
<button id="main-dropdown-summary-mobile" class="main-bar__links-mobile__trigger" | ||
data-component="dropdown" | ||
data-target="dropdown-menu-main-mobile"> | ||
<%= icon "menu-line" %><span class="sr-only"><%= t("main_menu", scope: "layouts.decidim.header") %></span> | ||
</button> | ||
|
||
<div id="dropdown-menu-main-mobile" class="main-bar__links-mobile__dropdown" aria-hidden="true"> | ||
<%= render partial: "layouts/decidim/header/header_language_selector" %> | ||
<%= render partial: "layouts/decidim/header/menu_breadcrumb_main_dropdown", locals: { id: "breadcrumb-main-dropdown-mobile" } %> | ||
</div> | ||
|
||
<%# Sticky menu mobile %> | ||
<div class="main-bar__links-mobile"> | ||
<%= render partial: "layouts/decidim/header/main_links_mobile" %> | ||
</div> | ||
|
||
<%# Overlay menus mobile %> | ||
<%= render partial: "layouts/decidim/header/main_links_mobile_search" %> | ||
<%= render partial: "layouts/decidim/header/main_links_mobile_account" if current_user %> | ||
</div> | ||
</div> | ||
</div> |
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
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
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
Oops, something went wrong.