Only show active subsection on screen when tabs are active

This commit is contained in:
squidfunk 2017-01-28 17:56:34 +01:00
parent 79f277c8fe
commit c4ba189c05
21 changed files with 132 additions and 63 deletions

View File

@ -28,7 +28,7 @@ import changed from "gulp-changed"
export default (gulp, config) => { export default (gulp, config) => {
return () => { return () => {
return gulp.src(`${config.assets.src}/images/**/*.ico`) return gulp.src(`${config.assets.src}/images/**/favicon.*`)
.pipe(changed(`${config.assets.build}/images`)) .pipe(changed(`${config.assets.build}/images`))
.pipe(gulp.dest(`${config.assets.build}/images`)) .pipe(gulp.dest(`${config.assets.build}/images`))
} }

View File

@ -1,4 +1,4 @@
{% extends "main.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<h1>404 - Not found</h1> <h1>404 - Not found</h1>
{% endblock %} {% endblock %}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17,15 +17,13 @@
{% if config.site_favicon %} {% if config.site_favicon %}
<link rel="shortcut icon" href="{{ base_url }}/{{ config.site_favicon }}"> <link rel="shortcut icon" href="{{ base_url }}/{{ config.site_favicon }}">
{% else %} {% else %}
<link rel="shortcut icon" href="{{ base_url }}/assets/images/favicon.ico"> <link rel="shortcut icon" href="{{ base_url }}/assets/images/favicon.png">
{% endif %} {% endif %}
<meta name="generator" content="mkdocs+mkdocs-material#1.0.3"> <meta name="generator" content="mkdocs+mkdocs-material#1.0.3">
{% endblock %} {% endblock %}
{% block htmltitle %} {% block htmltitle %}
{% if page.title %} {% if page.title and not page.is_homepage %}
<title>{{ page.title }} - {{ config.site_name }}</title> <title>{{ page.title }} - {{ config.site_name }}</title>
{% elif config.site_description %}
<title>{{ config.site_name }} - {{ config.site_description }}</title>
{% else %} {% else %}
<title>{{ config.site_name }}</title> <title>{{ config.site_name }}</title>
{% endif %} {% endif %}
@ -45,7 +43,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-5bd62fe5d3.css"> <link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-22ac52ce22.css">
{% if config.extra.palette %} {% if config.extra.palette %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-02ce7adcc2.palette.css"> <link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-02ce7adcc2.palette.css">
{% endif %} {% endif %}
@ -128,7 +126,7 @@
{% endblock %} {% endblock %}
</div> </div>
{% block scripts %} {% block scripts %}
<script src="{{ base_url }}/assets/javascripts/application-ce981a9b53.js"></script> <script src="{{ base_url }}/assets/javascripts/application-baa758dc1b.js"></script>
<script>var config={url:{base:"{{ base_url }}"}},app=new Application(config);app.initialize()</script> <script>var config={url:{base:"{{ base_url }}"}},app=new Application(config);app.initialize()</script>
{% for path in extra_javascript %} {% for path in extra_javascript %}
<script src="{{ path }}"></script> <script src="{{ path }}"></script>

View File

@ -8,7 +8,7 @@
<label class="md-nav__link" for="{{ path }}"> <label class="md-nav__link" for="{{ path }}">
{{ nav_item.title }} {{ nav_item.title }}
</label> </label>
<nav class="md-nav" data-md-component="collapsible"> <nav class="md-nav" data-md-component="collapsible" data-md-level="{{ level }}">
<label class="md-nav__title" for="{{ path }}"> <label class="md-nav__title" for="{{ path }}">
{{ nav_item.title }} {{ nav_item.title }}
</label> </label>
@ -16,6 +16,7 @@
{% set base = path %} {% set base = path %}
{% for nav_item in nav_item.children %} {% for nav_item in nav_item.children %}
{% set path = base + "-" + loop.index | string %} {% set path = base + "-" + loop.index | string %}
{% set level = level + 1 %}
{% include "partials/nav-item.html" %} {% include "partials/nav-item.html" %}
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -1,4 +1,4 @@
<nav class="md-nav md-nav--primary"> <nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="drawer"> <label class="md-nav__title md-nav__title--site" for="drawer">
<i class="{% if config.extra.logo %} md-logo {% else %} md-icon md-icon--home {% endif %} md-nav__button"> <i class="{% if config.extra.logo %} md-logo {% else %} md-icon md-icon--home {% endif %} md-nav__button">
{% if config.extra.logo %} {% if config.extra.logo %}
@ -15,6 +15,7 @@
<ul class="md-nav__list" data-md-scrollfix> <ul class="md-nav__list" data-md-scrollfix>
{% for nav_item in nav %} {% for nav_item in nav %}
{% set path = "nav-" + loop.index | string %} {% set path = "nav-" + loop.index | string %}
{% set level = 1 %}
{% include "partials/nav-item.html" %} {% include "partials/nav-item.html" %}
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -1,11 +1,13 @@
<li class="md-tabs__item">
{% if nav_item.children and nav_item.children | length > 0 %} {% if nav_item.children and nav_item.children | length > 0 %}
<li class="md-tabs__item">
<a href="{{ nav_item.children[0].url }}" title="{{ nav_item.title }}" class="md-tabs__link {% if nav_item.active %} md-tabs__link--active {% endif %}"> <a href="{{ nav_item.children[0].url }}" title="{{ nav_item.title }}" class="md-tabs__link {% if nav_item.active %} md-tabs__link--active {% endif %}">
{{ nav_item.title }} {{ nav_item.title }}
</a> </a>
</li>
{% elif nav_item.url == base_url %} {% elif nav_item.url == base_url %}
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" class="md-tabs__link {% for nav_item_ in nav %} {{nav_item_.children | length}} {% if nav_item_.url == page.url and nav_item_.children | length == 0 %} md-tabs__link--active {% endif %} {% endfor %}"> <li class="md-tabs__item">
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" class="md-tabs__link {% for nav_item_ in nav %} {% if nav_item_.url == page.url and nav_item_.children | length == 0 %} md-tabs__link--active {% endif %} {% endfor %}">
{{ nav_item.title }} {{ nav_item.title }}
</a> </a>
{% endif %}
</li> </li>
{% endif %}

View File

@ -20,7 +20,7 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
{% extends "main.html" %} {% extends "base.html" %}
<!-- Content block --> <!-- Content block -->
{% block content %} {% block content %}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -53,6 +53,7 @@ export default class Shadow {
let current = this.el_ let current = this.el_
while ((current = current.previousElementSibling)) while ((current = current.previousElementSibling))
this.height_ += current.offsetHeight this.height_ += current.offsetHeight
this.update()
} }
/** /**

View File

@ -23,3 +23,60 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Nothing to see here, move along // Nothing to see here, move along
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// TODO: ONLY for screen+
.md-nav--primary {
// // WE'RE IN THE TOP LEVEL LIST
& > .md-nav__list {
> .md-nav__item > .md-nav__link {
display: none;
}
// the single nested entry that is active
> .md-nav__item--nested > .md-nav__toggle:checked ~ .md-nav__link {
display: block;
margin-top: 0; // TODO: this really sucks... refactor into margin collapse if possible
padding-top: 1.2rem; // TODO: first write gemini tests!
font-weight: 700;
cursor: text;
pointer-events: none;
&::after {
display: none;
}
}
> .md-nav__item--nested > .md-nav__toggle:checked ~ .md-nav {
margin-left: -1.2rem;
}
}
// WE'RE IN THE SUB LIST
// TODO: SET THE ACTIVE ITEM
// LINK IS ALREADY ACTIVE, MAYBE CHANGE
// & > .md-nav__list {
// > .md-nav__item {
// display: none;
// }
//
// > .md-nav__item--active {
// display: block;
//
// // OVERRIDE EXPAND...
// > .md-nav__link {
// font-weight: 700;
//
// &::after {
// display: none;
// }
// }
// }
// }
// [data-md-tier="1"] > .md-nav__list > .md-nav__item {
// padding-left: 0 !important;
//
// // data-attribute for LEVEL
// // data-md-level=0,1,2,3,4
// // fix nested nav selectors in nav.scss (and toc!)
// }
}

View File

@ -40,7 +40,7 @@
// Always show shadow, in case JavaScript is not available // Always show shadow, in case JavaScript is not available
.no-js & { .no-js & {
@include z-depth(2); @include z-depth(3);
} }
// [screen +]: Show shadow depending on scroll offset // [screen +]: Show shadow depending on scroll offset
@ -50,10 +50,6 @@
// Show and animate shadow // Show and animate shadow
&[data-md-state="shadow"] { &[data-md-state="shadow"] {
@include z-depth(3); @include z-depth(3);
transition:
background-color 0.25s,
box-shadow 0.25s;
} }
} }

View File

@ -66,7 +66,7 @@
// List item // List item
&__item { &__item {
padding: 0.625em 1.2rem 0; padding: 0 1.2rem;
// Add bottom spacing to last item // Add bottom spacing to last item
&:last-child { &:last-child {
@ -98,6 +98,7 @@
// Link inside item // Link inside item
&__link { &__link {
display: block; display: block;
margin-top: 0.625em;
transition: color 0.125s; transition: color 0.125s;
text-overflow: ellipsis; text-overflow: ellipsis;
cursor: pointer; cursor: pointer;
@ -289,6 +290,7 @@
// Link inside item // Link inside item
.md-nav__link { .md-nav__link {
position: relative; position: relative;
margin-top: 0;
padding: 1.6rem; padding: 1.6rem;
// Rotate icon // Rotate icon
@ -429,7 +431,8 @@
display: none; display: none;
} }
// Link inside item // Link inside item - ideally the link display method would be set to
// inline on screen, but this doesn't work with text ellipsis
&__link { &__link {
// Item contains a nested list // Item contains a nested list

View File

@ -29,6 +29,7 @@
width: 100%; width: 100%;
background: $md-color-primary; background: $md-color-primary;
overflow-x: scroll; overflow-x: scroll;
overflow-y: hidden;
// [tablet -]: Hide tabs for tablet and below, as they don't make any sense // [tablet -]: Hide tabs for tablet and below, as they don't make any sense
@include break-to-device(tablet) { @include break-to-device(tablet) {
@ -40,7 +41,6 @@
margin: 0; margin: 0;
margin-left: 0.4rem; margin-left: 0.4rem;
padding: 0; padding: 0;
transition: opacity 0.1s;
list-style: none; list-style: none;
white-space: nowrap; white-space: nowrap;
} }
@ -48,31 +48,41 @@
// List item // List item
&__item { &__item {
display: inline-block; display: inline-block;
} height: 4.8rem;
// Link inside item
&__link {
display: block;
padding-right: 1.2rem; padding-right: 1.2rem;
padding-left: 1.2rem; padding-left: 1.2rem;
}
// Link inside item - could be defined as block elements and aligned via
// line height, but this would imply more repaints when scrolling
&__link {
display: block;
margin-top: 1.6rem;
transition: transition:
color 0.25s, color 0.25s,
transform 0.4s cubic-bezier(0.1, 0.7, 0.1, 1); transform 0.4s cubic-bezier(0.1, 0.7, 0.1, 1),
opacity 0.1s;
color: $md-color-white--light; color: $md-color-white--light;
font-size: 1.4rem; font-size: 1.4rem;
line-height: 4.8rem;
// Active or hovered link // Active or hovered link
&--active, &--active,
&:hover { &:hover {
color: $md-color-white; color: $md-color-white;
} }
// Delay transitions by a small amount
@for $i from 2 through 16 {
.md-tabs__item:nth-child(#{$i}) & {
transition-delay: 0.02s * ($i - 1);
}
}
} }
// Hide tabs upon scrolling - disable transition to minimizes repaints whilte // Hide tabs upon scrolling - disable transition to minimizes repaints whilte
// scrolling down, while scrolling up seems to be okay // scrolling down, while scrolling up seems to be okay
&[data-md-state="hidden"] .md-tabs__link { &[data-md-state="hidden"] .md-tabs__link {
transform: translateY(10%); transform: translateY(50%);
transition: none; transition: none;
opacity: 0; opacity: 0;
} }

View File

@ -52,7 +52,7 @@
href="{{ base_url }}/{{ config.site_favicon }}"> href="{{ base_url }}/{{ config.site_favicon }}">
{% else %} {% else %}
<link rel="shortcut icon" <link rel="shortcut icon"
href="{{ base_url }}/assets/images/favicon.ico"> href="{{ base_url }}/assets/images/favicon.png">
{% endif %} {% endif %}
<!-- Generator banner --> <!-- Generator banner -->
@ -61,10 +61,8 @@
<!-- Block: site title --> <!-- Block: site title -->
{% block htmltitle %} {% block htmltitle %}
{% if page.title %} {% if page.title and not page.is_homepage %}
<title>{{ page.title }} - {{ config.site_name }}</title> <title>{{ page.title }} - {{ config.site_name }}</title>
{% elif config.site_description %}
<title>{{ config.site_name }} - {{ config.site_description }}</title>
{% else %} {% else %}
<title>{{ config.site_name }}</title> <title>{{ config.site_name }}</title>
{% endif %} {% endif %}

View File

@ -37,7 +37,8 @@
<label class="md-nav__link" for="{{ path }}"> <label class="md-nav__link" for="{{ path }}">
{{ nav_item.title }} {{ nav_item.title }}
</label> </label>
<nav class="md-nav" data-md-component="collapsible"> <nav class="md-nav" data-md-component="collapsible"
data-md-level="{{ level }}">
<label class="md-nav__title" for="{{ path }}"> <label class="md-nav__title" for="{{ path }}">
{{ nav_item.title }} {{ nav_item.title }}
</label> </label>
@ -47,6 +48,7 @@
{% set base = path %} {% set base = path %}
{% for nav_item in nav_item.children %} {% for nav_item in nav_item.children %}
{% set path = base + "-" + loop.index | string %} {% set path = base + "-" + loop.index | string %}
{% set level = level + 1 %}
{% include "partials/nav-item.html" %} {% include "partials/nav-item.html" %}
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -21,7 +21,7 @@
--> -->
<!-- Main navigation --> <!-- Main navigation -->
<nav class="md-nav md-nav--primary"> <nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="drawer"> <label class="md-nav__title md-nav__title--site" for="drawer">
<i class=" <i class="
{% if config.extra.logo %} {% if config.extra.logo %}
@ -43,6 +43,7 @@
<ul class="md-nav__list" data-md-scrollfix> <ul class="md-nav__list" data-md-scrollfix>
{% for nav_item in nav %} {% for nav_item in nav %}
{% set path = "nav-" + loop.index | string %} {% set path = "nav-" + loop.index | string %}
{% set level = 1 %}
{% include "partials/nav-item.html" %} {% include "partials/nav-item.html" %}
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -20,11 +20,9 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
<!-- Tab item -->
<li class="md-tabs__item">
<!-- Main navigation item with nested items --> <!-- Main navigation item with nested items -->
{% if nav_item.children and nav_item.children | length > 0 %} {% if nav_item.children and nav_item.children | length > 0 %}
<li class="md-tabs__item">
<a href="{{ nav_item.children[0].url }}" title="{{ nav_item.title }}" <a href="{{ nav_item.children[0].url }}" title="{{ nav_item.title }}"
class="md-tabs__link class="md-tabs__link
{% if nav_item.active %} {% if nav_item.active %}
@ -32,9 +30,11 @@
{% endif %}"> {% endif %}">
{{ nav_item.title }} {{ nav_item.title }}
</a> </a>
</li>
<!-- Home page --> <!-- Home page -->
{% elif nav_item.url == base_url %} {% elif nav_item.url == base_url %}
<li class="md-tabs__item">
<!-- <!--
Hack: the item should be active, if we're sure that we're on the first Hack: the item should be active, if we're sure that we're on the first
@ -43,7 +43,6 @@
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" <a href="{{ nav_item.url }}" title="{{ nav_item.title }}"
class="md-tabs__link class="md-tabs__link
{% for nav_item_ in nav %} {% for nav_item_ in nav %}
{{nav_item_.children | length}}
{% if nav_item_.url == page.url and {% if nav_item_.url == page.url and
nav_item_.children | length == 0 %} nav_item_.children | length == 0 %}
md-tabs__link--active md-tabs__link--active
@ -51,5 +50,5 @@
{% endfor %}"> {% endfor %}">
{{ nav_item.title }} {{ nav_item.title }}
</a> </a>
{% endif %}
</li> </li>
{% endif %}