Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
58ad978
Refactor code structure for improved readability and maintainability.…
iantrich Feb 21, 2026
902e6b9
note on name
iantrich Feb 21, 2026
cda3349
Enhance Boilerplate Card configuration options: add card style, accen…
iantrich Feb 21, 2026
1eb2979
Add layout and display mode options to Boilerplate Card configuration…
iantrich Feb 21, 2026
4ff0956
Refactor boilerplate card code for improved clarity and organization;…
iantrich Feb 21, 2026
b92bec5
chore: update custom-card-helpers to version 2.0.0 and modify package…
iantrich Feb 21, 2026
cc2921f
Update .prettierrc.json
iantrich Feb 21, 2026
96f0a46
address PR review comments
iantrich Feb 21, 2026
2ea3537
address PR review comments
iantrich Feb 21, 2026
7a064b1
refactor: replace deep clone with structuredClone for improved perfor…
iantrich Feb 22, 2026
d4cdb63
address PR comments
iantrich Feb 22, 2026
5ab0a81
feat: add press_action and release_action to BoilerplateCardConfig in…
iantrich Feb 22, 2026
9f64c26
refactor: enhance type safety in customFireEvent and ActionHandler pr…
iantrich Feb 22, 2026
9d86f20
Update src/action-handler-directive.ts
iantrich Feb 22, 2026
23b9051
refactor: update attribute_limit description and change selector mode…
iantrich Feb 22, 2026
60da50a
Update package.json
iantrich Feb 22, 2026
0b312ae
refactor: change output configuration from dir to file for boilerplat…
iantrich Feb 22, 2026
674b204
refactor: update input format and enhance watch configuration in roll…
iantrich Feb 22, 2026
a337b84
refactor: update configuration and build setup for improved developme…
iantrich Feb 23, 2026
3775437
refactor: remove overrides section and update output paths in rollup …
iantrich Feb 23, 2026
2d903c3
refactor: add lit-element dependency to package-lock.json
iantrich Feb 23, 2026
7bfdb14
Migrate to yarn package manager
iantrich Feb 25, 2026
f543cd6
docs: add GitHub Copilot instructions and reference files
iantrich Feb 25, 2026
1d0dae6
refactor: standardize environment variable setup in build and release…
iantrich Feb 25, 2026
959ded2
refactor: simplify clean script in package.json
iantrich Feb 25, 2026
069f76d
fix: ensure newline at end of file in const.ts
iantrich Feb 25, 2026
fbe71d4
docs: update instructions for adding custom card in Home Assistant
iantrich Feb 25, 2026
36784b6
feat: add version validation and bumping in release workflow
iantrich Feb 27, 2026
be5a64f
refactor: update devcontainer configuration and remove Dockerfile
iantrich Mar 3, 2026
c9cfda1
fix: update devcontainer base image tag to latest
iantrich Mar 3, 2026
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
120 changes: 120 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Home Assistant Custom Card - Dev Container Setup

This directory contains the development container configuration for building and testing the boilerplate-card custom card for Home Assistant.

## Setup Instructions

1. **Install VS Code Remote Containers**
- [VS Code Extension: Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)

2. **Open in Dev Container**
- Open the project folder in VS Code
- Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac)
- Type "Remote-Containers: Reopen in Container"
- Wait for the container to build (first time takes ~2-3 minutes)

3. **Build the Card**
```bash
yarn build # Lint and build
yarn start # Start dev server with hot reload (port 5000)
yarn lint # Check code quality
yarn rollup # Production build
```

4. **Access Services**
- **Dev Container**: Terminal in VS Code (automatic)
- **Home Assistant**: http://localhost:8123 (user: dev/pass: dev)
- **Rollup Dev Server**: http://localhost:5000

5. **Configure Home Assistant to Use Your Card**
- In Home Assistant, go to Settings > Dashboards
- Create a new Dashboard
- Add the card from the GUI

## File Structure

```
.devcontainer/
├── devcontainer.json # VS Code dev container config
├── .gitignore # Ignore HA data
└── README.md # This file
```

## Base Image

This project uses the published image:

