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

Commit d9a117d

Browse files
authored
Merge pull request #151 from geotrev/develop
Site updates
2 parents 61f1561 + ea801f9 commit d9a117d

File tree

32 files changed

+686
-340
lines changed

32 files changed

+686
-340
lines changed

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ module.exports = {
205205
// react
206206
"react/display-name": ERROR,
207207

208+
// jsx-a11y
209+
"jsx-a11y/no-noninteractive-element-interactions": OFF,
210+
"jsx-a11y/no-interactive-element-to-noninteractive-role": OFF,
211+
208212
// used for undernet only
209213
"no-console": OFF,
210214
},

app/components/Article/Article.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,30 @@ import ScrollUpOnMount from "app/components/ScrollUpOnMount"
1010
export default class Article extends React.Component {
1111
constructor() {
1212
super()
13+
1314
this.state = {
1415
domIsLoaded: false,
1516
}
1617
}
1718

19+
COMPONENTS = ["Tooltips", "Accordions", "Modals", "Dropdowns"]
20+
1821
static propTypes = {
1922
children: PropTypes.any,
2023
}
2124

2225
componentDidMount() {
23-
Undernet.start()
2426
Prism.highlightAll()
2527

26-
this.setState({
27-
domIsLoaded: true,
28-
})
28+
// initialize all Undernet components
29+
// DO NOT init focus outline - it is set up in layouts/Main
30+
this.COMPONENTS.forEach(component => Undernet[component].start())
31+
32+
this.setState({ domIsLoaded: true })
2933
}
3034

3135
componentWillUnmount() {
32-
Undernet.stop()
36+
this.COMPONENTS.forEach(component => Undernet[component].stop())
3337
}
3438

3539
render() {

app/components/Article/__tests__/Article.spec.js

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,75 @@ import Article from "../Article"
33
import Undernet from "undernet"
44
import Prism from "prismjs"
55

6+
jest.mock("app/components/ScrollUpOnMount", () => global.simpleMock("ScrollUpOnMount"))
7+
68
global.scrollTo = jest.fn()
79

8-
jest.mock("undernet", () => ({
9-
start: jest.fn(),
10-
stop: jest.fn(),
11-
}))
10+
const components = ["Tooltips", "Accordions", "Modals", "Dropdowns"]
11+
12+
components.forEach(component => {
13+
Undernet[component].start = jest.fn()
14+
Undernet[component].stop = jest.fn()
15+
})
1216

1317
jest.mock("prismjs", () => ({
1418
highlightAll: jest.fn(),
1519
}))
1620

17-
describe("<Article />", () => {
18-
let wrapper
19-
beforeEach(() => {
20-
const md = "# Test header \n So neat"
21-
wrapper = mount(<Article>{md}</Article>)
22-
})
23-
24-
it("renders", () => {
25-
expect(wrapper).toMatchSnapshot()
26-
})
21+
const mountComponent = () => {
22+
const md = "# Test header \n So neat"
23+
return mount(<Article>{md}</Article>)
24+
}
2725

28-
it("calls window.scrollTo on mount", () => {
29-
expect(window.scrollTo).toHaveBeenCalledWith(0, 0)
30-
})
26+
describe("<Article />", () => {
27+
describe("#render", () => {
28+
it("renders", () => {
29+
// Given
30+
const wrapper = mountComponent()
31+
// Then
32+
expect(wrapper).toMatchSnapshot()
33+
})
3134

32-
it("calls Prism.highlightAll on mount", () => {
33-
expect(Prism.highlightAll).toHaveBeenCalled()
35+
it("sets fadeIn class on wrapper on mount", () => {
36+
// Given
37+
const wrapper = mountComponent()
38+
// Then
39+
const fadeInClassIsPresent = wrapper
40+
.find("article")
41+
.prop("className")
42+
.includes("fadeIn")
43+
expect(fadeInClassIsPresent).toBe(true)
44+
})
3445
})
3546

36-
it("starts Undernet on mount", () => {
37-
expect(Undernet.start).toHaveBeenCalled()
38-
})
47+
describe("#componentDidMount", () => {
48+
it("calls Prism.highlightAll on mount", () => {
49+
// Given
50+
mountComponent()
51+
// Then
52+
expect(Prism.highlightAll).toHaveBeenCalled()
53+
})
3954

40-
it("stops Undernet on unmount", () => {
41-
wrapper.unmount()
42-
expect(Undernet.stop).toHaveBeenCalled()
55+
components.forEach(component => {
56+
it(`calls Undernet.${component}.start`, () => {
57+
// Given
58+
mountComponent()
59+
// Then
60+
expect(Undernet[component].start).toHaveBeenCalled()
61+
})
62+
})
4363
})
4464

45-
it("sets fadeIn class on wrapper on mount", () => {
46-
expect(
47-
wrapper
48-
.find("article")
49-
.prop("className")
50-
.includes("fadeIn")
51-
).toBe(true)
65+
describe("#componentWillUnmount", () => {
66+
components.forEach(component => {
67+
it(`calls Undernet.${component}.stop`, () => {
68+
// Given
69+
const wrapper = mountComponent()
70+
// When
71+
wrapper.unmount()
72+
// Then
73+
expect(Undernet[component].stop).toHaveBeenCalled()
74+
})
75+
})
5276
})
5377
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`<Article /> renders 1`] = `
3+
exports[`<Article /> #render renders 1`] = `
44
<Article>
55
<article
66
className="article-wrapper has-no-padding column fadeIn"

app/components/DocsRoutes/__tests__/DocsRoutes.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from "react"
22
import { BrowserRouter as Router } from "react-router-dom"
33
import DocsRoutes from "../DocsRoutes"
44

5+
jest.mock("app/components/PageNotFound", () => global.simpleMock("PageNotFound"))
6+
57
function mountRoutes() {
68
return mount(
79
<Router>

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,7 @@ exports[`<DocsRoutes /> renders 1`] = `
8282
"url": "/",
8383
}
8484
}
85-
>
86-
<div
87-
className="has-padding-4 has-center-text"
88-
>
89-
<h1>
90-
Sorry, that page doesn't exist. :(
91-
</h1>
92-
<p
93-
className="has-no-margin-bottom"
94-
>
95-
Did you enter the URL correctly?
96-
</p>
97-
</div>
98-
</PageNotFound>
85+
/>
9986
</Route>
10087
</Switch>
10188
</DocsRoutes>

app/components/Footer/Footer.js

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,68 @@
11
import React from "react"
22
import Github from "react-feather/dist/icons/github"
33
import Twitter from "react-feather/dist/icons/twitter"
4+
import PropTypes from "prop-types"
45

56
import "./styles.scss"
67

7-
export default function Footer() {
8+
export default function Footer(props) {
89
return (
910
<div className="footer-wrapper small-section fluid grid">
1011
<div className="row">
1112
<div className="has-no-padding column">
1213
<p className="has-center-text has-gray900-text">
13-
Undernet is front-end framework created and maintained by{" "}
14+
Undernet is a front-end framework created and maintained by{" "}
1415
<a className="has-white-text" href="http://www.geotrev.com">
1516
George Treviranus
1617
</a>
1718
.
1819
</p>
1920
<p className="has-center-text has-gray900-text">
20-
<a className="has-white-text has-feather" href="https://www.twitter.com/gwtrev">
21-
<Twitter role="presentation" focusable="false" />
22-
<span className="is-visually-hidden">Open link to www.twitter.com/gwtrev</span>
23-
</a>
24-
<a
25-
className="has-white-text has-feather"
26-
href="https://www.github.com/geotrev/undernet"
27-
>
28-
<Github role="presentation" focusable="false" />
29-
<span className="is-visually-hidden">
30-
Open link to www.github.com/geotrev/undernet
31-
</span>
21+
Animations provided by{" "}
22+
<a className="has-white-text" href="https://folgert.com/">
23+
Gavin Folgert
3224
</a>
25+
. ❤️
3326
</p>
27+
<ul className="has-center-text has-gray900-text is-unstyled-list is-flex-row is-flex is-justified-center">
28+
<li role="none">
29+
<a
30+
role="listitem"
31+
className="has-white-text has-feather"
32+
href="https://www.twitter.com/gwtrev"
33+
>
34+
<Twitter role="presentation" focusable="false" />
35+
<span className="is-visually-hidden">Open link to www.twitter.com/gwtrev</span>
36+
</a>
37+
</li>
38+
<li role="none">
39+
<a
40+
role="listitem"
41+
className="has-white-text has-feather"
42+
href="https://www.github.com/geotrev/undernet"
43+
>
44+
<Github role="presentation" focusable="false" />
45+
<span className="is-visually-hidden">
46+
Open link to www.github.com/geotrev/undernet
47+
</span>
48+
</a>
49+
</li>
50+
<li role="none">
51+
<button
52+
className="is-visually-hidden-focusable"
53+
onClick={props.handleHeaderFocusClick}
54+
role="listitem"
55+
>
56+
Return to top of page
57+
</button>
58+
</li>
59+
</ul>
3460
</div>
3561
</div>
3662
</div>
3763
)
3864
}
65+
66+
Footer.propTypes = {
67+
handleHeaderFocusClick: PropTypes.func.isRequired,
68+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import React from "react"
22
import Footer from "../Footer"
33

4+
jest.mock("react-feather/dist/icons/twitter", () => global.simpleMock("Twitter"))
5+
jest.mock("react-feather/dist/icons/github", () => global.simpleMock("Github"))
6+
47
describe("<Footer />", () => {
58
it("renders", () => {
6-
const wrapper = mount(<Footer />)
9+
const wrapper = mount(<Footer handleHeaderFocusClick={jest.fn()} />)
710
expect(wrapper).toMatchSnapshot()
811
})
912
})

0 commit comments

Comments
 (0)