refactor(docs-infra): scope nav-item styles to the `<aio-nav-item>` element (#40704)

This commit ensures that all styles for the sidenav nav-items (which are
defined in `_sidenav.scss`) only apply to elements inside an
`<aio-nav-item>` element. This will prevent the styles accidentally
taking effect on a different part of the app.

PR Close #40704
This commit is contained in:
George Kalpakas 2021-02-05 12:48:56 +02:00 committed by Alex Rickabaugh
parent e043e52a4f
commit c9a40257d4
1 changed files with 126 additions and 124 deletions

View File

@ -3,24 +3,6 @@
transition: none; transition: none;
} }
aio-nav-menu {
display: block;
margin: 0 auto;
max-width: 268px;
&:first-of-type {
margin-top: 16px;
}
&:last-of-type {
margin-bottom: 16px;
}
ul, a {
margin: 0;
}
}
mat-sidenav-container.sidenav-container { mat-sidenav-container.sidenav-container {
background-color: $white; background-color: $white;
min-height: 100%; min-height: 100%;
@ -72,119 +54,139 @@ mat-sidenav-container.sidenav-container {
} }
} }
.vertical-menu-item { aio-nav-menu {
box-sizing: border-box; display: block;
color: $darkgray; margin: 0 auto;
cursor: pointer; max-width: 268px;
display: flex;
align-items: center;
justify-content: space-between;
overflow-wrap: break-word;
padding: 8px;
text-decoration: none;
text-align: left;
width: 100%;
word-wrap: break-word;
&:hover { &:first-of-type {
background-color: $lightgray; margin-top: 16px;
color: $blue;
text-shadow: 0 0 5px $white;
} }
&:focus { &:last-of-type {
outline: $focus-outline-onlight auto 2px; margin-bottom: 16px;
} }
&.selected { ul, a {
color: $darkblue; margin: 0;
} }
span { aio-nav-item {
padding-right: 32px; .vertical-menu-item {
} box-sizing: border-box;
color: $darkgray;
cursor: pointer;
display: flex;
align-items: center;
justify-content: space-between;
overflow-wrap: break-word;
padding: 8px;
text-decoration: none;
text-align: left;
width: 100%;
word-wrap: break-word;
//icons _within_ nav &:hover {
.mat-icon { background-color: $lightgray;
height: 24px; color: $blue;
width: 24px; text-shadow: 0 0 5px $white;
} }
}
&:focus {
button.vertical-menu-item { outline: $focus-outline-onlight auto 2px;
border: none; }
background-color: transparent;
margin: 0; &.selected {
width: 100%; color: $darkblue;
} }
.heading-children { span {
&.expanded { padding-right: 32px;
visibility: visible; }
opacity: 1;
padding-left: 0; //icons _within_ nav
max-height: 4000px; // Arbitrary max-height. Can increase if needed. Must have measurement to transition height. .mat-icon {
transition: visibility 500ms, opacity 500ms, max-height 500ms; height: 24px;
transition-timing-function: ease-in-out; width: 24px;
} }
}
&.collapsed {
overflow: hidden; // Needed to prevent unnecessary sidenav scrollbar. button.vertical-menu-item {
visibility: hidden; border: none;
padding-left: 0; background-color: transparent;
opacity: 0; margin: 0;
max-height: 1px; // Must have measurement to transition height. width: 100%;
transition: visibility 275ms, opacity 275ms, max-height 280ms; }
transition-timing-function: ease-out;
} .heading-children {
&.expanded {
.no-animations &.expanded, visibility: visible;
.no-animations &.collapsed { opacity: 1;
transition: none !important; padding-left: 0;
} max-height: 4000px; // Arbitrary max-height. Can increase if needed. Must have measurement to transition height.
} transition: visibility 500ms, opacity 500ms, max-height 500ms;
transition-timing-function: ease-in-out;
.level-1 { }
font-family: $main-font;
@include font-size(16); &.collapsed {
@include line-height(28); overflow: hidden; // Needed to prevent unnecessary sidenav scrollbar.
font-weight: 400; visibility: hidden;
padding-left: 20px; padding-left: 0;
margin: 0; opacity: 0;
transition: background-color 0.2s; max-height: 1px; // Must have measurement to transition height.
} transition: visibility 275ms, opacity 275ms, max-height 280ms;
transition-timing-function: ease-out;
.level-2 { }
font-family: $main-font;
@include font-size(14); .no-animations &.expanded,
@include line-height(24); .no-animations &.collapsed {
font-weight: 400; transition: none !important;
margin: 0; }
padding-left: 36px; }
}
.level-1 {
.level-3 { font-family: $main-font;
font-family: $main-font; @include font-size(16);
@include font-size(14); @include line-height(28);
@include line-height(24); font-weight: 400;
margin: 0; padding-left: 20px;
padding-left: 44px; margin: 0;
} transition: background-color 0.2s;
}
.level-4 {
font-family: $main-font; .level-2 {
@include font-size(14); font-family: $main-font;
@include line-height(24); @include font-size(14);
margin: 0; @include line-height(24);
padding-left: 52px; font-weight: 400;
} margin: 0;
padding-left: 36px;
.level-1, .level-2, .level-3 { }
&.collapsed > .mat-icon {
@include rotate(0deg); .level-3 {
} font-family: $main-font;
@include font-size(14);
&.expanded > .mat-icon { @include line-height(24);
@include rotate(90deg); margin: 0;
padding-left: 44px;
}
.level-4 {
font-family: $main-font;
@include font-size(14);
@include line-height(24);
margin: 0;
padding-left: 52px;
}
.level-1, .level-2, .level-3 {
&.collapsed > .mat-icon {
@include rotate(0deg);
}
&.expanded > .mat-icon {
@include rotate(90deg);
}
}
} }
} }