- `ghcr.io/custom-cards/custom-card-devcontainer:latest`

The image includes the `container` helper used by the devcontainer lifecycle commands.

## Development Workflow

### Building the Card

```bash
# One-time setup (automatic on container creation)
yarn install

# Development with hot reload
yarn start # Runs Rollup in watch mode on port 5000

# Quality checks
yarn lint # ESLint check
yarn build # Full build pipeline (lint + rollup)

# Production build
yarn rollup # Create optimized dist files
```

### File Locations

- **Source Code**: `src/`
- **Built Output**: `dist/` (inside container)
- **Configuration**: Root directory (`tsconfig.json`, `rollup.config.js`, etc.)

## Troubleshooting

### Container Won't Start
```bash
# Rebuild the container
ctrl+shift+p → "Remote: Rebuild Container"
```

### Port Already in Use
```bash
# Find what's using port 5000 or 8123
lsof -i :5000
lsof -i :8123
```

### Node Modules Issues
```bash
# Clear and reinstall dependencies
rm -rf node_modules
yarn install
```

## Additional Resources

- [Home Assistant Custom Card Development](https://developers.home-assistant.io/docs/frontend/custom-ui/custom-card/)
- [VS Code Dev Containers Docs](https://code.visualstudio.com/docs/remote/containers)
- [Lit Documentation](https://lit.dev/)
- [Material Design Web Components](https://github.com/material-components/material-web)

## Environment Details

- **Node.js**: 24
- **TypeScript**: 5.9.3
- **Build Tool**: Rollup 4.20
- **Linter**: ESLint 9 + TypeScript Support
- **Code Formatter**: Prettier 3.8
- **Web Framework**: Lit 3.2
- **Home Assistant Image**: Latest (optional)

## Notes

- The container runs as non-root user `nodejs` for security
- Volume mounts use `cached` consistency mode for better performance on Mac/Windows
- All Yarn commands run inside the container automatically
- VS Code extensions are configured for TypeScript and YAML development
4 changes: 4 additions & 0 deletions .devcontainer/config/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
default_config:
demo:
homeassistant_alerts:
enabled: false
4 changes: 0 additions & 4 deletions .devcontainer/configuration.yaml

This file was deleted.

94 changes: 66 additions & 28 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,70 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
// For format details, see https://aka.ms/devcontainer.json
// Uses custom-cards/custom-card-devcontainer image for Home Assistant + Dev environment
{
"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
"name": "Home Assistant Custom Card Dev",

// Use published devcontainer image
"image": "ghcr.io/custom-cards/custom-card-devcontainer:latest",
"remoteUser": "vscode",

// Set working directory
"workspaceFolder": "/workspaces/test",

// Mount project to workspace, dist to Lovelace plugins, and config directory for Home Assistant
"mounts": [
"source=${localWorkspaceFolder},target=/workspaces/test,type=bind",
"source=${localWorkspaceFolder}/dist,target=/config/www/workspace,type=bind",
"source=${localWorkspaceFolder}/.devcontainer/config,target=/config,type=bind"
],
"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

// Forward Home Assistant port
"forwardPorts": [8123],
"portsAttributes": {
"8123": {
"label": "Home Assistant",
"onAutoForward": "notify"
}
},

// Container environment variables for Home Assistant setup
"containerEnv": {
"COREPACK_ENABLE_DOWNLOAD_PROMPT": "0",
"DEVCONTAINER": "1",
"HASS_USERNAME": "dev",
"HASS_PASSWORD": "dev",
"LOVELACE_REMOTE_FILES": "http://localhost:5000/boilerplate-card.js"
},

// Setup Home Assistant and install dependencies
"postCreateCommand": "container setup && corepack enable && yarn install",
"postStartCommand": "container launch & yarn start & wait",

// VS Code extensions for development
"customizations": {
"vscode": {
"extensions": [
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"bierner.lit-html",
"redhat.vscode-yaml",
"esbenp.prettier-vscode"
],
"settings": {
"typescript.enablePromptUseWorkspaceTsdk": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
},
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.tsserver.pluginPaths": [
"node_modules/typescript/lib"
],
"files.eol": "\n",
"task.allowAutomaticTasks": "on"
}
}
}
}
9 changes: 0 additions & 9 deletions .devcontainer/ui-lovelace.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions .eslintrc.js

This file was deleted.

19 changes: 19 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Enforce LF line endings for all text files
* text=auto eol=lf

# Explicitly declare common source file types
*.ts text eol=lf
*.js text eol=lf
*.json text eol=lf
*.md text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.css text eol=lf
*.html text eol=lf

# Binary files — no line ending conversion
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.zip binary
101 changes: 101 additions & 0 deletions .github/copilot-insturctions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# GitHub Copilot Instructions

You are assisting with development of this Home Assistant Lovelace custom card project.
The codebase is TypeScript + Lit and builds with Rollup.

Use these instructions as project-specific guardrails when generating, editing, or reviewing code.

## Quick reference

### Core commands

```bash
yarn install
yarn start
yarn build
yarn lint
```

### Primary files

- `src/boilerplate-card.ts` — main card implementation
- `src/editor.ts` — visual editor (`LovelaceCardEditor`)
- `src/types.ts` — card config and type definitions
- `src/action-handler-directive.ts` — tap/hold/double-tap directive
- `src/localize/localize.ts` — localization helper
- `src/localize/languages/en.json` and `src/localize/languages/nb.json` — translation files
- `rollup.config.js` and `rollup.config.dev.js` — production and dev build config

## Architecture and patterns

- The custom element is `custom:boilerplate-card`.
- Prefer Lit 3 patterns and idiomatic web component structure.
- Keep configuration shape centralized in `src/types.ts`.
- Keep editor schema and defaults aligned with runtime card behavior.
- Keep feature logic in small, readable helpers instead of long monolithic methods.

## TypeScript standards

- Use strict, explicit typing; avoid `any` unless there is no practical alternative.
- Use `import type` for type-only imports where appropriate.
- Validate and narrow optional config fields before use.
- Keep public API names stable unless explicitly requested to change them.

## Lit and component guidance

- Use `@property` for public reactive inputs and `@state` for internal state.
- Avoid direct DOM mutation when Lit reactivity can handle updates.
- Preserve existing card/editor lifecycle behavior.
- For card config, validate early in `setConfig` and throw actionable errors.
- Keep `getCardSize` deterministic and aligned with rendered density.

## Home Assistant integration

- Use Home Assistant helpers and conventions from `custom-card-helpers`.
- Ensure tap, hold, and double-tap actions are wired through existing action patterns.
- Support unavailable/loading/error states gracefully.
- Keep Lovelace config compatibility in mind when changing schema or defaults.

## Localization and copy

- Do not hardcode user-facing strings when a localize key should be used.
- Add new translation keys to both language files currently in the repo (`en.json`, `nb.json`).
- Keep copy concise, sentence case, and user-facing.
- Favor consistent terminology across card UI and editor labels.

## Styling and UX

- Respect Home Assistant theme variables and CSS custom properties.
- Avoid hardcoded colors when theme tokens can be used.
- Keep spacing and typography consistent with existing card styles.
- Ensure layouts work in both compact and wider dashboard widths.

## Build and quality expectations

- Keep `yarn lint` clean for changed code.
- Ensure `yarn build` succeeds after non-trivial changes.
- Do not introduce unrelated refactors in focused changes.
- If updating build tooling, keep dev and prod Rollup configs consistent.

## Safe change workflow

1. Read adjacent code before editing.
2. Implement the smallest viable change.
3. Run relevant checks (`yarn lint`, `yarn build`, or targeted command).
4. Update docs/README when behavior or config changes.
5. Summarize what changed and why.

## Pull request guidance

- Keep PRs focused to one logical change.
- Include screenshots or short clips for visible UI/editor changes.
- Document config changes and migration notes when applicable.
- Call out any follow-up work explicitly instead of bundling extra scope.

## Avoid these common issues

- Breaking editor/card config parity
- Adding untyped dynamic config access
- Hardcoding text instead of localization keys
- Overriding theme behavior with fixed styles
- Changing output filenames or card tag without explicit request
Loading