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

Commit 1ddd206

Browse files
author
george treviranus
committed
clean build scripts
1 parent 09ed974 commit 1ddd206

File tree

7 files changed

+33
-18
lines changed

7 files changed

+33
-18
lines changed

app/components/Article/Article.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ import Undernet from "undernet"
88
import ScrollUpOnMount from "app/components/ScrollUpOnMount"
99
import { useDidMount, useWillUnmount } from "app/helpers"
1010

11-
const SCOPE = "#undernet-scope"
11+
const SCOPE = "#article"
1212

1313
export default function Article(props) {
1414
const [domIsLoaded, setDomIsLoaded] = useState(false)
1515

16-
useWillUnmount(() => Undernet.stop(SCOPE, false))
16+
useWillUnmount(() => Undernet.stop(SCOPE))
1717

1818
useDidMount(() => {
1919
Prism.highlightAll()
20-
Undernet.start(SCOPE, false)
20+
Undernet.start(SCOPE)
2121
setDomIsLoaded(true)
2222
})
2323

2424
return (
2525
<article
26-
id="undernet-scope"
26+
id="article"
2727
className={classNames("article-wrapper has-no-p column", { fadeIn: domIsLoaded })}
2828
>
2929
<ScrollUpOnMount />

app/docs/download.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Include the link tag before your custom CSS, and the script tag at the end of yo
3434
</html>
3535
```
3636

37-
Note that if you plan to link to and start Undernet via `<script>` tag, it's recommended to add an event listener for `DOMContentLoaded` to ensure the page is ready. Head over to the [JavaScript](/docs/overview/javascript) page to see more examples, including UI frameworks like React.
37+
Note that if you plan to link to and start Undernet via `<script>` tag, it's recommended to add an event listener for `DOMContentLoaded` to ensure the page is ready. Head over to the [JavaScript](/docs/overview/javascript) page to see more examples, including in UI frameworks like React.
3838

3939
```html
4040
<script>
@@ -45,9 +45,7 @@ Note that if you plan to link to and start Undernet via `<script>` tag, it's rec
4545

4646
## NPM or Yarn
4747

48-
You can also install and setup with npm or yarn.
49-
50-
### JavaScript
48+
Install and setup with npm or yarn.
5149

5250
```sh
5351
$ npm install -D undernet

app/docs/javascript.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Enabling Undernet, including all its component plugins, is as easy as this:
1212

1313
## Core API
1414

15-
There are a few ways to use Undernet.
15+
There are a few ways to use Undernet. The most direct way is using the `start` and `stop` methods off the default `Undernet` object:
1616

1717
### start
1818

1919
```js
20-
Undernet.start(scopeString)
20+
Undernet.start(scopeString, enableFocusRing)
2121
```
2222

2323
#### `scopeString` (string)
@@ -26,10 +26,16 @@ Default: `undefined`
2626

2727
Limits Undernet's initialization to a specific DOM with selector string `scopeString`. E.g., `#my-element-id`.
2828

29+
#### `enableFocusRing` (boolean)
30+
31+
Default: `false`
32+
33+
Enables a utility which adds a distinct focus ring on elements focused while using a keyboard.
34+
2935
### stop
3036

3137
```js
32-
Undernet.stop(scopeString)
38+
Undernet.stop(scopeString, enableFocusRing)
3339
```
3440

3541
#### `scopeString` (string)
@@ -38,9 +44,15 @@ Default: `undefined`
3844

3945
Runs a teardown of components previously initialized via `start(scopeString)`.
4046

47+
#### `enableFocusRing` (boolean)
48+
49+
Default: `false`
50+
51+
Disables the focus ring utility.
52+
4153
## Using Modules
4254

43-
If you use npm, the default export is the `Undernet` object, same as if you use the CDN. Importing this gives you everything, including all JS components and utilities.
55+
If you use npm, the default export is the `Undernet` object. Importing this gives you everything, including all JS components and utilities.
4456

4557
```js
4658
import Undernet from "undernet"

babel.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,29 @@ const modules = {
77
emotion: "emotion",
88
}
99

10+
const libIgnore = ["src/js/__tests__", "src/js/index.bundle.js"]
11+
1012
module.exports = api => {
1113
const test = api.env("test")
1214
const cjs = api.env("cjs")
1315
const esm = api.env("esm")
1416

1517
let presets = [modules.env, modules.react]
1618
let plugins = [modules.properties, modules.dynamicImport, modules.emotion]
19+
let ignore = []
1720

1821
if (test) {
1922
presets = [modules.react, [modules.env, { targets: { node: "current" } }]]
2023
plugins = [...plugins, modules.dynamicImportNode]
2124
} else if (cjs) {
2225
presets = [modules.env]
2326
plugins = []
27+
ignore = [...libIgnore]
2428
} else if (esm) {
2529
presets = [[modules.env, { modules: false }]]
2630
plugins = []
31+
ignore = [...libIgnore]
2732
}
2833

29-
return { plugins, presets }
34+
return { plugins, presets, ignore }
3035
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"prettify": "npm run js:prettify && npm run scss:prettify",
2626
"clean": "rm -rf dist/ lib/ && mkdir dist/ lib/",
2727
"js:build": "npm run js:build:cjs && npm run js:build:esm",
28-
"js:build:cjs": "BABEL_ENV=cjs babel src/js/ -d lib/cjs/ --ignore 'src/js/index.bundle.js','src/js/__tests__/','src/js/helpers/' --no-comments -s",
29-
"js:build:esm": "BABEL_ENV=esm babel src/js/ -d lib/esm/ --ignore 'src/js/index.bundle.js','src/js/__tests__/','src/js/helpers/' --no-comments -s",
28+
"js:build:cjs": "BABEL_ENV=cjs babel src/js/ -d lib/cjs/ --no-comments -s",
29+
"js:build:esm": "BABEL_ENV=esm babel src/js/ -d lib/esm/ --no-comments -s",
3030
"js:build:rollup": "BABEL_ENV=cjs rollup -c rollup.config.js",
3131
"js:watch": "BABEL_ENV=esm babel src/js/ -d lib/esm/ --watch --ignore 'src/js/index.bundle.js' --no-comments -s",
3232
"js:prettify": "prettier --write 'src/js/**/*.js'",

src/js/__tests__/utils.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ describe("focusOnce(element)", () => {
376376
})
377377
})
378378

379-
describe("setComponents(thisArg, scopeId, scopeKey, componentAttribute, componentKey, errorMessage, filterFn)", () => {
379+
describe("setComponents(options = {})", () => {
380380
const SCOPE_1 = "#scope-1"
381381
const SCOPE_2 = "#scope-2"
382382
const COMPONENT_ATTR = "data-test-component"

src/js/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const Undernet = {
2525

2626
const focusRing = Undernet.createFocusRing()
2727

28-
Undernet.start = (scopeId, enableFocusRing = true) => {
28+
Undernet.start = (scopeId, enableFocusRing = false) => {
2929
Undernet.Modals.start(scopeId)
3030
Undernet.Accordions.start(scopeId)
3131
Undernet.Collapsibles.start(scopeId)
@@ -35,7 +35,7 @@ Undernet.start = (scopeId, enableFocusRing = true) => {
3535
if (enableFocusRing) focusRing.start()
3636
}
3737

38-
Undernet.stop = (scopeId, enableFocusRing = true) => {
38+
Undernet.stop = (scopeId, enableFocusRing = false) => {
3939
Undernet.Modals.stop(scopeId)
4040
Undernet.Accordions.stop(scopeId)
4141
Undernet.Collapsibles.stop(scopeId)

0 commit comments

Comments
 (0)