-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(settings): sidebar navigation #451
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
57f6216
feat(settings): sidebar navigation
mhuggins e81518c
chore(sidebar): make sidebar sticky when scrolling
mhuggins c182c77
feat(settings): responsive sidebar navigation
mhuggins b4fae14
feat(settings): stick sidebar at correct y-offset
mhuggins bb9ed8f
chore(lint): disable no-descending-specificity
mhuggins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
.input { | ||
display: flex; | ||
align-items: center; | ||
margin-bottom: 0; | ||
|
||
.label { | ||
flex: 0 1 230px; | ||
|
2 changes: 1 addition & 1 deletion
2
src/renderer/settings/components/SectionContent/SectionContent.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.sectionContent { | ||
margin-bottom: 40px; | ||
padding-bottom: 40px; | ||
color: #494759; | ||
font-size: 14px; | ||
} |
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 |
---|---|---|
@@ -1,19 +1,64 @@ | ||
import React from 'react'; | ||
import { Element, scrollSpy } from 'react-scroll'; | ||
import { StickyContainer, Sticky } from 'react-sticky'; | ||
|
||
import Page from 'shared/components/Page'; | ||
import Panel from 'shared/components/Panel'; | ||
|
||
import GeneralSettings from '../GeneralSettings'; | ||
import NetworkSettings from '../NetworkSettings'; | ||
import SidebarLink from '../SidebarLink'; | ||
import styles from './Settings.scss'; | ||
|
||
export default function Settings() { | ||
return ( | ||
<Page className={styles.settings}> | ||
<Panel className={styles.panel}> | ||
<GeneralSettings /> | ||
<NetworkSettings /> | ||
</Panel> | ||
</Page> | ||
); | ||
export default class Settings extends React.PureComponent { | ||
state = { | ||
offset: 0 | ||
}; | ||
|
||
componentDidMount() { | ||
this.setState({ offset: this.container.node.offsetTop }); | ||
scrollSpy.update(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<StickyContainer id="settingsContainer" ref={this.registerRef} className={styles.settings}> | ||
<Page className={styles.page}> | ||
<Panel className={styles.panel}> | ||
<div className={styles.sidebar}> | ||
<Sticky relative topOffset={this.state.offset}> | ||
{({ style }) => ( | ||
<ul style={style}> | ||
<li> | ||
<SidebarLink to="general" containerId="settingsContainer"> | ||
General | ||
</SidebarLink> | ||
</li> | ||
<li> | ||
<SidebarLink to="network" containerId="settingsContainer"> | ||
Network | ||
</SidebarLink> | ||
</li> | ||
</ul> | ||
)} | ||
</Sticky> | ||
</div> | ||
|
||
<div className={styles.content}> | ||
<Element name="general"> | ||
<GeneralSettings /> | ||
</Element> | ||
<Element name="network"> | ||
<NetworkSettings /> | ||
</Element> | ||
</div> | ||
</Panel> | ||
</Page> | ||
</StickyContainer> | ||
); | ||
} | ||
|
||
registerRef = (el) => { | ||
this.container = el; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,41 @@ | ||
.settings { | ||
padding: 24px; | ||
position: relative; | ||
height: 100%; | ||
overflow-y: auto; | ||
|
||
.page { | ||
padding: 24px; | ||
} | ||
|
||
.panel { | ||
padding: 0 40px 20px; | ||
display: flex; | ||
|
||
.sidebar { | ||
flex: 0 0 auto; | ||
} | ||
|
||
.content { | ||
flex: 1 1 auto; | ||
} | ||
} | ||
|
||
.sidebar { | ||
width: 170px; | ||
box-shadow: inset -1px 0px 0px #d7d8de; | ||
|
||
ul { | ||
list-style: none; | ||
margin: 0; | ||
} | ||
} | ||
|
||
.content { | ||
padding: 0 40px; | ||
} | ||
|
||
@media only screen and (max-width: $responsive-width) { | ||
.sidebar { | ||
display: none; | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/renderer/settings/components/SidebarLink/SidebarLink.js
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,17 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-scroll'; | ||
|
||
import styles from './SidebarLink.scss'; | ||
|
||
export default function SidebarLink(props) { | ||
return ( | ||
<Link | ||
className={styles.sidebarLink} | ||
activeClass={styles.active} | ||
spy | ||
smooth | ||
duration={250} | ||
{...props} | ||
/> | ||
); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/renderer/settings/components/SidebarLink/SidebarLink.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,31 @@ | ||
.sidebarLink { | ||
display: block; | ||
height: 42px; | ||
line-height: 42px; | ||
padding: 0 16px; | ||
color: $light-text-color; | ||
font-size: 14px; | ||
font-weight: 500; | ||
text-decoration: none; | ||
cursor: pointer; | ||
-webkit-font-smoothing: antialiased; | ||
|
||
&.active, | ||
&:hover { | ||
color: $dark-text-color; | ||
} | ||
|
||
&.active { | ||
position: relative; | ||
|
||
&:after { | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
width: 2px; | ||
background: linear-gradient(0deg, #b9d532 0%, #5bba47 100%); | ||
} | ||
} | ||
} |
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 @@ | ||
export { default } from './SidebarLink'; |
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 |
---|---|---|
@@ -1,23 +1,19 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import { string, node } from 'prop-types'; | ||
import { string } from 'prop-types'; | ||
|
||
import styles from './Page.scss'; | ||
|
||
export default function Page(props) { | ||
return ( | ||
<div className={classNames(styles.page, props.className)}> | ||
{props.children} | ||
</div> | ||
<div {...props} className={classNames(styles.page, props.className)} /> | ||
); | ||
} | ||
|
||
Page.propTypes = { | ||
className: string, | ||
children: node | ||
className: string | ||
}; | ||
|
||
Page.defaultProps = { | ||
className: null, | ||
children: null | ||
className: null | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the issue with #412 again?
The issue is closed and the PR got merged in 😄