Skip to content

Commit

Permalink
feat: Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell committed Oct 30, 2020
0 parents commit 0b2789f
Show file tree
Hide file tree
Showing 40 changed files with 2,579 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"browser": true
}
}
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Tests
on: [push, pull_request]

env:
CI: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- run: npm install
- name: Lint
run: npm run -s pretest
- name: Tests
run: npm run -s tests-only
- name: Coverage
run: npm run -s posttest
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.tgz
coverage
node_modules
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.tgz
coverage
nyc.config.js
.eslintrc.json
.github
pkgs
fixtures
test.js
tap-snapshots
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock=false
access=public
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 CFWare, LLC

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:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# @cfware/tabs [![NPM Version][npm-image]][npm-url]

Basic page tabs element

## Usage

Import to your application:
```js
import '@cfware/tabs';
```

Create a tabs element:
```html
<cfware-tabs>
<div slot="title">Title 1</div>
<div slot="contents">Tab 1 Contents</div>
<div slot="title">Title 2</div>
<div slot="contents">Tab 2 Contents</div>
</cfware-tabs>
```

[npm-image]: https://img.shields.io/npm/v/@cfware/tabs.svg
[npm-url]: https://npmjs.org/package/@cfware/tabs
41 changes: 41 additions & 0 deletions fixtures/tabs-preset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<html>
<head>
<title>&lt;cfware-tabs&gt; test</title>
<style>
html, body {
display: inline-block!important;
margin: 0;
width: -moz-fit-content;
}

#test {
height: 300px;
width: 600px;
display: grid;
}
</style>
<script type="module" src="tabs.js"></script>
<script type="module" src="/node_modules/@cfware-app/icon/icons.js"></script>
</head>
<body>
<div id="test">
<cfware-tabs selected-index="1">
<div slot="title" id="tab1"><cfware-icon icon="&#xF007;"></cfware-icon></div>
<div slot="contents">
<cfware-icon icon="&#xF007;"></cfware-icon>
<cfware-icon icon="&#xF007;"></cfware-icon>
</div>
<div slot="title" id="tab2"><cfware-icon icon="&#xF093;"></cfware-icon></div>
<div slot="contents">
<cfware-icon icon="&#xF093;"></cfware-icon>
<cfware-icon icon="&#xF093;"></cfware-icon>
</div>
<div slot="title" id="tab3"><cfware-icon icon="&#xF2ED;"></cfware-icon></div>
<div slot="contents">
<cfware-icon icon="&#xF2ED;"></cfware-icon>
<cfware-icon icon="&#xF2ED;"></cfware-icon>
</div>
</cfware-tabs>
</div>
</body>
</html>
41 changes: 41 additions & 0 deletions fixtures/tabs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<html>
<head>
<title>&lt;cfware-tabs&gt; test</title>
<style>
html, body {
display: inline-block!important;
margin: 0;
width: -moz-fit-content;
}

#test {
height: 300px;
width: 600px;
display: grid;
}
</style>
<script type="module" src="tabs.js"></script>
<script type="module" src="/node_modules/@cfware-app/icon/icons.js"></script>
</head>
<body>
<div id="test">
<cfware-tabs>
<div slot="title" id="tab1"><cfware-icon icon="&#xF007;"></cfware-icon></div>
<div slot="contents">
<cfware-icon icon="&#xF007;"></cfware-icon>
<cfware-icon icon="&#xF007;"></cfware-icon>
</div>
<div slot="title" id="tab2"><cfware-icon icon="&#xF093;"></cfware-icon></div>
<div slot="contents">
<cfware-icon icon="&#xF093;"></cfware-icon>
<cfware-icon icon="&#xF093;"></cfware-icon>
</div>
<div slot="title" id="tab3"><cfware-icon icon="&#xF2ED;"></cfware-icon></div>
<div slot="contents">
<cfware-icon icon="&#xF2ED;"></cfware-icon>
<cfware-icon icon="&#xF2ED;"></cfware-icon>
</div>
</cfware-tabs>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from '@cfware/nyc';

