//// /// Copyright (c) 2016-2020 Martin Donath /// /// Permission is hereby granted, free of charge, to any person obtaining a /// copy of this software and associated documentation files (the "Software"), /// to deal in the Software without restriction, including without limitation /// the rights to use, copy, modify, merge, publish, distribute, sublicense, /// and/or sell copies of the Software, and to permit persons to whom the /// Software is furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL /// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING /// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER /// DEALINGS //// // ---------------------------------------------------------------------------- // Rules // ---------------------------------------------------------------------------- // Navigation container .md-nav { font-size: px2rem(14px); line-height: 1.3; // List title &__title { display: block; padding: 0 px2rem(12px); font-weight: 700; text-overflow: ellipsis; overflow: hidden; // Hide buttons by default .md-nav__button { display: none; // Stretch images img { width: 100%; height: auto; } // Logo &.md-logo svg { // Image or icon img, svg { display: block; width: px2rem(24px); height: px2rem(24px); fill: currentColor; } } } } // List of items &__list { margin: 0; padding: 0; list-style: none; } // List item &__item { padding: 0 px2rem(12px); // Add bottom spacing to last item &:last-child { padding-bottom: px2rem(12px); } // 2nd+ level items & & { padding-right: 0; // Adjust for right-to-left languages [dir="rtl"] & { padding-right: px2rem(12px); padding-left: 0; } // Remove bottom spacing for nested items &:last-child { padding-bottom: 0; } } } // Link inside item &__link { display: block; margin-top: 0.625em; transition: color 125ms; text-overflow: ellipsis; cursor: pointer; overflow: hidden; scroll-snap-align: start; // Hide link to table of contents by default - this will only match the // table of contents inside the drawer below and including tablet portrait html &[for="__toc"] { display: none; // Hide table of contents by default & ~ .md-nav { display: none; } } // Blurred link &[data-md-state="blur"] { color: var(--md-default-fg-color--light); } // Active link .md-nav__item &--active { color: var(--md-primary-fg-color); } // Reset active color for nested list titles .md-nav__item--nested > & { color: inherit; } // Focused or hovered link &:focus, &:hover { color: var(--md-accent-fg-color); } } // Repository containing source &__source { display: none; } // [tablet -]: Layered navigation @include break-to-device(tablet) { background-color: var(--md-default-bg-color); // Stretch primary navigation to drawer &--primary, &--primary .md-nav { display: flex; position: absolute; top: 0; right: 0; left: 0; flex-direction: column; height: 100%; z-index: 1; } // Adjust styles for primary navigation &--primary { // List title and item .md-nav__title, .md-nav__item { font-size: px2rem(16px); line-height: 1.5; } // List title .md-nav__title { position: relative; height: px2rem(112px); padding: px2rem(60px) px2rem(16px) px2rem(4px); background-color: var(--md-default-fg-color--lightest); color: var(--md-default-fg-color--light); font-weight: 400; line-height: px2rem(48px); white-space: nowrap; cursor: pointer; // Icon .md-nav__icon { display: block; position: absolute; top: px2rem(8px); left: px2rem(8px); width: px2rem(24px); height: px2rem(24px); margin: px2rem(4px); // Adjust for right-to-left languages [dir="rtl"] & { right: px2rem(8px); left: initial; } } // Main lists ~ .md-nav__list { background-color: var(--md-default-bg-color); box-shadow: inset 0 px2rem(1px) 0 var(--md-default-fg-color--lightest); overflow-y: auto; scroll-snap-type: y mandatory; // Remove border for first list item & > .md-nav__item:first-child { border-top: 0; } } // Site title in main navigation &[for="__drawer"] { position: relative; background-color: var(--md-primary-fg-color); color: var(--md-primary-bg-color); // Site logo .md-nav__button { display: block; position: absolute; top: px2rem(4px); left: px2rem(4px); width: px2rem(64px); height: px2rem(64px); margin: px2rem(4px); padding: px2rem(8px); font-size: px2rem(48px); } } } // Adjust for right-to-left languages html [dir="rtl"] & .md-nav__title { // Site title in main navigation &[for="__drawer"] .md-nav__button { right: px2rem(4px); left: initial; } } // List of items .md-nav__list { flex: 1; } // List item .md-nav__item { padding: 0; border-top: px2rem(1px) solid var(--md-default-fg-color--lightest); // Adjust for right-to-left languages [dir="rtl"] & { padding: 0; } // Increase spacing to account for icon &--nested > .md-nav__link { padding-right: px2rem(48px); // Adjust for right-to-left languages [dir="rtl"] & { padding-right: px2rem(16px); padding-left: px2rem(48px); } } // Active parent item &--active > .md-nav__link { color: var(--md-primary-fg-color); } } // Link inside item .md-nav__link { position: relative; margin-top: 0; padding: px2rem(12px) px2rem(16px); // Icon .md-nav__icon { position: absolute; top: 50%; right: px2rem(12px); margin-top: px2rem(-12px); color: inherit; font-size: px2rem(24px); // Adjust for right-to-left languages [dir="rtl"] & { right: initial; left: px2rem(12px); } } } // Icon .md-nav__icon { // Adjust for right-to-left languages [dir="rtl"] & { // Flip icon vertically svg { transform: scale(-1); } } } // Table of contents inside navigation .md-nav--secondary { // Set links to static to avoid unnecessary layering .md-nav__link { position: static; } // Set nested navigation for table of contents to static .md-nav { position: static; background-color: transparent; // 3rd level link .md-nav__link { padding-left: px2rem(28px); // Adjust for right-to-left languages [dir="rtl"] & { padding-right: px2rem(28px); padding-left: initial; } } // 4th level link .md-nav .md-nav__link { padding-left: px2rem(40px); // Adjust for right-to-left languages [dir="rtl"] & { padding-right: px2rem(40px); padding-left: initial; } } // 5th level link .md-nav .md-nav .md-nav__link { padding-left: px2rem(52px); // Adjust for right-to-left languages [dir="rtl"] & { padding-right: px2rem(52px); padding-left: initial; } } // 6th level link .md-nav .md-nav .md-nav .md-nav__link { padding-left: px2rem(64px); // Adjust for right-to-left languages [dir="rtl"] & { padding-right: px2rem(64px); padding-left: initial; } } } } } // Hide nested navigation by default .md-nav__toggle ~ & { display: flex; transform: translateX(100%); transition: transform 250ms cubic-bezier(0.8, 0, 0.6, 1), opacity 125ms 50ms; opacity: 0; // Adjust for right-to-left languages [dir="rtl"] & { transform: translateX(-100%); } } // Expand nested navigation, if toggle is checked .md-nav__toggle:checked ~ & { transform: translateX(0); transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1), opacity 125ms 125ms; opacity: 1; } } // [tablet portrait -]: Show table of contents in drawer @include break-to-device(tablet portrait) { // Show link to table of contents - higher specificity is necessary to // display the table of contents inside the drawer html &__link[for="__toc"] { display: block; padding-right: px2rem(48px); // Hide link to current item + .md-nav__link { display: none; } // Show table of contents & ~ .md-nav { display: flex; } } // Adjust for right-to-left languages html [dir="rtl"] &__link { padding-right: px2rem(16px); padding-left: px2rem(48px); } // Repository containing source &__source { display: block; padding: 0 px2rem(4px); background-color: var(--md-primary-fg-color--dark); color: var(--md-primary-bg-color); } } // [tablet landscape +]: Tree-like navigation @include break-from-device(tablet landscape) { // List title &--secondary .md-nav__title { // Snap to table of contents title &[for="__toc"] { scroll-snap-align: start; } // Hide icon .md-nav__icon { display: none; } } } // [screen +]: Tree-like navigation @include break-from-device(screen) { transition: max-height 250ms cubic-bezier(0.86, 0, 0.07, 1); // List title &--primary .md-nav__title { // Snap to site title &[for="__drawer"] { scroll-snap-align: start; } // Hide icon .md-nav__icon { display: none; } } // Hide nested navigation by default .md-nav__toggle ~ & { display: none; } // Show nested navigation, if toggle is checked .md-nav__toggle:checked ~ & { display: block; } // Hide titles for nested navigation &__item--nested > .md-nav > &__title { display: none; } // Icon &__icon { height: px2rem(18px); float: right; transition: transform 250ms; // Inline icon and adjust to match font size svg { display: inline-block; width: px2rem(18px); height: px2rem(18px); vertical-align: px2rem(-2px); } // Rotate icon for expanded lists .md-nav__item--nested .md-nav__toggle:checked ~ .md-nav__link & { transform: rotateZ(90deg); } } } }