-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* trying out new design mobile * tweaked side nav to work on scroll * added correct file for arrow svg and tweaked padding * added arrow to graphic * refactored to export out side nav * ran yarn format * refactored to use state to add classname * refactored to store a map that holds DOM elements * refactored json file to be used for side nav
- Loading branch information
Chloe Hwang
authored
Jan 4, 2018
1 parent
25a2764
commit 659a17d
Showing
11 changed files
with
217 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react' | ||
import data from '../data/index.json' | ||
|
||
const SideNav = ({ graphics, currentSection }) => { | ||
const scrollToElement = (e, elem) => { | ||
e.preventDefault() | ||
|
||
window.scroll({ | ||
top: elem.offsetTop - 400, | ||
left: 0, | ||
behavior: 'smooth' | ||
}) | ||
} | ||
|
||
return ( | ||
<aside className="section-nav"> | ||
<nav> | ||
<ol className="section-nav__list"> | ||
{graphics.map(({ num, elem }) => ( | ||
<li | ||
key={num} | ||
className={ | ||
'section-nav__list__link' + | ||
(num === currentSection ? ' -active' : '') | ||
} | ||
> | ||
<a | ||
href={'#graphic-' + num} | ||
onClick={e => { | ||
scrollToElement(e, elem) | ||
}} | ||
> | ||
{data[num].heading} | ||
</a> | ||
</li> | ||
))} | ||
</ol> | ||
</nav> | ||
</aside> | ||
) | ||
} | ||
|
||
export default SideNav |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/microcosm-www-next/src/stylesheets/setup/_dimensions.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/microcosm-www-next/src/stylesheets/structure/_aside.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SECTION NAV (ASIDE) | ||
|
||
.section-nav { | ||
align-items: center; | ||
display: flex; | ||
height: 100vh; | ||
left: $page-gutter-mobile / 2; | ||
position: fixed; | ||
z-index: 1; | ||
|
||
@include breakpoint(large-desktop-up) { | ||
display: none; | ||
} | ||
} | ||
|
||
.section-nav__list__link { | ||
@include breakpoint(medium-desktop-down) { | ||
border-radius: 2px; | ||
border: 1px solid white; | ||
height: 10px; | ||
margin-top: 0.75rem; | ||
width: 10px; | ||
|
||
a { | ||
color: transparent; | ||
display: block; | ||
font-size: 1rem; | ||
line-height: 8px; | ||
padding-left: 1rem; | ||
text-decoration: none; | ||
vertical-align: top; | ||
width: 300px; | ||
} | ||
|
||
&.-active { | ||
background-color: white; | ||
} | ||
|
||
&:hover { | ||
background-color: white; | ||
|
||
a { | ||
color: white; | ||
text-shadow: 0px 0px 0.3em rgba(0, 0, 0, 0.5); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.