export default config.exclude('pkgs/**');
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@cfware/tabs",
"version": "0.1.0",
"description": "Basic page tabs element",
"main": "tabs.js",
"exports": "./tabs.js",
"type": "module",
"scripts": {
"pretest": "cfware-lint .",
"tests-only": "nyc -s node --experimental-loader @istanbuljs/esm-loader-hook test.js",
"test": "npm run -s tests-only",
"posttest": "nyc report --check-coverage"
},
"engines": {
"node": ">=14.0.0"
},
"author": "Corey Farrell",
"license": "MIT",
"keywords": [
"custom-elements",
"tabs",
"html"
],
"repository": {
"type": "git",
"url": "git+https://github.com/cfware/tabs.git"
},
"bugs": {
"url": "https://github.com/cfware/tabs/issues"
},
"homepage": "https://github.com/cfware/tabs#readme",
"dependencies": {
"@cfware/shadow-element": "^0.15.1"
},
"devDependencies": {
"@cfware-app/icon": "file:pkgs/icon",
"@cfware/fastify-test-helper": "^0.7.0",
"@cfware/lint": "^2.0.4",
"@cfware/nyc": "^0.7.0",
"@cfware/tap-selenium-manager": "^1.1.0",
"@istanbuljs/esm-loader-hook": "^0.1.2",
"libtap": "^0.3.0",
"nyc": "^15.1.0"
}
}
1 change: 1 addition & 0 deletions pkgs/icon/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
34 changes: 34 additions & 0 deletions pkgs/icon/fontawesome-free/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Font Awesome Free License
-------------------------

Font Awesome Free is free, open source, and GPL friendly. You can use it for
commercial projects, open source projects, or really almost whatever you want.
Full Font Awesome Free license: https://fontawesome.com/license/free.

# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
In the Font Awesome Free download, the CC BY 4.0 license applies to all icons
packaged as SVG and JS file types.

# Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL)
In the Font Awesome Free download, the SIL OFL license applies to all icons
packaged as web and desktop font files.

# Code: MIT License (https://opensource.org/licenses/MIT)
In the Font Awesome Free download, the MIT license applies to all non-font and
non-icon files.

# Attribution
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
Awesome Free files already contain embedded comments with sufficient
attribution, so you shouldn't need to do anything additional when using these
files normally.

We've kept attribution comments terse, so we ask that you do not actively work
to remove them from files, especially code. They're a great way for folks to
learn about Font Awesome.

# Brand Icons
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
to represent the company, product, or service to which they refer.**
61 changes: 61 additions & 0 deletions pkgs/icon/fontawesome-free/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"_integrity": "sha512-OEdH7SyC1suTdhBGW91/zBfR6qaIhThbcN8PUXtXilY4GYnSBbVqOntdHbC1vXwsDnX0Qix2m2+DSU1J51ybOQ==",
"author": {
"name": "Dave Gandy",
"email": "dave@fontawesome.com",
"url": "http://twitter.com/davegandy"
},
"bugs": {
"url": "http://github.com/FortAwesome/Font-Awesome/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Brian Talbot",
"url": "http://twitter.com/talbs"
},
{
"name": "Travis Chase",
"url": "http://twitter.com/supercodepoet"
},
{
"name": "Rob Madole",
"url": "http://twitter.com/robmadole"
},
{
"name": "Geremia Taglialatela",
"url": "http://twitter.com/gtagliala"
},
{
"name": "Mike Wilkerson",
"url": "http://twitter.com/mw77"
}
],
"dependencies": {},
"deprecated": false,
"description": "The iconic font, CSS, and SVG framework",
"engines": {
"node": ">=6"
},
"homepage": "https://fontawesome.com",
"keywords": [
"font",
"awesome",
"fontawesome",
"icon",
"svg",
"bootstrap"
],
"license": "(CC-BY-4.0 AND OFL-1.1 AND MIT)",
"main": "js/fontawesome.js",
"name": "@fortawesome/fontawesome-free",
"repository": {
"type": "git",
"url": "git+https://github.com/FortAwesome/Font-Awesome.git"
},
"scripts": {
"postinstall": "node attribution.js"
},
"style": "css/fontawesome.css",
"version": "5.15.1"
}
21 changes: 21 additions & 0 deletions pkgs/icon/icon-chars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const iconChars = {
ban: '\uF05E',
'caret-down': '\uF0D7',
'caret-right': '\uF0DA',
download: '\uF019',
edit: '\uF044',
envelope: '\uF0E0',
'exclamation-triangle': '\uF071',
'id-card': '\uF2C2',
list: '\uF03A',
lock: '\uF023',
microphone: '\uF130',
'phone-alt': '\uF879',
plus: '\uF067',
'question-circle': '\uF059',
'sign-out-alt': '\uF2F5',
times: '\uF00D',
'trash-alt': '\uF2ED',
upload: '\uF093',
user: '\uF007'
};
36 changes: 36 additions & 0 deletions pkgs/icon/icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import ShadowElement, {html, template, htmlNode, define, stringProperties} from '@cfware/shadow-element';

