Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up the boiler plate example to work with how home assistant works right now #69

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 21 additions & 30 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/alpine
{
"name": "Boilerplate Card Development",
"image": "ludeeus/container:monster",
"context": "..",
"appPort": ["5000:5000", "9123:8123"],
"postCreateCommand": "npm install",
"runArgs": [
"-v",
"${env:HOME}${env:USERPROFILE}/.ssh:/tmp/.ssh" // This is added so you can push from inside the container
],
"extensions": [
"github.vscode-pull-request-github",
"eamodio.gitlens",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"bierner.lit-html",
"runem.lit-plugin",
"auchenberg.vscode-browser-preview",
"davidanson.vscode-markdownlint",
"redhat.vscode-yaml"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
"name": "Alpine",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/vscode/devcontainers/typescript-node",


// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [ 5000 ],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "yarn"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
10 changes: 0 additions & 10 deletions elements/formfield.js

This file was deleted.

8 changes: 0 additions & 8 deletions elements/ignore/select.js

This file was deleted.

1 change: 0 additions & 1 deletion elements/ignore/switch.js

This file was deleted.

1 change: 0 additions & 1 deletion elements/ignore/textfield.js

This file was deleted.

53 changes: 0 additions & 53 deletions elements/select.js

This file was deleted.

17 changes: 0 additions & 17 deletions elements/switch.js

This file was deleted.

18 changes: 0 additions & 18 deletions elements/textfield.js

This file was deleted.

72 changes: 31 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,41 @@
"author": "Ian Richardson <iantrich@gmail.com>",
"license": "MIT",
"dependencies": {
"@lit-labs/scoped-registry-mixin": "^1.0.0",
"@material/mwc-formfield": "^0.25.3",
"@material/mwc-list": "^0.25.3",
"@material/mwc-menu": "^0.25.3",
"@material/mwc-notched-outline": "^0.25.3",
"@material/mwc-ripple": "^0.25.3",
"@material/mwc-select": "^0.25.3",
"@material/mwc-switch": "^0.25.3",
"@material/mwc-textfield": "^0.25.3",
"custom-card-helpers": "^1.7.2",
"home-assistant-js-websocket": "^5.11.1",
"lit": "^2.0.0"
"custom-card-helpers": "^1.9.0",
"home-assistant-js-websocket": "^9.3.0",
"lit": "^2.8.0",
"@lit-labs/context": "0.4.1",
"@lit-labs/motion": "1.0.7",
"@lit-labs/observers": "2.0.2",
"@lit-labs/virtualizer": "2.0.12"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-decorators": "^7.14.5",
"@rollup/plugin-json": "^4.1.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.1",
"rollup": "^2.58.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"typescript": "^4.4.3"
},
"resolutions": {
"lit": "^2.1.2",
"lit-html": "2.1.2",
"lit-element": "3.1.2",
"@lit/reactive-element": "1.2.1"
"@babel/plugin-proposal-decorators": "^7.24.6",
"@eslint/js": "^9.4.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.8",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/eslint__js": "^8.42.3",
"eslint": "^8.57.0",
"rollup": "^4.18.0",
"rollup-plugin-serve": "^1.1.1",
"rollup-plugin-sizes": "^1.0.6",
"typescript": "^5.4.5",
"typescript-eslint": "^7.11.0"
},
"scripts": {
"start": "rollup -c rollup.config.dev.js --watch",
"start": "rollup -c rollup.config.dev.mjs --watch",
"build": "npm run lint && npm run rollup",
"lint": "eslint src/*.ts",
"rollup": "rollup -c"
}
}
"rollup": "rollup -c --logLevel=debug -m"
},
"resolutions": {
"lit": "2.8.0",
"@lit/reactive-element": "1.6.3"
},
"packageManager": "yarn@4.2.2"
}
24 changes: 0 additions & 24 deletions rollup-plugins/ignore.js

This file was deleted.

39 changes: 39 additions & 0 deletions rollup.config.dev.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import babel from '@rollup/plugin-babel';
import serve from 'rollup-plugin-serve';
import terser from '@rollup/plugin-terser';
import json from '@rollup/plugin-json';
import sizes from 'rollup-plugin-sizes';

export default {
input: ['src/boilerplate-card.ts'],
output: {
dir: './dist',
format: 'es',
},
logLevel: 'debug',
plugins: [
resolve(),
typescript(),
json(),
babel({
exclude: 'node_modules/**',
format: 'es',
include: 'src/**',
exclude: 'homeassistant-frontend/**',
babelHelpers: 'bundled',
}),
terser(),
serve({
contentBase: './dist',
host: '0.0.0.0',
port: 5000,
allowCrossOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
}),
sizes({ details: true }),
],
};
43 changes: 43 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import typescript from '@rollup/plugin-typescript';
import commonjs from '@rollup/plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import terser from '@rollup/plugin-terser';
import serve from 'rollup-plugin-serve';
import json from '@rollup/plugin-json';

const dev = process.env.ROLLUP_WATCH;

const serveopts = {
contentBase: ['./dist'],
host: '0.0.0.0',
port: 5000,
allowCrossOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
};

const plugins = [
nodeResolve({}),
commonjs(),
typescript(),
json(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'bundled',
}),
dev && serve(serveopts),
!dev && terser(),
];

export default [
{
input: 'src/boilerplate-card.ts',
output: {
dir: 'dist',
format: 'es',
},
plugins: [...plugins],
},
];
10 changes: 3 additions & 7 deletions src/action-handler-directive.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { noChange } from 'lit';
import { AttributePart, directive, Directive, DirectiveParameters } from 'lit/directive';
import { AttributePart, directive, Directive, DirectiveParameters } from 'lit/directive.js';

import { ActionHandlerDetail, ActionHandlerOptions } from 'custom-card-helpers/dist/types';
import { fireEvent } from 'custom-card-helpers';

const isTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.maxTouchPoints > 0;

interface ActionHandler extends HTMLElement {
holdTime: number;
bind(element: Element, options): void;
}
interface ActionHandlerElement extends HTMLElement {
class ActionHandlerElement extends HTMLElement {
actionHandler?: boolean;
}

Expand All @@ -20,7 +16,7 @@ declare global {
}
}

class ActionHandler extends HTMLElement implements ActionHandler {
class ActionHandler extends HTMLElement {
public holdTime = 500;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion src/boilerplate-card.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { LitElement, html, TemplateResult, css, PropertyValues, CSSResultGroup } from 'lit';
import { customElement, property, state } from 'lit/decorators';
import { customElement, property, state } from 'lit/decorators.js';
import {
HomeAssistant,
hasConfigOrEntityChanged,
Expand Down
Loading
Loading