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

Commit 6abdd20

Browse files
author
george
committed
changes badges to html elements in <Badges> component
1 parent bee24b9 commit 6abdd20

File tree

13 files changed

+461
-82
lines changed

13 files changed

+461
-82
lines changed

app/components/Badges/Badges.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from "react"
2+
3+
export default function Badges() {
4+
return (
5+
<>
6+
<a href="https://badge.fury.io/js/undernet">
7+
<img src="https://badge.fury.io/js/undernet.svg" alt="npm version" height="18" />
8+
</a>
9+
<a href="https://circleci.com/gh/geotrev/undernet/tree/master">
10+
<img
11+
src="https://circleci.com/gh/geotrev/undernet/tree/master.svg?style=svg"
12+
alt="undernet master branch circeci status"
13+
height="20"
14+
/>
15+
</a>
16+
<a href="https://david-dm.org/geotrev/undernet?type=dev">
17+
<img
18+
src="https://david-dm.org/geotrev/undernet/dev-status.svg"
19+
alt="undernet dev dependency status"
20+
height="20"
21+
/>
22+
</a>
23+
<a href="https://david-dm.org/geotrev/undernet">
24+
<img
25+
src="https://david-dm.org/geotrev/undernet.svg"
26+
alt="undernet dependency status"
27+
height="20"
28+
/>
29+
</a>
30+
</>
31+
)
32+
}

app/pages/Home/__tests__/Badges.spec.js renamed to app/components/Badges/__tests__/Badges.spec.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import React from "react"
22
import Badges from "../Badges"
33

4-
jest.mock(
5-
"../markdown/badges.md",
6-
() => "some status content, converted from markdown to html/text!"
7-
)
8-
94
describe("<Badges />", () => {
105
it("renders", () => {
116
const wrapper = mount(<Badges />)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<Badges /> renders 1`] = `
4+
<Badges>
5+
<a
6+
href="https://badge.fury.io/js/undernet"
7+
>
8+
<img
9+
alt="npm version"
10+
height="18"
11+
src="https://badge.fury.io/js/undernet.svg"
12+
/>
13+
</a>
14+
<a
15+
href="https://circleci.com/gh/geotrev/undernet/tree/master"
16+
>
17+
<img
18+
alt="undernet master branch circeci status"
19+
height="20"
20+
src="https://circleci.com/gh/geotrev/undernet/tree/master.svg?style=svg"
21+
/>
22+
</a>
23+
<a
24+
href="https://david-dm.org/geotrev/undernet?type=dev"
25+
>
26+
<img
27+
alt="undernet dev dependency status"
28+
height="20"
29+
src="https://david-dm.org/geotrev/undernet/dev-status.svg"
30+
/>
31+
</a>
32+
<a
33+
href="https://david-dm.org/geotrev/undernet"
34+
>
35+
<img
36+
alt="undernet dependency status"
37+
height="20"
38+
src="https://david-dm.org/geotrev/undernet.svg"
39+
/>
40+
</a>
41+
</Badges>
42+
`;

app/components/Badges/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from "./Badges"

app/pages/Home/Badges.js

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

app/pages/Home/Home.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Link } from "react-router-dom"
33
import Prism from "prismjs"
44
import lottie from "lottie-web"
55
import ChevronRight from "react-feather/dist/icons/chevron-right"
6+
import Loadable from "react-loadable"
67

78
import ScrollUpOnMount from "app/components/ScrollUpOnMount"
89
import SetMeta from "app/components/SetMeta"
@@ -11,11 +12,15 @@ import { docPages } from "app/routes"
1112
import { useDidMount, useWillUnmount } from "app/helpers"
1213

1314
import pkg from "projectRoot/package.json"
14-
import { StatusBadges, InstallNpm, InstallAssets } from "./markdownContent"
15+
import { InstallNpm, InstallAssets } from "./markdownContent"
1516
import { ANIMATION_DATA } from "./animations"
1617

1718
import "./styles.scss"
1819

20+
const loader = () => import("../../components/Badges")
21+
const loading = () => <span className="is-visually-hidden">Loading badges</span>
22+
const StatusBadges = Loadable({ loader, loading })
23+
1924
const { download, introduction } = docPages
2025

2126
export default function Home() {
@@ -72,7 +77,7 @@ export default function Home() {
7277

7378
{/*
7479
* Title is set here _and_ in public/index.html...
75-
* Doing so prevents title changes on other pages from
80+
* Doing so prevents title changes on doc pages from
7681
* persisting if a visitor returns to the home page.
7782
*/}
7883
<SetMeta

app/pages/Home/__tests__/Home.spec.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ const mountComponent = () => {
4141
}
4242

4343
describe("<Home />", () => {
44-
it("renders", () => {
44+
it("renders with loading on StatusBadges", () => {
4545
const wrapper = mountComponent()
4646
expect(wrapper).toMatchSnapshot()
4747
})
48+
49+
it("lazy loads StatusBadges", async () => {
50+
const wrapper = await mountComponent()
51+
expect(wrapper).toMatchSnapshot()
52+
})
4853
})

app/pages/Home/__tests__/__snapshots__/Badges.spec.js.snap

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

0 commit comments

Comments
 (0)