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

LG-4792: Revise email languages layout to avoid text wrapping #5906

Merged
merged 2 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Unreleased

### Improvements/Changes
- Layout: Improve layout margins and typographical consistency across several content pages. (#5880, #5884, #5887, #5888, #5908)
- Layout: Improve layout margins and typographical consistency across several content pages. (#5880, #5884, #5887, #5888, #5906)
- Typography: Updated monospace font to Roboto Mono for consistency across login.gov sites. (#5891)
- Icons: Replaced custom button icons using U.S. Web Design system icons. (#5904)

Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/utilities/_space-misc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
padding-left: 24px;
}

.minw-full {
min-width: 100%;
}

@media #{$breakpoint-sm} {
.sm-mr-20p {
margin-right: 20px;
Expand Down
55 changes: 29 additions & 26 deletions app/views/shared/_email_languages.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@ locals:
* f: from validated_form_for
* selection: the current language selection
%>
<div class="margin-bottom-4">
<ul class="usa-input-list">
<% I18n.available_locales.each do |locale| %>
<% item_id = "email-locale-#{locale}" %>
<li class="grid-col-8 mobile-lg:grid-col-6">
<%= f.input_field(
:email_language,
type: :radio,
value: locale,
checked: selection ?
selection.to_s == locale.to_s :
(I18n.locale.to_s == locale.to_s),
class: 'usa-radio__input usa-radio__input--bordered',
id: item_id,
) %>
<%= f.label(
:email_language,
locale == I18n.locale ?
t('account.email_language.default', language: t("i18n.locale.#{locale}")) :
t("i18n.locale.#{locale}"),
for: item_id,
class: 'usa-radio__label width-full',
) %>
</li>
<% end %>
</ul>
<div class="grid-row margin-bottom-2">
<div class="grid-col-fill">
<ul class="usa-input-list display-inline-block minw-full">
<% I18n.available_locales.each do |locale| %>
<% item_id = "email-locale-#{locale}" %>
<li class="text-no-wrap width-full">
<%= f.input_field(
:email_language,
type: :radio,
value: locale,
checked: selection ?
selection.to_s == locale.to_s :
(I18n.locale.to_s == locale.to_s),
class: 'usa-radio__input usa-radio__input--bordered',
id: item_id,
) %>
<%= f.label(
:email_language,
locale == I18n.locale ?
t('account.email_language.default', language: t("i18n.locale.#{locale}")) :
t("i18n.locale.#{locale}"),
for: item_id,
class: 'usa-radio__label width-full text-no-wrap',
) %>
</li>
<% end %>
</ul>
</div>
<div class="grid-col-4 tablet:grid-col-6"></div>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity: The reason to do it this way where the content column is assigned grid-col-fill and this column is given an explicit width is due to how the USWDS grid will assign flex-grow: 0; flex-shrink: 1 when using explicit widths. This allows the empty column to shrink and allows the grid-col-fill to occupy its space.

</div>
5 changes: 3 additions & 2 deletions app/views/sign_up/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<%= t('forms.registration.labels.email_language') %>
</legend>

<p class="margin-bottom-4">
<p class="margin-bottom-2">
<%= t(
'account.email_language.languages_list',
app_name: APP_NAME,
Expand All @@ -45,6 +45,7 @@
<%= t('sign_up.terms', app_name: APP_NAME) %>
<%= new_window_link_to(t('titles.rules_of_use'), MarketingSite.rules_of_use_url) %>
<% end,
label_html: { class: 'margin-y-0' },
required: true,
) %>

Expand All @@ -53,7 +54,7 @@
:button,
t('forms.buttons.submit.default'),
type: :submit,
class: 'usa-button usa-button--big usa-button--wide margin-y-5',
class: 'display-block usa-button usa-button--big usa-button--wide margin-y-5',
) %>
<% end %>

Expand Down