Hoisted active state of navigation tabs link into item

This commit is contained in:
squidfunk 2023-07-06 15:45:36 +02:00
parent aa752900e5
commit 7ef079012b
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
9 changed files with 26 additions and 21 deletions

View File

@ -44,7 +44,7 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.92d4c850.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/main.0c456da8.min.css' | url }}">
{% if config.theme.palette %} {% if config.theme.palette %}
{% set palette = config.theme.palette %} {% set palette = config.theme.palette %}
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.ecc896b0.min.css' | url }}"> <link rel="stylesheet" href="{{ 'assets/stylesheets/palette.ecc896b0.min.css' | url }}">

View File

@ -10,24 +10,24 @@
{{ ref.title }} {{ ref.title }}
{% endmacro %} {% endmacro %}
{% macro render(nav_item, ref = nav_item) %} {% macro render(nav_item, ref = nav_item) %}
{% set class = "md-tabs__link" %} {% set class = "md-tabs__item" %}
{% if ref.active %} {% if ref.active %}
{% set class = class ~ " md-tabs__link--active" %} {% set class = class ~ " md-tabs__item--active" %}
{% endif %} {% endif %}
{% if nav_item.children %} {% if nav_item.children %}
{% set first = nav_item.children | first %} {% set first = nav_item.children | first %}
{% if first.children %} {% if first.children %}
{{ render(first, ref) }} {{ render(first, ref) }}
{% else %} {% else %}
<li class="md-tabs__item"> <li class="{{ class }}">
<a href="{{ first.url | url }}" class="{{ class }}"> <a href="{{ first.url | url }}" class="md-tabs__link">
{{ render_content(first, ref) }} {{ render_content(first, ref) }}
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% else %} {% else %}
<li class="md-tabs__item"> <li class="{{ class }}">
<a href="{{ nav_item.url | url }}" class="{{ class }}"> <a href="{{ nav_item.url | url }}" class="md-tabs__link">
{{ render_content(nav_item) }} {{ render_content(nav_item) }}
</a> </a>
</li> </li>

View File

@ -77,6 +77,12 @@
&__item { &__item {
height: px2rem(48px); height: px2rem(48px);
padding-inline: px2rem(12px); padding-inline: px2rem(12px);
// Navigation tabs link in active navigation
&--active .md-tabs__link {
color: inherit;
opacity: 1;
}
} }
// Navigation tabs link - could be defined as block elements and aligned via // Navigation tabs link - could be defined as block elements and aligned via
@ -94,8 +100,7 @@
transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1), transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),
opacity 250ms; opacity 250ms;
// Active link and link on focus/hover // Navigation tabs link on focus/hover
&--active,
&:is(:focus, :hover) { &:is(:focus, :hover) {
color: inherit; color: inherit;
opacity: 1; opacity: 1;

View File

@ -20,7 +20,7 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
<!-- Determine base classes --> <!-- Determine classes -->
{% set class = "md-header" %} {% set class = "md-header" %}
{% if "navigation.tabs.sticky" in features %} {% if "navigation.tabs.sticky" in features %}
{% set class = class ~ " md-header--shadow md-header--lifted" %} {% set class = class ~ " md-header--shadow md-header--lifted" %}

View File

@ -81,7 +81,7 @@
<!-- Render navigation item --> <!-- Render navigation item -->
{% macro render(nav_item, path, level) %} {% macro render(nav_item, path, level) %}
<!-- Determine base classes --> <!-- Determine classes -->
{% set class = "md-nav__item" %} {% set class = "md-nav__item" %}
{% if nav_item.active %} {% if nav_item.active %}
{% set class = class ~ " md-nav__item--active" %} {% set class = class ~ " md-nav__item--active" %}

View File

@ -22,7 +22,7 @@
{% import "partials/nav-item.html" as item with context %} {% import "partials/nav-item.html" as item with context %}
<!-- Determine base classes --> <!-- Determine classes -->
{% set class = "md-nav md-nav--primary" %} {% set class = "md-nav md-nav--primary" %}
{% if "navigation.tabs" in features %} {% if "navigation.tabs" in features %}
{% set class = class ~ " md-nav--lifted" %} {% set class = class ~ " md-nav--lifted" %}

View File

@ -37,10 +37,10 @@
<!-- Render navigation item --> <!-- Render navigation item -->
{% macro render(nav_item, ref = nav_item) %} {% macro render(nav_item, ref = nav_item) %}
<!-- Determine class according to state --> <!-- Determine classes -->
{% set class = "md-tabs__link" %} {% set class = "md-tabs__item" %}
{% if ref.active %} {% if ref.active %}
{% set class = class ~ " md-tabs__link--active" %} {% set class = class ~ " md-tabs__item--active" %}
{% endif %} {% endif %}
<!-- Navigation item with nested items --> <!-- Navigation item with nested items -->
@ -53,8 +53,8 @@
<!-- Nested navigation item --> <!-- Nested navigation item -->
{% else %} {% else %}
<li class="md-tabs__item"> <li class="{{ class }}">
<a href="{{ first.url | url }}" class="{{ class }}"> <a href="{{ first.url | url }}" class="md-tabs__link">
{{ render_content(first, ref) }} {{ render_content(first, ref) }}
</a> </a>
</li> </li>
@ -62,8 +62,8 @@
<!-- Navigation item --> <!-- Navigation item -->
{% else %} {% else %}
<li class="md-tabs__item"> <li class="{{ class }}">
<a href="{{ nav_item.url | url }}" class="{{ class }}"> <a href="{{ nav_item.url | url }}" class="md-tabs__link">
{{ render_content(nav_item) }} {{ render_content(nav_item) }}
</a> </a>
</li> </li>