document.head.append(htmlNode`
<style>
@font-face {
font-family: 'CFWare Icons';
font-style: normal;
font-weight: 900;
font-display: auto;
src: url("data:font/woff2;base64,d09GMgABAAAAAAkAAAsAAAAAE8AAAAiwAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGVgCFfAqWIJIfCyoAATYCJANQBCAFhEYHgXkbzRCjopRxlpL95QFPxmu8DJGiqCVp6qvGa5mqWNVq/aGHIbTfcS7vUJQrseXq57RixrAoqOf34zd75Zl/MUEzjUrSUCmVEmhkQiVBKZR8EEv3/9ban5k9lXSI1tWIetK6InoNS5lMSDwSIZKhQzz81eb97TgRshPo1m7awJdxszRMLGz497Q3JgOUTlQmMju1I3H2F52Ej5cHFW8gMKUbXvhwaJP/HUuTd+6n5eTSTgORnKXAECQKk9j/bWCs7liXQI/w//b7Vt+s3t1z19uSbJBQOP01SqPEMeTO/fMQ0YeKhSae1jUhlrZUSIRGhFAotXDtt37WuEgwGs9FMfr67wZe5F+JQOXeHrw+u7mHfi1nAcxQAEDY7qjaNmVoLjXOQRNFkiHt5nNIIvREBgDP/Z/+G/B4gxMrSD9ePE41+DLoX6YD4Lb4DhxABB5cWxfgBug8FUT0roKo/hUF38C5VZTiBxmD8SDQZmqe5mfhlmjV9MCzFN/63d9+ZqbE/vjJ/cu5+V95wGyIUilFHWnlJpiXqRVGAw3UAwob+Av4+YpZ28UZBgAGNB4goBGACk0bKNFMgYjmCXRofoDQwoEWLRHI0aqBCe0u4NAeAB7tGZDhd0Wgxh9bQIE/3gEj/vgG9Pgvc9xksxc6h+gJ+DeEjSX43jxPTyP7u4byJTkqxN4vjcKm07JsmtVVt6pu2FlcGpRDVQ2kojUNTcya7ZODzd59ub6/2W7IAG6uzlply7B5E/8ktKQRbP9v9j5Z+d9rg38eeLz4h5uj9E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lss1ucYWrSyRU4vN1FUhnlKETAUAAAAA") format("woff2");
}
</style>
`);

class CFWareIcon extends ShadowElement {
get [template]() {
return html`
<style>
:host {
display: inline;
font-family: 'CFWare Icons';
font-weight: 900;
user-select: none;
cursor: default;
}
</style>
${this.icon}
`;
}
}

CFWareIcon[define]('cfware-icon', {
[stringProperties]: {
icon: ''
}
});
Loading

0 comments on commit 0b2789f

Please sign in to comment.