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

Secondary Nav: refactor into new design #8011

Merged
merged 8 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
aria-label="Section navigation">
<button class="o-secondary-nav_header" type="button" aria-expanded="false">
<span class="o-secondary-nav_label">
{{ _('In this section') }}
{{ _('Navigate this section') }}
</span>
<span class="o-secondary-nav_cues">
<span class="o-secondary-nav_cue-open" aria-label="Show">
Expand Down
33 changes: 16 additions & 17 deletions cfgov/unprocessed/css/breadcrumbs.less
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
.breadcrumbs {
.m-breadcrumbs {
// Mobile size.
position: relative;
display: flex;
flex-wrap: wrap;
gap: unit(10px / @base-font-size-px, rem);
align-items: center;
flex-wrap: wrap;

font-size: unit(14px / @base-font-size-px, rem);
padding-top: unit(15px / @base-font-size-px, rem);
padding-bottom: unit(15px / @base-font-size-px, rem);
margin-left: unit(20px / @base-font-size-px, rem);
margin-right: unit(20px / @base-font-size-px, rem);
min-height: 33px;
width: calc(100vw - 65px);

.cf-icon-svg {
fill: @pacific;
margin-left: unit(-20px / @base-font-size-px, rem);
&_crumbs {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: block;
}

// Desktop size.
Expand All @@ -24,30 +28,25 @@

// Hide on print.
.respond-to-print( {
.breadcrumbs {
.m-breadcrumbs {
display: none;
}
} );

// Right-to-left (RTL) layout.
html[lang='ar'] {
.breadcrumbs {
.m-breadcrumbs {
margin-right: unit(20px / @base-font-size-px, rem);
margin-left: unit(20px / @base-font-size-px, rem);

.cf-icon-svg {
margin-right: unit(-20px / @base-font-size-px, rem);
margin-left: initial;
}
}
}

// TODO: When the layout-2-1 template is converted to use `u-layout-grid_wrapper`, this can be removed.
.content_wrapper .breadcrumbs {
margin-left: unit(35px / @base-font-size-px, rem);
.content_wrapper .m-breadcrumbs {
margin-left: unit(15px / @base-font-size-px, rem);

// Tablet size only.
.respond-to-range(@bp-sm-min, @bp-sm-max, {
margin-left: unit(50px / @base-font-size-px, rem);
margin-left: unit(30px / @base-font-size-px, rem);
});
}
19 changes: 19 additions & 0 deletions cfgov/unprocessed/css/enhancements/layout-1-3.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,28 @@
}
}

// Tablet and below.
.respond-to-max(@bp-sm-max, {
.u-layout-grid {
&_breadcrumbs {
padding-left: unit(30px / @base-font-size-px, rem);
padding-right: unit(30px / @base-font-size-px, rem);
margin-left: unit(-30px / @base-font-size-px, rem);
margin-right: unit(-30px / @base-font-size-px, rem);
background: @gray-5;
border-bottom: 1px solid @gray-40;
}
}
});

// Tablet
.respond-to-range( @bp-sm-min, @bp-sm-max, {
.u-layout-grid {
&_breadcrumbs {
padding-left: unit(15px / @base-font-size-px, rem);
padding-right: unit(15px / @base-font-size-px, rem);
}

&_secondary-nav {
margin-left: unit(-30px / @base-font-size-px, rem);
margin-right: unit(-30px / @base-font-size-px, rem);
Expand Down
15 changes: 8 additions & 7 deletions cfgov/unprocessed/css/organisms/secondary-nav.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<nav class="o-secondary-nav">
<button class="o-secondary-nav_header">
<span class="o-secondary-nav_label">
In this section
Navigate this section
</span>
<span class="o-secondary-nav_cues">
<span class="o-secondary-nav_cue-open" aria-label="Show">
Expand Down Expand Up @@ -110,7 +110,10 @@
// Grow to available width.
flex-grow: 1;

.h5();
font-size: unit(16px / @base-font-size-px, rem);
font-weight: 600;
letter-spacing: 1px;
color: @pacific;

line-height: unit((22 / @size-v));
margin-bottom: 0;
Expand Down Expand Up @@ -193,6 +196,9 @@
background: @gray-5;
border-bottom: 1px solid @gray-40;

// Add drop-shadow.
box-shadow: 0 5px 5px rgba(0, 0, 0, .2);

&__no-children {
display: none;
}
Expand All @@ -202,11 +208,6 @@
display: none;
}
}

.o-secondary-nav {
border-top: 1px solid @gray-40;
border-bottom: 1px solid @gray-40;
}
} );

// Desktop
Expand Down
60 changes: 37 additions & 23 deletions cfgov/v1/jinja2/v1/includes/molecules/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
{# ==========================================================================

breadcrumbs.render()
breadcrumbs.render()

==========================================================================
==========================================================================

Description:
Description:

Create breadcrumb markup when given:
Create breadcrumb markup when given:

breadcrumbs: An array of tuples used to display nav items.
Format: (href, live, title)
breadcrumbs: An array of tuples used to display nav items.
Format: (href, live, title)

========================================================================== #}
========================================================================== #}

{% macro render( breadcrumbs ) %}
<nav class="m-breadcrumbs" aria-label="{{ _('Breadcrumbs') }}">

{# Change slash direction in RTL languages. #}
{% if language == 'ar' %}
{% set crumb_divider = ' \\ ' %}
{% else %}
{% set crumb_divider = ' / ' %}
{% endif %}

{% for crumb in breadcrumbs %}

{% if loop.index == loop.length %}
Copy link
Member

Choose a reason for hiding this comment

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

@anselmbradford in response to your question about the leading slash: in Jinja for syntax the loop.index variable is 1-based, not 0-based. So if the length of the breadcrumbs is 1, this will render the divider the first time through the loop. See docs here, you can use loop.index0 instead.

I'm a bit unclear from your comments above with @jenn-franklin -- what is the desired behavior? If you don't want to render the slash if there's only one parent breadcrumb, you could remove this clause, but will it be obvious that this is a breadcrumb then?

Copy link
Member

Choose a reason for hiding this comment

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

We didn't include the first slash during usability testing, and participants didn't struggle to understand that it was a breadcrumb, so that's good! But... ugh... I'm waffling. Haha. I guess ultimately I may lean a little more toward including the first slash.

Copy link
Member Author

Choose a reason for hiding this comment

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

As is, http://localhost:8000/es/herramientas-del-consumidor/prestamos-para-vehiculos/respuestas/conozca-sus-derechos/ would not have a leading slash, while http://localhost:8000/es/coronavirus/maneje-sus-finanzas/ would. I guess we either always want the slash or always not have it?

Copy link
Member

Choose a reason for hiding this comment

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

Yah, I'd say always slash or never slash.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yah, I'd say always slash or never slash.

Which one though?

Copy link
Member

Choose a reason for hiding this comment

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

If it's helpful, Jinja has a random filter if we want to show slashes to some visitors but not others. Keep the cf.gov experience dynamic and interesting!

Copy link
Member

Choose a reason for hiding this comment

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

Let's go with slash!

{{ crumb_divider }}
{% endif %}

{% macro render( breadcrumbs ) %}
<nav class="breadcrumbs" aria-label="{{ _('Breadcrumbs') }}">
{{ svg_icon('left') }}
{% for crumb in breadcrumbs %}
{% if crumb.href or crumb.live %}
<a href="{{ crumb.href if crumb.href else pageurl(crumb) }}">
{{ crumb.title | e }}
<a class="m-breadcrumbs_crumb"
href="{{ crumb.href if crumb.href else pageurl(crumb) }}">
{{ crumb.title }}
</a>
{% else %}
<span class="breadcrumbs_text">{{ crumb.title | e }}</span>
<span class="m-breadcrumbs_crumb">
{{ crumb.title }}
</span>
{% endif %}
{% if not loop.last %}
{% if language == 'ar' %}
\
{% else %}
/
{% endif %}

{% if loop.index < loop.length - 1 %}
{{ crumb_divider }}
{% endif %}
{% endfor %}
</nav>
{% endmacro %}


{% endfor %}
</nav>
{% endmacro %}
6 changes: 3 additions & 3 deletions cfgov/v1/jinja2/v1/includes/organisms/secondary-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

<button class="o-secondary-nav_header" type="button" aria-expanded="false">
<span class="o-secondary-nav_label">
{{ _('In this section') }}
{{ _('Navigate this section') }}
</span>
<span class="o-secondary-nav_cues">
<span class="o-secondary-nav_cue-open" aria-label="Show">
{{ svg_icon('plus-round') }}
{{ svg_icon('down') }}
</span>
<span class="o-secondary-nav_cue-close" aria-label="Hide">
{{ svg_icon('minus-round') }}
{{ svg_icon('up') }}
</span>
</span>
</button>
Expand Down
Binary file modified cfgov/v1/locale/ar/LC_MESSAGES/django.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions cfgov/v1/locale/ar/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ msgid "Section navigation"
msgstr ""

#: v1/jinja2/v1/includes/organisms/secondary-nav.html:18
msgid "In this section"
msgstr "في هذا القسم"
msgid "Navigate this section"
msgstr "انتقل إلى هذا القسم"

#: v1/jinja2/v1/includes/organisms/video-player.html:60
msgid "Close video"
Expand Down
Binary file modified cfgov/v1/locale/es/LC_MESSAGES/django.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions cfgov/v1/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ msgid "Section navigation"
msgstr "Navegación de la sección"

#: v1/jinja2/v1/includes/organisms/secondary-nav.html:18
msgid "In this section"
msgstr "En esta sección"
msgid "Navigate this section"
msgstr "Navegue por esta sección"

#: v1/jinja2/v1/includes/organisms/video-player.html:60
msgid "Close video"
Expand Down
Binary file modified cfgov/v1/locale/ht/LC_MESSAGES/django.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions cfgov/v1/locale/ht/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ msgid "Section navigation"
msgstr ""

#: v1/jinja2/v1/includes/organisms/secondary-nav.html:18
msgid "In this section"
msgstr "Nan seksyon sa a"
msgid "Navigate this section"
msgstr "Vizite seksyon sa a"

#: v1/jinja2/v1/includes/organisms/video-player.html:60
msgid "Close video"
Expand Down
Binary file modified cfgov/v1/locale/ko/LC_MESSAGES/django.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions cfgov/v1/locale/ko/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ msgid "Section navigation"
msgstr ""

#: v1/jinja2/v1/includes/organisms/secondary-nav.html:18
msgid "In this section"
msgstr "이 섹션에서는"
msgid "Navigate this section"
msgstr "섹션 탐색하기"

#: v1/jinja2/v1/includes/organisms/video-player.html:60
msgid "Close video"
Expand Down
Binary file modified cfgov/v1/locale/ru/LC_MESSAGES/django.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions cfgov/v1/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ msgid "Section navigation"
msgstr ""

#: v1/jinja2/v1/includes/organisms/secondary-nav.html:18
msgid "In this section"
msgstr "В этом разделе"
msgid "Navigate this section"
msgstr "Навигация по этому разделу"

#: v1/jinja2/v1/includes/organisms/video-player.html:60
msgid "Close video"
Expand Down
Binary file modified cfgov/v1/locale/tl/LC_MESSAGES/django.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions cfgov/v1/locale/tl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ msgid "Section navigation"
msgstr ""

#: v1/jinja2/v1/includes/organisms/secondary-nav.html:18
msgid "In this section"
msgstr "Sa seksyong ito"
msgid "Navigate this section"
msgstr "Galugarin ang seksyong ito"

#: v1/jinja2/v1/includes/organisms/video-player.html:60
msgid "Close video"
Expand Down
Binary file modified cfgov/v1/locale/vi/LC_MESSAGES/django.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions cfgov/v1/locale/vi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ msgid "Section navigation"
msgstr ""

#: v1/jinja2/v1/includes/organisms/secondary-nav.html:18
msgid "In this section"
msgstr "Trong phần này"
msgid "Navigate this section"
msgstr "Điều hướng phần này"

#: v1/jinja2/v1/includes/organisms/video-player.html:60
msgid "Close video"
Expand Down
Binary file modified cfgov/v1/locale/zh_Hant/LC_MESSAGES/django.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions cfgov/v1/locale/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ msgid "Section navigation"
msgstr ""

#: v1/jinja2/v1/includes/organisms/secondary-nav.html:18
msgid "In this section"
msgstr "本節概述"
msgid "Navigate this section"
msgstr "瀏覽本部分"

#: v1/jinja2/v1/includes/organisms/video-player.html:60
msgid "Close video"
Expand Down
Loading