mirror of
https://github.com/GeorgeSG/lovelace-time-picker-card.git
synced 2025-12-28 21:00:29 +00:00
Initial commit
This commit is contained in:
12
.editorconfig
Normal file
12
.editorconfig
Normal file
@@ -0,0 +1,12 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
19
.eslintrc
Normal file
19
.eslintrc
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
|
||||
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
|
||||
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018, // Allows for the parsing of modern ECMAScript features
|
||||
"sourceType": "module", // Allows for the use of imports
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/camelcase": 0,
|
||||
"@typescript-eslint/no-non-null-assertion": 0,
|
||||
"@typescript-eslint/explicit-function-return-type": [1, { "allowExpressions": true }]
|
||||
},
|
||||
"ignorePatterns": ["dist/", "node_modules/"]
|
||||
}
|
||||
42
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
42
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: File a bug report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
### Checklist:
|
||||
|
||||
- [ ] I updated to the latest version available
|
||||
- [ ] I cleared the cache of my browser
|
||||
|
||||
### The problem
|
||||
|
||||
<!--
|
||||
Describe the issue you are experiencing
|
||||
-->
|
||||
|
||||
### Environment
|
||||
|
||||
<!--
|
||||
Provide details about the versions you are using, which helps us to reproduce
|
||||
and find the issue quicker. Version information is found in the
|
||||
Home Assistant frontend: Developer tools -> Info.
|
||||
-->
|
||||
|
||||
- template-card release with the issue:
|
||||
- Last working template-card release (if known):
|
||||
- Browser and Operating System:
|
||||
|
||||
### Problem-relevant configuration
|
||||
|
||||
```yaml
|
||||
|
||||
```
|
||||
|
||||
### Javascript errors shown in the web inspector (if applicable):
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
26
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
26
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest a feature for template-card
|
||||
title: ''
|
||||
labels: feature request
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
### Problem
|
||||
|
||||
<!--
|
||||
Is your feature request related to a problem? If so, please write a clear and concise description
|
||||
of what the problem is. Ex. I'm always frustrated when [...]
|
||||
-->
|
||||
|
||||
### Suggested feature / solution
|
||||
|
||||
<!--
|
||||
A clear and concise description of what you want to happen.
|
||||
-->
|
||||
|
||||
### Additional context
|
||||
|
||||
<!--
|
||||
Add any other context or screenshots about the feature request here.
|
||||
-->
|
||||
20
.github/workflows/ci.yaml
vendored
Normal file
20
.github/workflows/ci.yaml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: 'CI'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build
|
||||
run: |
|
||||
npm install
|
||||
npm run lint
|
||||
npm run build
|
||||
24
.github/workflows/release.yaml
vendored
Normal file
24
.github/workflows/release.yaml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Build and upload
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build template-card.js
|
||||
run: |
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
- name: Upload to release
|
||||
uses: shopify/upload-to-release@1.0.0
|
||||
with:
|
||||
name: template-card.js
|
||||
path: dist/template-card.js
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
dist/
|
||||
5
.prettierrc
Normal file
5
.prettierrc
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"printWidth": 100
|
||||
}
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Georgi Gardev
|
||||
|
||||
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.
|
||||
39
README.md
Normal file
39
README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Lovelace Template Card by [@georgesg](https://www.github.com/georgesg)
|
||||
|
||||
[![hacs_badge][hacs-shield]][hacs]
|
||||
[![GitHub Release][releases-shield]][releases]
|
||||

|
||||
[![Project Maintenance][maintenance-shield]][maintenance]
|
||||
[![GitHub Activity][commits-shield]][commits]
|
||||
[![License][license-shield]][license]
|
||||
|
||||
## Overview
|
||||
|
||||
This is a Template for a lovelace card, mostly the same as [boilerplate-card](https://github.com/custom-cards/boilerplate-card), but with some of my preferences applied on top.
|
||||
|
||||
## Installation
|
||||
|
||||
Install using [HACS](https://hacs.xyz) or follow this [guide](https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins)
|
||||
|
||||
```yaml
|
||||
resources:
|
||||
- url: /local/template-card.js
|
||||
type: module
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```yaml
|
||||
type: 'custom:template-card'
|
||||
```
|
||||
|
||||
[commits-shield]: https://img.shields.io/github/commit-activity/y/GeorgeSG/lovelace-template-card?style=flat-square
|
||||
[commits]: https://github.com/GeorgeSG/lovelace-template-card/commits/master
|
||||
[license-shield]: https://img.shields.io/github/license/GeorgeSG/lovelace-template-card?style=flat-square
|
||||
[license]: https://github.com/GeorgeSG/lovelace-template-card/blob/master/LICENSE
|
||||
[maintenance-shield]: https://img.shields.io/maintenance/yes/2020.svg?style=flat-square
|
||||
[maintenance]: https://github.com/GeorgeSG/lovelace-template-card
|
||||
[releases-shield]: https://img.shields.io/github/release/GeorgeSG/lovelace-template-card.svg?style=flat-square
|
||||
[releases]: https://github.com/GeorgeSG/lovelace-template-card/releases
|
||||
[hacs-shield]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=flat-square
|
||||
[hacs]: https://github.com/custom-components/hacs
|
||||
5
hacs.json
Normal file
5
hacs.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Template Card",
|
||||
"render_readme": true,
|
||||
"filename": "template-card.js"
|
||||
}
|
||||
1823
package-lock.json
generated
Normal file
1823
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
49
package.json
Normal file
49
package.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "template-card",
|
||||
"version": "0.0.0",
|
||||
"author": "Georgi Gardev <georgi@gardev.com>",
|
||||
"description": "Lovelace template-card",
|
||||
"keywords": [
|
||||
"home-assistant",
|
||||
"homeassistant",
|
||||
"hass",
|
||||
"automation",
|
||||
"lovelace",
|
||||
"lovelace-card",
|
||||
"lovelace-custom-card"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "git@github.com:GeorgeSG/lovelace-template-card.git",
|
||||
"scripts": {
|
||||
"start": "rollup -c --watch",
|
||||
"build": "npm run lint && npm run rollup",
|
||||
"lint": "eslint src/*.ts",
|
||||
"rollup": "rollup -c",
|
||||
"release-patch": "npm version patch && git push origin master --tags",
|
||||
"release-minor": "npm version minor && git push origin master --tags",
|
||||
"release-major": "npm version major && git push origin master --tags"
|
||||
},
|
||||
"dependencies": {
|
||||
"custom-card-helpers": "^1.5.0",
|
||||
"home-assistant-js-websocket": "^5.1.0",
|
||||
"lit-element": "^2.3.1",
|
||||
"lit-html": "^1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@rollup/plugin-json": "^4.0.3",
|
||||
"@rollup/plugin-node-resolve": "^7.1.1",
|
||||
"@rollup/plugin-typescript": "^4.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.30.0",
|
||||
"@typescript-eslint/parser": "^2.30.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"prettier": "^2.0.5",
|
||||
"rollup": "^1.32.1",
|
||||
"rollup-plugin-babel": "^4.4.0",
|
||||
"rollup-plugin-serve": "^1.0.1",
|
||||
"rollup-plugin-terser": "^5.3.0",
|
||||
"typescript": "^3.8.3"
|
||||
}
|
||||
}
|
||||
36
rollup.config.js
Normal file
36
rollup.config.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||
import json from '@rollup/plugin-json';
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
import babel from 'rollup-plugin-babel';
|
||||
import serve from 'rollup-plugin-serve';
|
||||
|
||||
const dev = process.env.ROLLUP_WATCH;
|
||||
|
||||
const serveOptions = {
|
||||
contentBase: ['./dist'],
|
||||
host: '0.0.0.0',
|
||||
port: 5000,
|
||||
allowCrossOrigin: true,
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
input: 'src/template-card.ts',
|
||||
output: {
|
||||
dir: './dist',
|
||||
format: 'es',
|
||||
},
|
||||
plugins: [
|
||||
nodeResolve(),
|
||||
json(),
|
||||
typescript(),
|
||||
babel({
|
||||
exclude: 'node_modules/**',
|
||||
}),
|
||||
dev && serve(serveOptions),
|
||||
!dev && terser(),
|
||||
],
|
||||
};
|
||||
3
src/const.ts
Normal file
3
src/const.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as pkg from '../package.json';
|
||||
|
||||
export const CARD_VERSION = pkg.version;
|
||||
8
src/styles.ts
Normal file
8
src/styles.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { css } from 'lit-element';
|
||||
|
||||
export const styles = css`
|
||||
.card-warning {
|
||||
background-color: var(--google-red-500, #ef5350);
|
||||
color: #fff;
|
||||
}
|
||||
`;
|
||||
45
src/template-card.ts
Normal file
45
src/template-card.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { HomeAssistant } from 'custom-card-helpers';
|
||||
import { CSSResult, customElement, html, LitElement, property, TemplateResult } from 'lit-element';
|
||||
import { CARD_VERSION } from './const';
|
||||
import { styles } from './styles';
|
||||
import { TemplateCardConfig } from './types';
|
||||
|
||||
console.info(
|
||||
`%c TEMPLATE-CARD \n%c Version ${CARD_VERSION} `,
|
||||
'color: darkgreen; font-weight: bold; background: black',
|
||||
'color: white; font-weight: bold; background: dimgray'
|
||||
);
|
||||
|
||||
@customElement('template-card')
|
||||
export class TemplateCard extends LitElement {
|
||||
@property() private hass?: HomeAssistant;
|
||||
@property() private config?: TemplateCardConfig;
|
||||
|
||||
render(): TemplateResult | null {
|
||||
if (!this.config || !this.hass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return html`<ha-card>TemplateCard</ha-card>`;
|
||||
}
|
||||
|
||||
setConfig(config): void {
|
||||
if (!config) {
|
||||
throw new Error('Invalid configuration');
|
||||
}
|
||||
|
||||
if (!config.entity) {
|
||||
throw new Error('You need to set an entity');
|
||||
}
|
||||
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
getCardSize(): number {
|
||||
return 3;
|
||||
}
|
||||
|
||||
static get styles(): CSSResult {
|
||||
return styles;
|
||||
}
|
||||
}
|
||||
3
src/types.ts
Normal file
3
src/types.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface TemplateCardConfig {
|
||||
entity: string;
|
||||
}
|
||||
17
tsconfig.json
Normal file
17
tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2017",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"lib": ["es2017", "dom", "dom.iterable"],
|
||||
"noEmit": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true,
|
||||
"experimentalDecorators": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user