Skip to content

Commit cebf0c9

Browse files
bradfrostbmuenzenmeyer
authored andcommitted
Nav active states
1 parent efe5c37 commit cebf0c9

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

packages/docs/src/_data/navigation.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"items": [
33
{
44
"label": "Getting Started",
5-
"url": "/docs/installing-pattern-lab"
5+
"url": "/docs/installing-pattern-lab/"
66
},
77
{
88
"label": "Documentation",
9-
"url": "/docs",
9+
"url": "/docs/",
1010
"subnavIsClosed": true,
1111
"subnav": [
1212
{
@@ -29,11 +29,11 @@
2929
},
3030
{
3131
"label": "Resources",
32-
"url": "/resources"
32+
"url": "/resources/"
3333
},
3434
{
3535
"label": "Demos",
36-
"url": "/demos"
36+
"url": "/demos/"
3737
},
3838
{
3939
"label": "On Github",

packages/docs/src/js/primary-nav.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,24 @@
3030
});
3131
}
3232

33+
/**
34+
* Expose docs dropdown if on a docs page
35+
*/
3336
if (window.location.href.indexOf('docs') > -1) {
34-
console.log('yellllll');
3537
navDropdownListItem.classList.add('is-active');
3638
}
3739

40+
var pathName = location.pathname;
41+
42+
var navLinks = document.querySelectorAll('.c-tree-nav a');
43+
44+
for (i = 0; i < navLinks.length; i++) {
45+
var subnavLink = navLinks[i].getAttribute('href');
46+
if (subnavLink == pathName) {
47+
navLinks[i].classList.add('is-active');
48+
}
49+
}
50+
3851
/**
3952
* Toggles active class on the primary nav panel
4053
* 1) Select all nav triggers and cycle through them

packages/docs/src/scss/abstracts/_variables.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* Brand Colors
4242
* 1) Brand=specific colors
4343
*/
44-
$color-brand-green: #08ce37;
44+
$color-brand-green: #0c9f2e;
4545
$color-brand-green-transparent: rgba(8, 206, 55, 0.05);
4646
$color-brand-purple-transparent: rgba(220, 193, 232, 0.2);
4747

@@ -50,7 +50,7 @@ $color-brand-purple-transparent: rgba(220, 193, 232, 0.2);
5050
* 1) Neutral colors are grayscale values used throughout the UI
5151
*/
5252
$color-white: #fff;
53-
$color-gray-02: #f9f9f9;
53+
$color-gray-02: #f2f2f2;
5454
$color-gray-07: #eee;
5555
$color-gray-13: #ddd;
5656
$color-gray-27: #bbb;

packages/docs/src/scss/components/_tree-nav.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
font-weight: $font-weight-bold;
1818
transition: color 0.2s ease;
1919

20-
&:hover {
20+
&:hover,
21+
&.is-active {
2122
color: $color-white;
2223
}
2324

@@ -61,7 +62,8 @@
6162
margin-bottom: 1rem;
6263

6364
&:hover,
64-
&:focus {
65+
&:focus,
66+
&.is-active {
6567
color: $color-white;
6668
}
6769

0 commit comments

Comments
 (0)