Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit b3c9518

Browse files
authored
Merge pull request #141 from geotrev/develop
Site updates
2 parents fe7b9b6 + 4d38246 commit b3c9518

31 files changed

+697
-4573
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ jobs:
2424
- node_modules
2525
key: v1-dependencies-{{ checksum "package.json" }}
2626

27+
- run: npm run lint
2728
- run: npm run js:build
2829
- run: npm test

.eslintrc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const READONLY = "readonly"
55
const OFF = "off"
66
const ALWAYS = "always"
77

8-
const sitePath = path.resolve(__dirname, "site")
9-
const srcPath = path.resolve(__dirname, "js/src")
10-
const scriptsPath = path.resolve(__dirname, "scripts")
8+
const appPath = path.resolve(__dirname, "app")
9+
const srcPath = path.resolve(__dirname, "src/js")
10+
const binPath = path.resolve(__dirname, "bin")
1111
const nodeModulesPath = path.resolve(__dirname, "node_modules")
1212
const webpackConfigPath = path.resolve(__dirname, "webpack.common.js")
1313

@@ -54,7 +54,7 @@ module.exports = {
5454
"import/resolver": {
5555
node: {
5656
extensions: [".js"],
57-
paths: [sitePath, srcPath, scriptsPath],
57+
paths: [appPath, srcPath, binPath],
5858
moduleDirectory: [nodeModulesPath],
5959
},
6060
webpack: { config: webpackConfigPath },

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ npm-error.log*
44

55
/lib/
66
/build/
7+
/coverage/
78
/node_modules/
89

10+
# don't include umd files in git - only in npm for cdn access
11+
/dist/*.js
12+
/dist/*.js.map
13+
/dist/*.css
14+
/dist/*.css.map
15+
916
.sass-cache
1017
.eslint-output

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ npm-error.log*
1616
/app/
1717
/bin/
1818
/build/
19+
/coverage/
1920
/dist/*.zip
2021
/node_modules/
2122
/public/

app/components/Button/Button.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

app/components/Button/__tests__/Button.spec.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

app/components/Button/__tests__/__snapshots__/Button.spec.js.snap

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/components/Button/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/components/SideNav/SideNav.js

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,19 @@ import Menu from "react-feather/dist/icons/menu"
77
import ChevronRight from "react-feather/dist/icons/chevron-right"
88
import { Accordions } from "undernet"
99

10-
import Button from "app/components/Button"
1110
import "./styles.scss"
1211

13-
const pkg = require("../../../package.json")
14-
const MENU_COLLAPSE_BREAKPOINT = 1199
12+
const pkg = require("projectRoot/package.json")
13+
const MENU_COLLAPSE_WIDTH = 1199
1514

1615
export default class SideNav extends React.Component {
1716
constructor(props) {
1817
super(props)
19-
this.handleCurrentWidth = throttle(this.handleCurrentWidth.bind(this), 50)
18+
this.handleMenuVisibility = throttle(this.handleMenuVisibility, 50)
2019
}
2120

2221
state = {
23-
menuIsOpen: window.innerWidth > MENU_COLLAPSE_BREAKPOINT ? true : false,
24-
currentWindowWidth: window.innerWidth,
22+
menuIsOpen: window.innerWidth > MENU_COLLAPSE_WIDTH,
2523
}
2624

2725
static propTypes = {
@@ -40,56 +38,43 @@ export default class SideNav extends React.Component {
4038
}
4139

4240
componentDidMount() {
43-
window.addEventListener("resize", this.handleCurrentWidth)
4441
window.addEventListener("resize", this.handleMenuVisibility)
4542

46-
const menuIsOpen = this.state.currentWindowWidth > MENU_COLLAPSE_BREAKPOINT
43+
const menuIsOpen = window.innerWidth > MENU_COLLAPSE_WIDTH
4744
this.setState({ menuIsOpen })
4845

4946
Accordions.start()
5047
}
5148

52-
componentDidUpdate() {
53-
Accordions.stop()
54-
Accordions.start()
55-
}
56-
5749
componentWillUnmount() {
58-
window.removeEventListener("resize", this.handleCurrentWidth)
5950
window.removeEventListener("resize", this.handleMenuVisibility)
6051
Accordions.stop()
6152
}
6253

6354
handleCollapseClick = () => {
64-
if (this.state.currentWindowWidth <= MENU_COLLAPSE_BREAKPOINT) {
55+
if (window.innerWidth <= MENU_COLLAPSE_WIDTH) {
6556
this.setState({ menuIsOpen: false })
6657
}
6758
}
6859

69-
handleCurrentWidth = () => {
70-
this.setState({
71-
currentWindowWidth: window.innerWidth,
72-
})
73-
}
74-
7560
handleMenuVisibility = () => {
76-
if (this.state.currentWindowWidth > MENU_COLLAPSE_BREAKPOINT) {
61+
if (window.innerWidth > MENU_COLLAPSE_WIDTH) {
7762
this.setState({ menuIsOpen: true })
7863
}
7964
}
8065

81-
handleClick = event => {
66+
handleMenuToggleClick = event => {
8267
event.preventDefault()
8368
this.setState({ menuIsOpen: !this.state.menuIsOpen })
8469
}
8570

86-
getButtonClasses() {
71+
get buttonClasses() {
8772
return classNames("is-justified-center is-aligned-center is-flex is-hidden-xlarge", {
8873
"rotate-180": !this.state.menuIsOpen,
8974
})
9075
}
9176

92-
getMenuClasses() {
77+
get menuClasses() {
9378
return classNames("row side-nav-menu accordion has-padding-3", {
9479
"is-hidden": !this.state.menuIsOpen,
9580
})
@@ -107,7 +92,7 @@ export default class SideNav extends React.Component {
10792
return isActive
10893
}
10994

110-
renderAccordionChildLink(item) {
95+
renderAccordionChildLink = item => {
11196
return (
11297
<li key={item.name} role="none">
11398
<NavLink
@@ -123,19 +108,20 @@ export default class SideNav extends React.Component {
123108
)
124109
}
125110

126-
renderAccordionRow(section, index, listItems) {
111+
renderAccordionRow(section, index) {
112+
const listItems = section.links.map(this.renderAccordionChildLink)
113+
127114
return (
128115
<Fragment key={section.header}>
129116
<h4 className="paragraph">
130-
<Button
117+
<button
131118
id={`nav-acc-button${index}`}
132-
dataParent="side-nav-accordion"
119+
data-parent="side-nav-accordion"
133120
className="accordion-button"
134-
dataTarget={`nav-acc-content${index}`}
135-
role="listitem"
121+
data-target={`nav-acc-content${index}`}
136122
>
137123
{section.header}
138-
</Button>
124+
</button>
139125
</h4>
140126
<ul className="accordion-content" id={`nav-acc-content${index}`}>
141127
{listItems}
@@ -146,18 +132,14 @@ export default class SideNav extends React.Component {
146132

147133
renderNavAccordion() {
148134
return this.props.navItems.map((section, i) => {
149-
const listItems = section.links.map((item, j) => {
150-
return this.renderAccordionChildLink(item, j)
151-
})
152-
153135
return (
154136
<div
155137
data-visible={this.accordionIsActive(section.links) ? "true" : "false"}
156138
data-accordion-row={`nav-acc-content${i}`}
157139
className={classNames("accordion-row", this.props.navListClasses)}
158140
key={section.links[0].url}
159141
>
160-
{this.renderAccordionRow(section, i, listItems)}
142+
{this.renderAccordionRow(section, i)}
161143
</div>
162144
)
163145
})
@@ -168,13 +150,22 @@ export default class SideNav extends React.Component {
168150
<div className="xsmall-12 xlarge-2 columns has-no-padding" id="side-nav">
169151
<div className="fluid grid side-nav-wrapper">
170152
<div className="row is-flex is-hidden-xlarge side-nav-expand">
171-
<Button onClick={this.handleClick} href="#" className={this.getButtonClasses()}>
153+
<button
154+
onClick={this.handleMenuToggleClick}
155+
className={this.buttonClasses}
156+
aria-controls="side-nav-wrapper"
157+
aria-expanded={this.state.menuIsOpen}
158+
>
172159
<Menu size={20} role="presentation" focusable="false" />{" "}
173160
<span className="has-black-text">Explore</span>
174-
</Button>
161+
</button>
175162
</div>
176163

177-
<nav data-accordion="side-nav-accordion" className={this.getMenuClasses()}>
164+
<nav
165+
data-accordion="side-nav-accordion"
166+
className={this.menuClasses}
167+
id="side-nav-wrapper"
168+
>
178169
<p className="version-text has-no-padding has-gray800-text xsmall-12 columns">
179170
Version {pkg.version}
180171
</p>

0 commit comments

Comments
 (0)