Skip to content

Commit

Permalink
💄 style: improve navigation bar & metadata wrapping (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo authored Nov 11, 2024
1 parent 0253799 commit 42f9bb9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 35 deletions.
33 changes: 24 additions & 9 deletions sass/parts/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,27 @@ header {
.nav-navs {
display: flex;
flex-wrap: wrap;
align-items: center;

ul {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
flex-wrap: inherit;
justify-content: inherit;
align-items: inherit;
gap: inherit;
gap: 1px;
margin: 0;
padding: 0;
list-style: none;
}
}

#menu-icons-group {
gap: 1px;
margin: 0;
padding: 0;
}

.nav-links {
justify-content: right;
padding: 0.66rem;
Expand Down Expand Up @@ -76,11 +84,22 @@ header {

ul,
li {
display: inline;
display: inline-block;
margin-inline-end: 0.2rem;
font-family: var(--sans-serif-font);
list-style-type: none;
}

.tag {
margin-inline-end: 0;
}

.separator {
margin-inline-end: 0.2rem;
user-select: none;
}
}

.language-switcher {
display: flex;
justify-content: center;
Expand Down Expand Up @@ -147,21 +166,17 @@ header {

.nav-navs {
display: flex;
justify-content: flex-end;
justify-content: center;
}
}

@media only screen and (max-width: 600px) {
.nav-navs {
flex-wrap: wrap;
justify-content: center;
margin-top: 0.8rem;
width: 100%;
}

.navbar {
flex-direction: column;
justify-content: center;
align-items: center;
}
}
Expand Down
13 changes: 7 additions & 6 deletions templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,26 @@ <h1 class="article-title">
{%- set previous_visible = true -%}
{% endif %}

{%- set separator_with_class = "<span class='separator' aria-hidden='true'>" ~ separator ~ "</span>"-%}

{#- Date -#}
{% if page.date and macros_settings::evaluate_setting_priority(setting="show_date", page=page, default_global_value=true) == "true" %}
{%- if previous_visible -%}&nbsp;{{ separator }}&nbsp;{%- endif -%}<li>{{ macros_format_date::format_date(date=page.date, short=true, language_strings=language_strings) }}</li>
<li>{%- if previous_visible -%}{{ separator_with_class | safe }}{%- endif -%}{{ macros_format_date::format_date(date=page.date, short=true, language_strings=language_strings) }}</li>
{#- Variable to keep track of whether we've shown a section, to avoid separators as the first element -#}
{%- set previous_visible = true -%}
{% endif %}

{#- Reading time -#}
{% if macros_settings::evaluate_setting_priority(setting="show_reading_time", page=page, default_global_value=true) == "true" %}
{%- if previous_visible -%}&nbsp;{{ separator }}&nbsp;{%- endif -%}<li title="{{ macros_translate::translate(key="words", number=page.word_count, default="$NUMBER words", language_strings=language_strings) }}">{{ macros_translate::translate(key="min_read", number=page.reading_time, default="$NUMBER min read", language_strings=language_strings) }}</li>
<li title="{{ macros_translate::translate(key="words", number=page.word_count, default="$NUMBER words", language_strings=language_strings) }}">{%- if previous_visible -%}{{ separator_with_class | safe }}{%- endif -%}{{ macros_translate::translate(key="min_read", number=page.reading_time, default="$NUMBER min read", language_strings=language_strings) }}</li>
{%- set previous_visible = true -%}
{% endif %}

{#- Tags -#}
{%- if page.taxonomies and page.taxonomies.tags -%}
{%- if previous_visible -%}&nbsp;{{ separator }}&nbsp;{%- endif -%}<li>{{- macros_translate::translate(key="tags", default="tags", language_strings=language_strings) | capitalize -}}:&nbsp;</li>
<li class="tag">{%- if previous_visible -%}{{ separator_with_class | safe }}{%- endif -%}{{- macros_translate::translate(key="tags", default="tags", language_strings=language_strings) | capitalize -}}:&nbsp;</li>
{%- for tag in page.taxonomies.tags -%}
<li><a href="{{ get_taxonomy_url(kind='tags', name=tag, lang=lang) | safe }}">{{ tag }}</a>
<li class="tag"><a href="{{ get_taxonomy_url(kind='tags', name=tag, lang=lang) | safe }}">{{ tag }}</a>
{%- if not loop.last -%}
,&nbsp;
{%- endif -%}
Expand All @@ -174,8 +176,7 @@ <h1 class="article-title">
</ul><ul class="meta last-updated"><li>{{ updated_str }}</li>
{# Show link to remote changes if enabled #}
{% if config.extra.remote_repository_url and macros_settings::evaluate_setting_priority(setting="show_remote_changes", page=page, default_global_value=true) == "true" %}
{%- if previous_visible -%}{{ separator }}&nbsp;{%- endif -%}
<li><a href="{% include "partials/history_url.html" %}" {{ blank_target }} rel="{{ rel_attributes }}">{{ macros_translate::translate(key="see_changes", default="See changes", language_strings=language_strings) }}<small>&nbsp;<span class="arrow-corner"></span></small></a></li>
<li>{%- if previous_visible -%}{{ separator_with_class | safe }}{%- endif -%}<a href="{% include "partials/history_url.html" %}" {{ blank_target }} rel="{{ rel_attributes }}">{{ macros_translate::translate(key="see_changes", default="See changes", language_strings=language_strings) }}<small>&nbsp;<span class="arrow-corner"></span></small></a></li>
{% endif %}
{% endif %}
</ul>
Expand Down
43 changes: 23 additions & 20 deletions templates/partials/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,31 @@
{% endfor %}
{%- endif -%}

{# Search #}
{%- if config.build_search_index %}
{%- set search_icon_title = macros_translate::translate(key='search_icon_title', default='Press $SHORTCUT to open search', language_strings=language_strings) -%}
<li class="js">
<div role="button" tabindex="0" id="search-button" class="search-icon interactive-icon" title="{{ search_icon_title }}" aria-label="{{ search_icon_title }}">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960">
<path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/>
</svg>
</div>
</li>
{%- endif %}
{#- Wrap the icons in a div to keep them all together -#}
<div class="nav-navs" id="menu-icons-group">
{# Search #}
{%- if config.build_search_index %}
{%- set search_icon_title = macros_translate::translate(key='search_icon_title', default='Press $SHORTCUT to open search', language_strings=language_strings) -%}
<li class="js">
<div role="button" tabindex="0" id="search-button" class="search-icon interactive-icon" title="{{ search_icon_title }}" aria-label="{{ search_icon_title }}">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960">
<path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/>
</svg>
</div>
</li>
{%- endif %}

{# Language switcher #}
{# Display the language switcher only if more than one language is available #}
{%- if config.languages | length > 0 %}
{% include "partials/language_switcher.html" %}
{%- endif %}
{# Language switcher #}
{# Displayed only if more than one language is available #}
{%- if config.languages | length > 0 %}
{% include "partials/language_switcher.html" %}
{%- endif %}

{# Theme switcher #}
{%- if config.extra.theme_switcher and config.extra.theme_switcher == true -%}
{%- include "partials/theme_switcher.html" -%}
{%- endif -%}
{# Theme switcher #}
{%- if config.extra.theme_switcher and config.extra.theme_switcher == true -%}
{%- include "partials/theme_switcher.html" -%}
{%- endif -%}
</div>
</ul>
</div>
{% endif %}
Expand Down

0 comments on commit 42f9bb9

Please sign in to comment.