-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Header] No-js behaviour for locale selectors #2485
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,9 +248,26 @@ | |
<div class="header__icons{% if section.settings.enable_country_selector or section.settings.enable_language_selector %} header__icons--localization header__localization{% endif %}"> | ||
<div class="desktop-localization-wrapper"> | ||
{%- if section.settings.enable_country_selector and localization.available_countries.size > 1 -%} | ||
<localization-form class="small-hide medium-hide"> | ||
<noscript class="small-hide medium-hide"> | ||
{%- form 'localization', id: 'HeaderCountryMobileFormNoScript', class: 'localization-form' -%} | ||
<div class="localization-form__select"> | ||
<h2 class="visually-hidden" id="HeaderCountryMobileLabelNoScript">{{ 'localization.country_label' | t }}</h2> | ||
<select class="localization-selector link" name="country_code" aria-labelledby="HeaderCountryMobileLabelNoScript"> | ||
{%- for country in localization.available_countries -%} | ||
<option value="{{ country.iso_code }}" {%- if country.iso_code == localization.country.iso_code %} selected{% endif %}> | ||
{{ country.name }} ({{ country.currency.iso_code }} {{ country.currency.symbol }}) | ||
</option> | ||
{%- endfor -%} | ||
</select> | ||
{% render 'icon-caret' %} | ||
</div> | ||
<button class="button button--tertiary">{{ 'localization.update_country' | t }}</button> | ||
{%- endform -%} | ||
</noscript> | ||
|
||
<localization-form class="small-hide medium-hide no-js-hidden"> | ||
{%- form 'localization', id: 'HeaderCountryForm', class: 'localization-form' -%} | ||
<div class="no-js-hidden"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non blocking but just curious: do you know why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure tbh. If I left it the way it was, I'd get some unwanted space around the selectors. It's like that in the footer, so I think it was mostly copied over. |
||
<div> | ||
<h2 class="visually-hidden" id="HeaderCountryLabel">{{ 'localization.country_label' | t }}</h2> | ||
{%- render 'country-localization', localPosition: 'HeaderCountry' -%} | ||
</div> | ||
|
@@ -259,9 +276,26 @@ | |
{% endif %} | ||
|
||
{%- if section.settings.enable_language_selector and localization.available_languages.size > 1 -%} | ||
<localization-form class="small-hide medium-hide"> | ||
<noscript class="small-hide medium-hide"> | ||
{%- form 'localization', id: 'HeaderLanguageMobileFormNoScript', class: 'localization-form' -%} | ||
<div class="localization-form__select"> | ||
<h2 class="visually-hidden" id="HeaderLanguageMobileLabelNoScript">{{ 'localization.language_label' | t }}</h2> | ||
<select class="localization-selector link" name="locale_code" aria-labelledby="HeaderLanguageMobileLabelNoScript"> | ||
{%- for language in localization.available_languages -%} | ||
<option value="{{ language.iso_code }}" lang="{{ language.iso_code }}" {%- if language.iso_code == localization.language.iso_code %} selected{% endif %}> | ||
{{ language.endonym_name | capitalize }} | ||
</option> | ||
{%- endfor -%} | ||
</select> | ||
{% render 'icon-caret' %} | ||
</div> | ||
<button class="button button--tertiary">{{ 'localization.update_language' | t }}</button> | ||
{%- endform -%} | ||
</noscript> | ||
|
||
<localization-form class="small-hide medium-hide no-js-hidden"> | ||
{%- form 'localization', id: 'HeaderLanguageForm', class: 'localization-form' -%} | ||
<div class="no-js-hidden"> | ||
<div> | ||
<h2 class="visually-hidden" id="HeaderLanguageLabel">{{ 'localization.language_label' | t }}</h2> | ||
{%- render 'language-localization', localPosition: 'HeaderLanguage' -%} | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
h2
and not alabel
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reusing the approach from the footer and also what's in the JS approach. I believe the reason why is because it helps navigate to it more easily when using a screen reader and using the VoiceOver rotor which shows you all the page's headings.