Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Apr 6, 2019
1 parent 3bb7e72 commit 7a9104d
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 1 deletion.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Custom cards for Home Assistant

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.
73 changes: 72 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,72 @@
text-divider-row
# 📺 Text Divider Row

[![GitHub Release][releases-shield]][releases]
[![GitHub Activity][commits-shield]][commits]
[![custom_updater][customupdaterbadge]][customupdater]
[![License][license-shield]](LICENSE.md)

![Project Maintenance][maintenance-shield]
[![BuyMeCoffee][buymecoffeebadge]][buymecoffee]

[![Discord][discord-shield]][discord]
[![Community Forum][forum-shield]][forum]

This card is for [Lovelace](https://www.home-assistant.io/lovelace) on [Home Assistant](https://www.home-assistant.io/) to display a text divider in an entities card

<!-- ![example](example.png) -->

## Options

| Name | Type | Requirement | Description
| ---- | ---- | ------- | -----------
| type | string | **Required** | `custom:text-divider-row`
| text | string | **Required** | Text to display in divider

## Installation

### Step 1

Save [text-divider-row](https://github.com/custom-cards/text-divider-row/raw/master/text-divider-row.js) to `<config directory>/www/text-divider-row.js` on your Home Assistant instance.

**Example:**

```bash
wget https://raw.githubusercontent.com/custom-cards/text-divider-row/master/text-divider-row.js
mv text-divider-row.js /config/www/
```

### Step 2

Link `text-divider-row` inside your `ui-lovelace.yaml` or Raw Editor in the UI Editor

```yaml
resources:
- url: /local/text-divider-row.js
type: module
```
### Step 3
Add a custom element in your `ui-lovelace.yaml` or in the UI Editor as a Manual Card

```yaml
type: 'custom:text-divider-row'
text: divider
```

[Troubleshooting](https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins)

[buymecoffee]: https://www.buymeacoffee.com/iantrich
[buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-blue.svg?style=for-the-badge
[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-cards/text-divider-row.svg?style=for-the-badge
[commits]: https://github.com/custom-cards/text-divider-row/commits/master
[customupdater]: https://github.com/custom-components/custom_updater
[customupdaterbadge]: https://img.shields.io/badge/custom__updater-true-success.svg?style=for-the-badge
[discord]: https://discord.gg/Qa5fW2R
[discord-shield]: https://img.shields.io/discord/330944238910963714.svg?style=for-the-badge
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge
[forum]: https://community.home-assistant.io/
[license-shield]: https://img.shields.io/github/license/custom-cards/text-divider-row.svg?style=for-the-badge
[maintenance-shield]: https://img.shields.io/badge/maintainer-Ian%20Richardson%20%40iantrich-blue.svg?style=for-the-badge
[releases-shield]: https://img.shields.io/github/release/custom-cards/text-divider-row.svg?style=for-the-badge
[releases]: https://github.com/custom-cards/text-divider-row/releases
56 changes: 56 additions & 0 deletions text-divider-row.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
var LitElement =
LitElement ||
Object.getPrototypeOf(customElements.get("home-assistant-main"));
var html = LitElement.prototype.html;

class TextDividerRow extends LitElement {
static get properties() {
return {
_config: {}
};
}

setConfig(config) {
if (!config || !config.text) {
throw new Error("Error in card configuration.");
}

this._config = config;
}

render() {
if (!this._config) {
return html``;
}

return html`
${this.renderStyle()}
<h2 class="text-divider"><span>${this._config.text}</span></h2>
`;
}

renderStyle() {
return html`
<style>
.text-divider {
margin: 2em 0;
line-height: 0;
text-align: center;
}
.text-divider span {
background-color: var(--card-background-color);
padding: 1em;
color: var(--secondary-text-color);
}
.text-divider:before {
content: " ";
display: block;
border-top: 1px solid var(--secondary-text-color);
border-bottom: 1px solid #f7f7f7;
}
</style>
`;
}
}

customElements.define("text-divider-row", TextDividerRow);

0 comments on commit 7a9104d

Please sign in to comment.