Skip to content

Commit f77fd34

Browse files
committed
Initial commit.
0 parents  commit f77fd34

Some content is hidden

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

56 files changed

+1572
-0
lines changed

.browserslistrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
last 2 Chrome versions
2+
last 2 Safari versions
3+
last 2 Firefox versions

.gitignore

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
.DS_Store
4+
ec2-user-key-pair.pem
5+
/tmp
6+
env.json
7+
package-lock.json
8+
9+
# compiled output
10+
/dist
11+
12+
# dependencies
13+
/node_modules
14+
/functions/node_modules
15+
16+
# IDEs and editors
17+
/.idea
18+
.project
19+
.classpath
20+
.c9/
21+
*.launch
22+
.settings/
23+
*.sublime-workspace
24+
25+
# IDE - VSCode
26+
.vscode/*
27+
!.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
32+
# misc
33+
/.sass-cache
34+
/connect.lock
35+
/coverage/*
36+
/libpeerconnection.log
37+
npm-debug.log
38+
testem.log
39+
logfile
40+
41+
# e2e
42+
/e2e/*.js
43+
/e2e/*.map
44+
45+
#System Files
46+
.DS_Store
47+
Thumbs.db
48+
dump.rdb
49+
50+
/compiled/
51+
/.idea/
52+
/.cache/
53+
/.vscode/
54+
*.log
55+
/logs/
56+
npm-debug.log*
57+
/lib-cov/
58+
/coverage/
59+
/.nyc_output/
60+
/.grunt/
61+
*.7z
62+
*.dmg
63+
*.gz
64+
*.iso
65+
*.jar
66+
*.rar
67+
*.tar
68+
*.zip
69+
.tgz
70+
.env
71+
.DS_Store?
72+
._*
73+
.Spotlight-V100
74+
.Trashes
75+
ehthumbs.db
76+
*.pem
77+
*.p12
78+
*.crt
79+
*.csr
80+
/node_modules/
81+
/dist/
82+
/documentation/

CODE_OF_CONDUCT.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting any of the code of conduct enforcers: [Andreas Mehlsen](mailto:[email protected]). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
You are more than welcome to contribute to `@appnest/elements` in any way you please, including:
2+
3+
* Updating documentation.
4+
* Fixing spelling and grammar
5+
* Adding tests
6+
* Fixing issues and suggesting new features
7+
* Blogging, tweeting, and creating tutorials about `@appnest/elements`
8+
* Reaching out to [@AndreasMehlsen](https://twitter.com/AndreasMehlsen) on Twitter
9+
* Submit an issue or a pull request

LICENSE.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright © 2018 Andreas Mehlsen [email protected]
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# @appnest/elements
2+
3+
<a href="https://npmcharts.com/compare/@appnest/elements?minimal=true"><img alt="Downloads per month" src="https://img.shields.io/npm/dm/@appnest/elements.svg" height="20"></img></a>
4+
<a href="https://david-dm.org/andreasbm/focus-trap"><img alt="Dependencies" src="https://img.shields.io/david/andreasbm/focus-trap.svg" height="20"></img></a>
5+
<a href="https://www.npmjs.com/package/@appnest/elements"><img alt="NPM Version" src="https://img.shields.io/npm/v/@appnest/elements.svg" height="20"></img></a>
6+
<a href="https://github.com/andreasbm/focus-trap/graphs/contributors"><img alt="Contributors" src="https://img.shields.io/github/contributors/andreasbm/focus-trap.svg" height="20"></img></a>
7+
<a href="https://opensource.org/licenses/MIT"><img alt="MIT License" src="https://img.shields.io/badge/License-MIT-yellow.svg" height="20"></img></a>
8+
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/@appnest/elements)
9+
10+
## What is this?
11+
12+
A lightweight web component to trap focus within a DOM node. A focus trap ensures that `tab` and `shift + tab` keys will cycle through the focus trap's tabbable elements but will not leave the focus trap. This is great for making [accessible modals](https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html). Check out the demo at [https://appnest-demo.firebaseapp.com/focus-trap/](https://appnest-demo.firebaseapp.com/focus-trap/).
13+
14+
<img src="https://raw.githubusercontent.com/andreasbm/focus-trap/master/assets/demo.gif" width="400">
15+
16+
**Features**
17+
18+
* Does one things very very well - it traps the focus!
19+
* Pierces through the shadow roots when looking for focusable elements.
20+
* Works right out of the box (just add it to your markup)
21+
* Created using only vanilla js - no dependencies and framework agnostic!
22+
23+
## Installation
24+
25+
```javascript
26+
npm i @appnest/elements
27+
```
28+
29+
## Usage
30+
31+
Import `@appnest/elements` somewhere in your code and you're ready to go! Simply add the focus trap to your `html` and it'll be working without any more effort from your part.
32+
33+
```html
34+
<focus-trap>
35+
<button>Focus 1</button>
36+
<button>Focus 2</button>
37+
<button>Focus 3</button>
38+
<button>Focus 4</button>
39+
<button>Focus 5</button>
40+
</focus-trap>
41+
```
42+
43+
## API
44+
45+
The `focus-trap` element implements the following interface.
46+
47+
```typescript
48+
interface IFocusTrap {
49+
// Returns whether or not the focus trap is inactive.
50+
inactive: boolean;
51+
52+
// Returns whether the focus trap currently has focus.
53+
readonly focused: boolean;
54+
55+
// Focuses the first focusable element in the focus trap.
56+
focusFirstElement: (() => void);
57+
58+
// Focuses the last focusable element in the focus trap.
59+
focusLastElement: (() => void);
60+
61+
// Returns a list of the focusable children found within the element.
62+
getFocusableChildren: (() => HTMLElement[]);
63+
}
64+
```
65+
66+
## 🎉 License
67+
68+
Licensed under [MIT](https://opensource.org/licenses/MIT).

assets/demo.gif

541 KB
Loading

assets/demo.mov

1.01 MB
Binary file not shown.

assets/dialog.gif

130 KB
Loading

assets/dialog.mov

594 KB
Binary file not shown.

karma.conf.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const {defaultResolvePlugins, defaultKarmaConfig} = require("@appnest/web-config");
2+
3+
module.exports = (config) => {
4+
config.set({
5+
...defaultKarmaConfig({
6+
rollupPlugins: defaultResolvePlugins()
7+
}),
8+
basePath: "src",
9+
logLevel: config.LOG_INFO
10+
});
11+
};

package.json

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@appnest/elements",
3+
"version": "0.0.19",
4+
"license": "MIT",
5+
"module": "index.js",
6+
"author": "Appnest",
7+
"description": "A lightweight web component to trap focus within a DOM node",
8+
"bugs": {
9+
"url": "https://github.com/andreasbm/focus-trap/issues"
10+
},
11+
"homepage": "https://github.com/andreasbm/focus-trap#readme",
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/andreasbm/focus-trap.git"
15+
},
16+
"keywords": [
17+
"custom",
18+
"elements",
19+
"web",
20+
"component",
21+
"custom element",
22+
"web component",
23+
"focus",
24+
"accessibility",
25+
"dialog",
26+
"focus trap",
27+
"trap"
28+
],
29+
"main": "index.js",
30+
"types": "index.d.ts",
31+
"scripts": {
32+
"ncu": "ncu -u -a && npm update && npm install",
33+
"test": "karma start",
34+
"b:dev": "rollup -c --environment NODE_ENV:dev",
35+
"b:prod": "rollup -c --environment NODE_ENV:prod",
36+
"s:dev": "rollup -c --watch --environment NODE_ENV:dev",
37+
"s:prod": "rollup -c --watch --environment NODE_ENV:prod",
38+
"s": "npm run s:dev",
39+
"start": "npm run s",
40+
"b:lib": "node pre-build.js && tsc -p tsconfig.build.json",
41+
"git:add:commit:push": "git add . && git commit --no-edit --amend --no-verify && git push",
42+
"bump:patch": "npm version patch && npm run git:add:commit:push",
43+
"bump:minor": "npm version minor && npm run git:add:commit:push",
44+
"publish": "cd dist && npm publish --access=public && cd ..",
45+
"bump:major": "npm version major && npm run git:add:commit:push",
46+
"publish:patch": "npm run test && npm run bump:patch && npm run b:lib && npm run publish",
47+
"publish:minor": "npm run test && npm run bump:minor && npm run b:lib && npm run publish",
48+
"publish:major": "npm run test && npm run bump:major && npm run b:lib && npm run publish"
49+
},
50+
"devDependencies": {
51+
"@appnest/web-config": "0.3.9"
52+
},
53+
"dependencies": {
54+
"lit-element": "^2.0.1",
55+
"lit-html": "^1.0.0"
56+
}
57+
}

pre-build.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const rimraf = require("rimraf");
2+
const path = require("path");
3+
const fs = require("fs-extra");
4+
const outLib = "dist";
5+
6+
// TODO: Run "tsc -p tsconfig.build.json" from this script and rename it to "build".
7+
8+
async function preBuild () {
9+
await cleanLib();
10+
copySync("./package.json", `./${outLib}/package.json`);
11+
copySync("./README.md", `./${outLib}/README.md`);
12+
}
13+
14+
function cleanLib () {
15+
return new Promise(res => {
16+
rimraf(outLib, res);
17+
});
18+
}
19+
20+
function copySync (src, dest) {
21+
fs.copySync(path.resolve(__dirname, src), path.resolve(__dirname, dest));
22+
}
23+
24+
preBuild().then(_ => {
25+
console.log(">> Prebuild completed");
26+
});

0 commit comments

Comments
 (0)