Skip to content

Commit c9d488c

Browse files
Collapse nav sections (#41)
* styles put back * animations, collapse others on opening one * improved timing function * add overflow hidden * remove auto collapsing * make secondary nav sticky
1 parent 766836f commit c9d488c

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

src/css/nav.css

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
width: 100%;
88
z-index: var(--z-index-nav);
99
visibility: hidden;
10+
11+
--transition-duration: 300ms;
1012
}
1113

1214
@media screen and (min-width: 769px) {
@@ -95,6 +97,23 @@ html.is-clipped--nav {
9597
margin: 0;
9698
}
9799

100+
.nav-item > .nav-list {
101+
transition-duration: var(--transition-duration);
102+
transition-delay: 0s;
103+
transition-timing-function: cubic-bezier(0, 1, 0, 1), ease, linear;
104+
transition-property: max-height, opacity, visibility;
105+
max-height: 100vh;
106+
opacity: 1;
107+
}
108+
109+
.nav-item:not(.is-active) > .nav-list {
110+
transition-delay: 0s, 0s, var(--transition-duration);
111+
max-height: 0;
112+
opacity: 0;
113+
visibility: hidden;
114+
overflow: hidden;
115+
}
116+
98117
.nav-item {
99118
display: flex;
100119
flex-direction: column;
@@ -105,14 +124,7 @@ html.is-clipped--nav {
105124
position: relative;
106125
display: flex;
107126
align-items: center;
108-
padding: var(--ds-space-1) var(--site-padding);
109-
}
110-
111-
@media screen and (max-width: 1023.5px) {
112-
.nav-link,
113-
.nav-text {
114-
padding: var(--ds-space-1) var(--site-padding--mobile);
115-
}
127+
padding: 1rem 3rem 1rem var(--site-padding);
116128
}
117129

118130
.nav-link {
@@ -174,6 +186,9 @@ html.is-clipped--nav {
174186
margin: 0;
175187
padding: var(--ds-space-2) 0;
176188
margin-top: auto;
189+
position: sticky;
190+
background: var(--ds-background-body);
191+
bottom: 0;
177192
}
178193

179194
.secondary-nav-list .nav-item {
@@ -184,28 +199,16 @@ html.is-clipped--nav {
184199
content: "\e89e";
185200
}
186201

187-
/*** nav-item toggle styles, keeping for now as we might implement again when more content is added ***/
188-
189-
/* .nav-item:not(.is-active) > .nav-list {
190-
display: none;
191-
} */
192-
193-
/* .nav-item-toggle {
194-
background: transparent url(../img/caret.svg) no-repeat center / 50%;
195-
border: none;
196-
outline: none;
197-
line-height: inherit;
198-
padding: 0;
202+
.nav-item-toggle {
199203
position: absolute;
200-
height: calc(var(--nav-line-height) * 1em);
201-
width: calc(var(--nav-line-height) * 1em);
202-
margin-top: -0.05em;
203-
margin-left: calc(var(--nav-line-height) * -1em);
204-
} */
204+
margin-top: 0.75em;
205+
margin-left: 0.5em;
206+
color: var(--ds-text-tertiary);
207+
}
205208

206-
/* .nav-item.is-active > .nav-item-toggle {
209+
.nav-item.is-active > .nav-item-toggle {
207210
transform: rotate(90deg);
208-
} */
211+
}
209212

210213
/*** nav-panel-explore styles, keeping for now as we might implement it elsewhere ***/
211214

src/partials/nav-tree.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
{{#each navigation}}
44
<li class="nav-item{{#if (eq ./url @root.page.url)}} is-current-page{{/if}}" data-depth="{{or ../level 0}}">
55
{{#if ./content}}
6-
{{!-- {{#if ./items.length}} --}}
7-
{{!-- <button class="nav-item-toggle"></button> --}}
8-
{{!-- {{/if}} --}}
6+
{{#if ./items.length}}
7+
<button class="nav-item-toggle material-icons">chevron_right</button>
8+
{{/if}}
99
{{#if ./url}}
1010
<a class="nav-link" href="
1111
{{~#if (eq ./urlType 'internal')}}{{{relativize ./url}}}

0 commit comments

Comments
 (0)