diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3081d100 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/node_modules/ +/.rts2_cache_umd/ +yarn.lock +/dist/BOILERPLATE-card.js.map +/dist/index.d.ts \ No newline at end of file diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..3f6c11fc --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v8.12.0 \ No newline at end of file diff --git a/dist/BOILERPLATE-card.js b/dist/BOILERPLATE-card.js new file mode 100644 index 00000000..ca4be560 --- /dev/null +++ b/dist/BOILERPLATE-card.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("lit-element")):"function"==typeof define&&define.amd?define(["lit-element"],t):t(e.litElement)}(this,function(e){function t(e,t,o,n){var r,i=arguments.length,c=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,o,n);else for(var f=e.length-1;f>=0;f--)(r=e[f])&&(c=(i<3?r(c):i>3?r(t,o,c):r(t,o))||c);return i>3&&c&&Object.defineProperty(t,o,c),c}var o=Object.freeze([""]),n=Object.freeze(["\n
BOILERPLATE
\n "]),r=function(t){function r(){t.apply(this,arguments)}t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r;var i={styles:{configurable:!0}};return r.prototype.setConfig=function(e){this._config=e},r.prototype.render=function(){return e.html(n)},i.styles.get=function(){return e.css(o)},Object.defineProperties(r,i),r}(e.LitElement);t([e.property()],r.prototype,"hass",void 0),t([e.property()],r.prototype,"_config",void 0),r=t([e.customElement("BOILERPLATE-card")],r)}); +//# sourceMappingURL=BOILERPLATE-card.js.map diff --git a/index.ts b/index.ts new file mode 100644 index 00000000..e63d6e18 --- /dev/null +++ b/index.ts @@ -0,0 +1,43 @@ +import { + LitElement, + html, + customElement, + property, + CSSResult, + TemplateResult, + css +} from "lit-element"; + +interface BOILERPLATEConfig { + type: string; +} + +@customElement("BOILERPLATE-card") +class BOILERPLATECard extends LitElement { + @property() public hass?: any; + @property() private _config?: BOILERPLATEConfig; + + public setConfig(config: BOILERPLATEConfig): void { + if (!this._config) { + // TODO Log error + } + + this._config = config; + } + + protected render(): TemplateResult { + return html` +
BOILERPLATE
+ `; + } + + static get styles(): CSSResult { + return css``; + } +} + +declare global { + interface HTMLElementTagNameMap { + "BOILERPLATE-card": BOILERPLATECard; + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..804de723 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "BOILERPLATE-card", + "version": "1.0.0", + "description": "A templatable config pass-through", + "keywords": [ + "home-assistant", + "homeassistant", + "hass", + "automation", + "lovelace", + "custom-cards" + ], + "umd:main": "BOILERPLATE-card.js", + "repository": "git@github.com:custom_cards/BOILERPLATE-card.git", + "author": "Ian Richardson ", + "license": "MIT", + "dependencies": { + "lit-element": "^2.0.1" + }, + "devDependencies": { + "microbundle": "^0.10.1", + "prettier": "^1.16.4", + "tslib": "^1.9.3", + "tslint": "^5.12.1", + "tslint-config-prettier": "^1.18.0", + "tslint-eslint-rules": "^5.4.0", + "tslint-plugin-prettier": "^2.0.1", + "typescript": "^3.3.3333" + }, + "scripts": { + "start": "microbundle watch", + "build": "npm run lint && microbundle --globals lit-element --target browser --format umd", + "lint": "tslint index.ts" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..ddc30c8b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "jsx": "react", + "jsxFactory": "h", + "target": "es2017", + "module": "esnext", + "moduleResolution": "node", + "lib": ["es2017", "dom", "dom.iterable"], + "noEmit": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "strict": true, + "noImplicitAny": false, + "skipLibCheck": true, + "resolveJsonModule": true, + "experimentalDecorators": true + } +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000..a9442303 --- /dev/null +++ b/tslint.json @@ -0,0 +1,17 @@ +{ + "extends": ["tslint:latest", "tslint-eslint-rules", "tslint-config-prettier"], + "rulesDirectory": ["tslint-plugin-prettier"], + "rules": { + "prettier": true, + "interface-name": false, + "no-submodule-imports": false, + "ordered-imports": false, + "object-literal-sort-keys": false, + "variable-name": [ + true, + "ban-keywords", + "check-format", + "allow-leading-underscore" + ] + } +}