diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..877ba4e
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+fold-entity-row.js binary
diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md
new file mode 100644
index 0000000..9b22dc5
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug-report.md
@@ -0,0 +1,51 @@
+---
+name: Bug report
+about: For reporting bugs or unexpected behavior of popup-card
+title: ''
+labels: ''
+assignees: ''
+---
+
+My Home Assistant version: 0.XX.X
+
+
+My lovelace configuration method (GUI or yaml):
+
+
+What I am doing:
+
+
+What I expected to happen:
+
+
+What happened instead:
+
+
+**Minimal** steps to reproduce:
+
+
+```yaml
+# The least ammount of code possible to reproduce my error
+
+
+
+# End of code
+```
+
+
+Error messages from the browser console:
+
+
+---
+
+**By putting an X in the boxes ([ ]) below, I indicate that I:**
+
+[ ] Understand that this is a channel for reporting bugs, not a support forum (https://community.home-assistant.io/).
+
+[ ] Have made sure I am using the latest version of popup-card.
+
+[ ] Have made sure I am using the latest version of [card-tools](https://github.com/thomasloven/lovelace-card-tools).
+
+[ ] Have followed the troubleshooting steps of the "Common Problems" section of https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins.
+
+[ ] Understand that leaving one or more boxes unticked or failure to follow the template above may increase the time required to handle my bug-report, or cause it to be closed without further action.
diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md
new file mode 100644
index 0000000..6c9159d
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature-request.md
@@ -0,0 +1,7 @@
+---
+name: Feature request
+about: For suggesting new features of popup-card
+title: ''
+labels: ''
+assignees: ''
+---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d26a54b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+node_modules/
+package-lock.json
+package.json
+webpack.config.js
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..5b9de40
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,42 @@
+AUTHOR := Thomas Lovén
+CARD_TOOLS := $(PWD)/../card-tools
+
+PACKAGE := $(shell basename $(CURDIR))
+PACKAGE := $(PACKAGE:lovelace-%=%)
+DOCKER_CMD:=docker run --rm -v $(CARD_TOOLS):/card-tools:ro -v $(PWD):/usr/src/$(PACKAGE) -w="/usr/src/$(PACKAGE)" node:11
+
+build: setup
+ $(DOCKER_CMD) npm run build
+
+dev: setup
+ $(DOCKER_CMD) npm run watch
+
+setup: package.json package-lock.json webpack.config.js
+
+clean:
+ rm package.json package-lock.json webpack.config.js
+ rm -r node_modules
+ rm $(PACKAGE).js
+
+define WEBPACK_CONFIG
+const path = require('path');
+
+module.exports = {
+ entry: './src/main.js',
+ mode: 'production',
+ output: {
+ filename: '$(PACKAGE).js',
+ path: path.resolve(__dirname)
+ }
+};
+endef
+export WEBPACK_CONFIG
+webpack.config.js:
+ echo "$$WEBPACK_CONFIG" >> $@
+
+package-lock.json:
+ $(DOCKER_CMD) npm install webpack webpack-cli --save-dev
+
+package.json:
+ $(DOCKER_CMD) /bin/bash -c "npm set init.license 'MIT' && npm set init.author.name '$(AUTHOR)' && npm init -y"
+ $(DOCKER_CMD) sed -E -i -e '/^ +"main"/d' -e '/^ +"scripts"/a\ "build": "webpack",' -e '/^ +"scripts"/a\ "watch": "webpack --watch --mode=development",' -e '2a\ "private": true,' $@
diff --git a/README.md b/README.md
index 7380c6f..16a1c4c 100644
--- a/README.md
+++ b/README.md
@@ -1,99 +1,134 @@
fold-entity-row
-========================
+===============
-Make a group from entities in a lovelace entities card - and fold them away when you don't want to see them.
-
-This card requires [card-tools](https://github.com/thomasloven/lovelace-card-tools) to be installed.
+Fold away and hide rows in lovelace [entities](https://www.home-assistant.io/lovelace/entities/) cards.
For installation instructions [see this guide](https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins).
-## Options
+Install `fold-entity-row.js` as a `module`.
-| Name | Type | Default | Description
-| ---- | ---- | ------- | -----------
-| type | string | **Required** | `custom:fold-entity-row`
-| head | entity/object | **Required** | The entity or row that should be the header
-| items | list | none | Entites or rows to put in the fold
-| group_config | object | none | Extra options to put on each item in the list
-| open | boolean | false | Set to true to have the fold opened by default
+## Usage
+Add this to an entities card:
+
+```yaml
+type: entities
+entities:
+ - light.bed_light
+ - type: custom:fold-entity-row
+ head: light.bed_light
+ entities:
+ - light.bed_light
+ - light.ceiling_lights
+ - light.kitchen_lights
+```
+
+This will show the row specified in `head:` with an arrow next to it. When clicked, the rows specified in `entities:` will be revealed.
+
+
+
+### Options
+
+- `head:` and any row in `entities:` can be customized in exactly the same ways as ordinary [entities](https://www.home-assistant.io/lovelace/entities/) card rows.
+
+```yaml
+type: custom:fold-entity-row
+head:
+ type: section
+ label: Customizations
+entities:
+ - light.bed_light
+ - entity: light.ceiling_lights
+ name: A light
+ - light.kitchen_lights
+```
+
+- Options specified in `group_config:` will be applied to all rows in the fold.
+
+```yaml
+type: custom:fold-entity-row
+head:
+ type: section
+ label: group_config
+group_config:
+ secondary_info: last-changed
+ icon: mdi:desk-lamp
+entities:
+ - light.bed_light
+ - light.ceiling_lights
+ - light.kitchen_lights
+```
+
+- The left side padding can be adjusted by the `padding:` parameter (value in pixels).
+
+```yaml
+type: custom:fold-entity-row
+head:
+ type: section
+ label: padding
+padding: 5
+entities:
+ - light.bed_light
+ - light.ceiling_lights
+ - light.kitchen_lights
+```
+
+- Setting `head:` to a group will populate the entities list with the entities of that group.
+
+```yaml
+type: custom:fold-entity-row
+head: group.all_lights
+```
+
+- Setting `open:` to true will make the fold open by default.
+
+```yaml
+type: custom:fold-entity-row
+head:
+ type: section
+ label: open
+open: true
+entities:
+ - light.bed_light
+ - light.ceiling_lights
+ - light.kitchen_lights
+```
+
+
+
+### Advanced
+
+- Folds can be nested
+
+```yaml
+type: custom:fold-entity-row
+head:
+ type: section
+ label: Nested
+entities:
+ - type: custom:fold-entity-row
+ head: light.bed_light
+ entities:
+ - type: custom:fold-entity-row
+ head: light.bed_light
+ entities:
+ - light.bed_light
+```
+
+- Folds can be populated by any wrapping element that fills the `entities:` parameter, such as [auto-entities](https://github.com/thomasloven/lovelace-auto-entities)
+
+```yaml
+type: custom:auto-entities
+filter:
+ include:
+ - domain: sensor
+card:
+ type: custom:fold-entity-row
+ head:
+ type: section
+ label: Automatically populated
+```
+
+
---
-
-```yaml
-type: entities
-title: Folding entities
-entities:
- - light.bed_light
- - type: custom:fold-entity-row
- head: sensor.yr_symbol
- items:
- - sensor.outside_humidity
- - sensor.outside_temperature
- - light.bed_light
- - type: custom:fold-entity-row
- head:
- type: section
- label: Lights
- group_config:
- secondary_info: last-changed
- items:
- - light.bed_light
- - light.ceiling_lights
- - light.kitchen_lights
- - light.bed_light
-```
-
-
-
-### Groups will populate the fold automatically
-
-If the head is a group, `items:` will be ignored and the fold will instead be filled with the entities in the group.
-
-```yaml
-type: entities
-title: Folding groups
-entities:
- - type: custom:fold-entity-row
- head: group.all_lights
- - type: custom:fold-entity-row
- head: group.all_scripts
- - type: custom:fold-entity-row
- head: group.all_automations
-```
-
-
-
-
-#### Use with entity-filter
-The `items` list can be populated by `entity-filter` using a trick:
-
-```yaml
-type: entities
-title: Entity Filter Fold
-entities:
- - type: custom:hui-entity-filter-card
- entities:
- - light.bed_light
- - light.ceiling_lights
- - light.kitchen_lights
- state_filter:
- - "on"
- card:
- type: custom:fold-entity-row
- head:
- type: section
- label: Lit lamps
-
- - type: custom:hui-entity-filter-card
- entities:
- - light.bed_light
- - light.ceiling_lights
- - light.kitchen_lights
- state_filter:
- - "off"
- card:
- type: custom:fold-entity-row
- head:
- type: section
- label: Unlit lamps
-```
+
diff --git a/fold-entity-row.js b/fold-entity-row.js
index 317b4f5..2b01771 100644
--- a/fold-entity-row.js
+++ b/fold-entity-row.js
@@ -1,145 +1,51 @@
-customElements.whenDefined('card-tools').then(() => {
-let cardTools = customElements.get('card-tools');
-class FoldEntityRow extends cardTools.LitElement {
-
- static get properties() {
- return {
- _closed: Boolean,
- };
- }
-
- render() {
- return cardTools.LitHtml`
- ${this._renderStyle()}
-