Skip to content

Commit 15fc325

Browse files
committed
Run check-all script
1 parent e9d0884 commit 15fc325

File tree

7 files changed

+47
-42
lines changed

7 files changed

+47
-42
lines changed

src/components/MarkdownPage/MarkdownPage.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import createOgUrl from 'utils/createOgUrl';
2525
const MarkdownPage = ({
2626
authors,
2727
createLink,
28-
date,
29-
enableScrollSync,
28+
date,
29+
enableScrollSync,
3030
ogDescription,
3131
location,
3232
markdownRemark,
@@ -99,7 +99,7 @@ const MarkdownPage = ({
9999

100100
<div css={sharedStyles.articleLayout.sidebar}>
101101
<StickyResponsiveSidebar
102-
enableScrollSync={enableScrollSync}
102+
enableScrollSync={enableScrollSync}
103103
createLink={createLink}
104104
defaultActiveSection={findSectionForPath(
105105
location.pathname,
@@ -133,8 +133,8 @@ MarkdownPage.defaultProps = {
133133
MarkdownPage.propTypes = {
134134
authors: PropTypes.array.isRequired,
135135
createLink: PropTypes.func.isRequired,
136-
date: PropTypes.string,
137-
enableScrollSync: PropTypes.bool,
136+
date: PropTypes.string,
137+
enableScrollSync: PropTypes.bool,
138138
location: PropTypes.object.isRequired,
139139
markdownRemark: PropTypes.object.isRequired,
140140
sectionList: PropTypes.array.isRequired,

src/templates/components/Sidebar/ScrollSyncSection.js

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,36 @@ class ScrollSyncSection extends Component {
2121
itemTopOffsets: [],
2222
};
2323

24-
this.calculateItemTopOffsets = this.calculateItemTopOffsets.bind(this);
25-
this.handleResize = this.handleResize.bind(this);
24+
this.calculateItemTopOffsets = this.calculateItemTopOffsets.bind(this);
25+
this.handleResize = this.handleResize.bind(this);
2626
this.handleScroll = this.handleScroll.bind(this);
2727
}
2828

2929
componentDidMount() {
3030
this.calculateItemTopOffsets();
3131

32-
window.addEventListener('resize', this.handleResize);
33-
window.addEventListener('scroll', this.handleScroll);
32+
window.addEventListener('resize', this.handleResize);
33+
window.addEventListener('scroll', this.handleScroll);
3434
}
3535

3636
componentWillUnmount() {
37-
window.removeEventListener('resize', this.handleResize);
38-
window.removeEventListener('scroll', this.handleScroll);
39-
}
37+
window.removeEventListener('resize', this.handleResize);
38+
window.removeEventListener('scroll', this.handleScroll);
39+
}
4040

41-
calculateItemTopOffsets() {
42-
const {section} = this.props;
41+
calculateItemTopOffsets() {
42+
const {section} = this.props;
4343

44-
const itemIds = _getItemIds(section.items);
45-
this.setState({
46-
itemTopOffsets: _getElementTopOffsetsById(itemIds),
47-
});
48-
}
44+
const itemIds = _getItemIds(section.items);
45+
this.setState({
46+
itemTopOffsets: _getElementTopOffsetsById(itemIds),
47+
});
48+
}
4949

50-
handleResize() {
51-
this.calculateItemTopOffsets();
52-
this.handleScroll();
53-
}
50+
handleResize() {
51+
this.calculateItemTopOffsets();
52+
this.handleScroll();
53+
}
5454

5555
handleScroll() {
5656
const {itemTopOffsets} = this.state;
@@ -63,20 +63,15 @@ class ScrollSyncSection extends Component {
6363
);
6464
}
6565
return window.scrollY >= itemTopOffset.offsetTop;
66-
});
66+
});
6767
this.setState({
6868
activeItemId: item ? item.id : '',
6969
});
7070
}
7171

7272
render() {
7373
const {activeItemId} = this.state;
74-
return (
75-
<Section
76-
isScrollSync
77-
activeItemId={activeItemId} {...this.props}
78-
/>
79-
);
74+
return <Section isScrollSync activeItemId={activeItemId} {...this.props} />;
8075
}
8176
}
8277

@@ -103,6 +98,6 @@ const _getElementTopOffsetsById = ids =>
10398
offsetTop: element.offsetTop,
10499
};
105100
})
106-
.filter(item => item);
101+
.filter(item => item);
107102

108103
export default ScrollSyncSection;

src/templates/components/Sidebar/Section.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import MetaTitle from '../MetaTitle';
1515
import ChevronSvg from '../ChevronSvg';
1616

1717
const Section = ({
18-
activeItemId,
18+
activeItemId,
1919
createLink,
20-
isActive,
21-
isScrollSync,
20+
isActive,
21+
isScrollSync,
2222
location,
2323
onLinkClick,
2424
onSectionTitleClick,
@@ -66,7 +66,9 @@ const Section = ({
6666
marginTop: 5,
6767
}}>
6868
{createLink({
69-
isActive: isScrollSync ? activeItemId === item.id : isItemActive(location, item),
69+
isActive: isScrollSync
70+
? activeItemId === item.id
71+
: isItemActive(location, item),
7072
item,
7173
location,
7274
onLinkClick,
@@ -78,7 +80,9 @@ const Section = ({
7880
{item.subitems.map(subitem => (
7981
<li key={subitem.id}>
8082
{createLink({
81-
isActive: isScrollSync ? activeItemId === subitem.id : isItemActive(location, subitem),
83+
isActive: isScrollSync
84+
? activeItemId === subitem.id
85+
: isItemActive(location, subitem),
8286
item: subitem,
8387
location,
8488
onLinkClick,

src/templates/components/Sidebar/Sidebar.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ class Sidebar extends Component {
2525
}
2626

2727
render() {
28-
const {closeParentMenu, createLink, enableScrollSync, location, sectionList} = this.props;
29-
const {activeSection} = this.state;
28+
const {
29+
closeParentMenu,
30+
createLink,
31+
enableScrollSync,
32+
location,
33+
sectionList,
34+
} = this.props;
35+
const {activeSection} = this.state;
3036

31-
const SectionComponent = enableScrollSync ? ScrollSyncSection : Section;
37+
const SectionComponent = enableScrollSync ? ScrollSyncSection : Section;
3238

3339
return (
3440
<Flex

src/templates/tutorial.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Tutorial = ({data, location}) => {
2727

2828
return (
2929
<MarkdownPage
30-
enableScrollSync
30+
enableScrollSync
3131
createLink={createLinkTutorial}
3232
location={location}
3333
markdownRemark={data.markdownRemark}

src/utils/createLink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const createLinkCommunity = ({isActive, item, section}) => {
4444
);
4545
}
4646
return createLinkDocs({
47-
isActive,
47+
isActive,
4848
item,
4949
section,
5050
});

src/utils/isItemActive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const toAnchor = (href = '') => {
2020
// This comment should not be true anymore since we're using 300 redirects
2121

2222
const isItemActive = (location, item) => {
23-
if (location.hash) {
23+
if (location.hash) {
2424
if (item.href) {
2525
return location.hash === toAnchor(item.href);
2626
}

0 commit comments

Comments
 (0)