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

Commit e231fbe

Browse files
authored
Merge pull request #170 from geotrev/develop
[Version 7] Release
2 parents 98f6d34 + 80c1bd6 commit e231fbe

File tree

172 files changed

+15267
-9927
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+15267
-9927
lines changed

.jest/jest.setup.js

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import Enzyme, { shallow, render, mount } from "enzyme"
1+
import Enzyme, { shallow, mount } from "enzyme"
22
import Adapter from "enzyme-adapter-react-16"
33

44
Enzyme.configure({ adapter: new Adapter() })
55

66
global.shallow = shallow
7-
global.render = render
87
global.mount = mount
98

109
// Create a simple component instance with jest.mock()
@@ -13,37 +12,3 @@ global.simpleMock = mockName => {
1312
// eslint-disable-next-line
1413
return eval(`const ${mockName} = props => props.children || null; ${mockName}`)
1514
}
16-
17-
/**
18-
* Create and fire a keyboard event.
19-
* @param {Number} which - The key code to simulate.
20-
* @param {Boolean} shiftKey - Whether shift key should be used.
21-
* @param {Element} node - The element to fire the event on.
22-
*/
23-
global.simulateKeyPress = (which, shiftKey = false, node = null) => {
24-
const event = new KeyboardEvent("keydown", {
25-
which,
26-
shiftKey,
27-
keyCode: which,
28-
bubbles: true,
29-
})
30-
31-
return node ? node.dispatchEvent(event) : document.dispatchEvent(event)
32-
}
33-
34-
/**
35-
* Create and fire a keyboard event.
36-
* @param {String} name - Event name.
37-
* @param {Object} node - The node to dispatch the event against.
38-
* @param {Boolean} bubbles - Flag for allowing bubbling of the event.
39-
* @param {Boolean} cancelale - Flag for allowing cancelling of the event.
40-
*/
41-
global.simulateMouseEvent = (name, node = null, bubbles = false, cancelable = false) => {
42-
const event = new MouseEvent(name, {
43-
bubbles: bubbles || true,
44-
cancelable: cancelable || true,
45-
relatedTarget: window,
46-
})
47-
48-
return node ? node.dispatchEvent(event) : document.dispatchEvent(event)
49-
}

.prettierignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
**/*.html
2-
**/*.md
1+
/node_modules/
2+
/build/
3+
/dist/
4+
/lib/
5+
/app/docs/

.stylelintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
app/docs/*
3+
src/scss/utilities/_reset.scss
4+
src/__tests__/

stylelint.config.js renamed to .stylelintrc.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ module.exports = {
5555

5656
"length-zero-no-unit": true,
5757

58-
linebreaks: "unix",
59-
6058
"max-nesting-depth": [3, { ignore: ["pseudo-classes", "blockless-at-rules"] }],
6159

6260
"media-feature-colon-space-after": ALWAYS,
@@ -71,16 +69,11 @@ module.exports = {
7169
"no-duplicate-at-import-rules": true,
7270
"no-duplicate-selectors": true,
7371
"no-empty-source": true,
74-
"no-empty-first-line": true,
7572
"no-invalid-double-slash-comments": true,
7673
"no-unknown-animations": true,
7774

7875
"property-no-unknown": true,
7976

80-
// This will be flagged by the script `scss:lint:check`
81-
// Please ignore the error :)
82-
"rule-empty-line-before": [ALWAYS, { except: ["first-nested"], ignore: ["after-comment"] }],
83-
8477
"selector-attribute-brackets-space-inside": NEVER,
8578
"selector-attribute-operator-blacklist": [],
8679
"selector-attribute-operator-space-after": NEVER,
@@ -119,7 +112,6 @@ module.exports = {
119112
"scss/at-mixin-argumentless-call-parentheses": NEVER,
120113
"scss/at-mixin-parentheses-space-before": NEVER,
121114
"scss/at-each-key-value-single-line": true,
122-
"scss/at-rule-conditional-no-parentheses": true,
123115
"scss/at-rule-no-unknown": true,
124116

125117
"scss/declaration-nested-properties": NEVER,
@@ -137,8 +129,6 @@ module.exports = {
137129

138130
"scss/map-keys-quotes": ALWAYS,
139131

140-
"scss/operator-no-newline-after": true,
141-
"scss/operator-no-newline-before": true,
142132
"scss/operator-no-unspaced": true,
143133

144134
"scss/selector-no-redundant-nesting-selector": true,

CONTRIBUTING.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
All input is good input! Contributing to this project should be as easy and transparent as possible, whether it's:
44

5-
* Reporting a bug
6-
* Discussing the current state of the code
7-
* Submitting a fix
8-
* Proposing new features
9-
* Becoming a maintainer
5+
- Reporting a bug
6+
- Discussing the current state of the code
7+
- Submitting a fix
8+
- Proposing new features
9+
- Becoming a maintainer
1010

1111
## We Develop with Github
1212

@@ -18,11 +18,11 @@ All code changes happen through pull requests
1818

1919
Pull requests are the best way to propose changes to the codebase. Any kind of idea or change is welcome.
2020

21-
1. Fork the repo and create your branch from `develop`.
22-
2. If you've added code that should be tested, add tests.
23-
3. If you've changed APIs, update the documentation.
24-
4. If you've added dependencies, note what they are and why they are needed.
25-
5. Make sure your code and tests run without errors. It's also helpful if you've done a regression check against other areas of the framework, but not strictly required.
21+
1. Fork the repo and create your branch from `develop`.
22+
2. If you've added code that should be tested, add tests.
23+
3. If you've changed APIs, update the documentation.
24+
4. If you've added dependencies, note what they are and why they are needed.
25+
5. Make sure your code and tests run without errors. It's also helpful if you've done a regression check against other areas of the framework, but not strictly required.
2626

2727
## Any contributions you make will be under the MIT Software License
2828

@@ -40,11 +40,9 @@ The more detail, the less confusion!
4040

4141
## Use a Consistent Coding Style
4242

43-
Reference `.prettierrc` for code styling. Run `npm run lint` to apply styling to both css and javascript, or manually apply updates to files using `prettier`:
43+
If you're using a code editor, make sure it has plugins for prettier, eslint, and stylelint.
4444

45-
```sh
46-
$ prettier --write path/to/folder/**/*
47-
```
45+
If you don't have plugins for your editor, run `npm run prettify && npm run lint` to apply styling to both css and javascript before you commit changes.
4846

4947
## References
5048

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Undernet](app/assets/images/github-logo.png?raw=true)
22

3-
[![CircleCI](https://circleci.com/gh/geotrev/undernet/tree/master.svg?style=svg)](https://circleci.com/gh/geotrev/undernet/tree/master) [![devDependencies Status](https://david-dm.org/geotrev/undernet/dev-status.svg)](https://david-dm.org/geotrev/undernet?type=dev) [![dependencies Status](https://david-dm.org/geotrev/undernet.svg)](https://david-dm.org/geotrev/undernet) [![npm version](https://badge.fury.io/js/undernet.svg)](https://badge.fury.io/js/undernet) ![Code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)
3+
[![CircleCI](https://circleci.com/gh/geotrev/undernet/tree/master.svg?style=svg)](https://circleci.com/gh/geotrev/undernet/tree/master) [![devDependencies Status](https://david-dm.org/geotrev/undernet/dev-status.svg)](https://david-dm.org/geotrev/undernet?type=dev) [![dependencies Status](https://david-dm.org/geotrev/undernet.svg)](https://david-dm.org/geotrev/undernet) [![npm version](https://badge.fury.io/js/undernet.svg)](https://badge.fury.io/js/undernet) ![Code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg) [![Netlify Status](https://api.netlify.com/api/v1/badges/b895bcd0-9455-4818-a94b-8d33e5907517/deploy-status)](https://app.netlify.com/sites/undernet-prod/deploys)
44

55
# Undernet
66

@@ -27,7 +27,7 @@ $ yarn add -D undernet
2727

2828
### Styles
2929

30-
See [branding documentation](https://www.undernet.io/docs/overview/branding) to setup a custom pipeline with Undernet's SCSS.
30+
See [CSS documentation](https://www.undernet.io/docs/overview/css) to setup a custom pipeline with Undernet's SCSS.
3131

3232
### Components / JS
3333

app/components/Article/Article.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
import React, { useState, useEffect } from "react"
1+
import React, { useState } from "react"
22
import Markdown from "react-markdown"
33
import Prism from "prismjs"
44
import classNames from "classnames"
55
import PropTypes from "prop-types"
6+
import Undernet from "undernet"
67

7-
import { COMPONENTS } from "./constants"
88
import ScrollUpOnMount from "app/components/ScrollUpOnMount"
9+
import { useDidMount, useWillUnmount } from "app/helpers"
10+
11+
const SCOPE = "#article"
912

1013
export default function Article(props) {
1114
const [domIsLoaded, setDomIsLoaded] = useState(false)
1215

13-
const componentUnmountFunction = () => {
14-
COMPONENTS.forEach(Component => Component.stop())
15-
}
16+
useWillUnmount(() => Undernet.stop(SCOPE))
1617

17-
const observedStateOnMount = []
18-
useEffect(() => {
18+
useDidMount(() => {
1919
Prism.highlightAll()
20-
COMPONENTS.forEach(Component => Component.start())
20+
Undernet.start(SCOPE)
2121
setDomIsLoaded(true)
22-
23-
return componentUnmountFunction
24-
}, observedStateOnMount)
22+
})
2523

2624
return (
2725
<article
28-
className={classNames("article-wrapper has-no-padding column", {
29-
fadeIn: domIsLoaded,
30-
})}
26+
id="article"
27+
className={classNames("article-wrapper has-no-p column", { fadeIn: domIsLoaded })}
3128
>
3229
<ScrollUpOnMount />
3330
<Markdown source={props.children} escapeHtml={false} />

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

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import React from "react"
2-
import Article from "../Article"
32
import Prism from "prismjs"
4-
import { COMPONENTS } from "../constants"
3+
import Undernet from "undernet"
4+
import Article from "../Article"
55

66
jest.mock("app/components/ScrollUpOnMount", () => global.simpleMock("ScrollUpOnMount"))
77

88
global.scrollTo = jest.fn()
99

10-
COMPONENTS.forEach(Component => {
11-
Component.start = jest.fn()
12-
Component.stop = jest.fn()
13-
})
10+
Undernet.start = jest.fn()
11+
Undernet.stop = jest.fn()
1412

1513
jest.mock("prismjs", () => ({
1614
highlightAll: jest.fn(),
@@ -47,29 +45,25 @@ describe("<Article />", () => {
4745
// Given
4846
mountComponent()
4947
// Then
50-
expect(Prism.highlightAll).toHaveBeenCalled()
48+
expect(Prism.highlightAll).toBeCalled()
5149
})
5250

53-
COMPONENTS.forEach(Component => {
54-
it(`calls ${Component}.start`, () => {
55-
// Given
56-
mountComponent()
57-
// Then
58-
expect(Component.start).toHaveBeenCalled()
59-
})
51+
it("calls Undernet.start", () => {
52+
// Given
53+
mountComponent()
54+
// Then
55+
expect(Undernet.start).toBeCalled()
6056
})
6157
})
6258

6359
describe("#componentWillUnmount", () => {
64-
COMPONENTS.forEach(Component => {
65-
it(`calls ${Component}.stop`, () => {
66-
// Given
67-
const wrapper = mountComponent()
68-
// When
69-
wrapper.unmount()
70-
// Then
71-
expect(Component.stop).toHaveBeenCalled()
72-
})
60+
it("calls Undernet.stop", () => {
61+
// Given
62+
const wrapper = mountComponent()
63+
// When
64+
wrapper.unmount()
65+
// Then
66+
expect(Undernet.stop).toBeCalled()
7367
})
7468
})
7569
})

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
exports[`<Article /> #render renders 1`] = `
44
<Article>
55
<article
6-
className="article-wrapper has-no-padding column fadeIn"
6+
className="article-wrapper has-no-p column fadeIn"
7+
id="article"
78
>
89
<ScrollUpOnMount />
910
<ReactMarkdown
@@ -20,28 +21,28 @@ exports[`<Article /> #render renders 1`] = `
2021
transformLinkUri={[Function]}
2122
>
2223
<Root
23-
key="root-1-1"
24+
key="root-1-1-0"
2425
>
2526
<Heading
26-
key="heading-1-1"
27+
key="heading-1-1-0"
2728
level={1}
2829
>
2930
<h1>
3031
<TextRenderer
31-
key="text-1-3"
32-
nodeKey="text-1-3"
32+
key="text-1-3-0"
33+
nodeKey="text-1-3-0"
3334
value="Test header"
3435
>
3536
Test header
3637
</TextRenderer>
3738
</h1>
3839
</Heading>
3940
<p
40-
key="paragraph-2-1"
41+
key="paragraph-2-1-1"
4142
>
4243
<TextRenderer
43-
key="text-2-1"
44-
nodeKey="text-2-1"
44+
key="text-2-1-0"
45+
nodeKey="text-2-1-0"
4546
value=" So neat"
4647
>
4748
So neat

app/components/Article/constants.js

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

app/components/DocsRoutes/DocsRoutes.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import { Switch, Route } from "react-router-dom"
33
import Loadable from "react-loadable"
44

5-
import * as routes from "app/routes"
5+
import { docPages } from "app/routes"
66
import PageNotFound from "app/components/PageNotFound"
77
import LoadingSpinner from "app/components/LoadingSpinner"
88

@@ -18,24 +18,11 @@ const getComponent = component =>
1818
export default function DocsRoutes() {
1919
return (
2020
<Switch>
21-
<Route exact path={routes.introductionPath} component={getComponent("Introduction")} />
22-
<Route exact path={routes.downloadPath} component={getComponent("Download")} />
23-
<Route exact path={routes.brandingPath} component={getComponent("Branding")} />
24-
<Route exact path={routes.javascriptPath} component={getComponent("Javascript")} />
25-
<Route exact path={routes.gridPath} component={getComponent("Grid")} />
26-
<Route exact path={routes.typographyPath} component={getComponent("Typography")} />
27-
<Route exact path={routes.buttonsPath} component={getComponent("Buttons")} />
28-
<Route exact path={routes.formsPath} component={getComponent("Forms")} />
29-
<Route exact path={routes.modalsPath} component={getComponent("Modals")} />
30-
<Route exact path={routes.accordionsPath} component={getComponent("Accordions")} />
31-
<Route exact path={routes.dropdownsPath} component={getComponent("Dropdowns")} />
32-
<Route exact path={routes.tooltipsPath} component={getComponent("Tooltips")} />
33-
<Route exact path={routes.alignmentPath} component={getComponent("Alignment")} />
34-
<Route exact path={routes.offsetOrderPath} component={getComponent("OffsetOrder")} />
35-
<Route exact path={routes.textPath} component={getComponent("Text")} />
36-
<Route exact path={routes.displayPath} component={getComponent("Display")} />
37-
<Route exact path={routes.colorPath} component={getComponent("Color")} />
38-
<Route exact path={routes.spacingPath} component={getComponent("Spacing")} />
21+
{Object.entries(docPages).map(([name, path]) => {
22+
const componentName = name[0].toUpperCase() + name.slice(1)
23+
24+
return <Route key={name} exact path={path} component={getComponent(componentName)} />
25+
})}
3926
<Route component={PageNotFound} />
4027
</Switch>
4128
)

app/components/DocsRoutes/articles/Accordions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import AccordionsMd from "app/docs/accordions.md"
66

77
const Accordions = () => {
88
return (
9-
<React.Fragment>
9+
<>
1010
<SetMeta
1111
title="Accordions"
12-
description="A component for hiding and showing content in an accordion-style user interface."
12+
description="A component that composes a series of collapsible containers."
1313
/>
1414
<PageHeader>Accordions</PageHeader>
1515
<Article>{AccordionsMd}</Article>
16-
</React.Fragment>
16+
</>
1717
)
1818
}
1919

0 commit comments

Comments
 (0)