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

Home Assistant 2022.11 compatibility #47

Open
wants to merge 5 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## Note: outdated, use https://github.com/stickpin/stack-in-card instead

# Stack In Card by [@RomRider](https://www.github.com/RomRider)

A replacement for [vertical-stack-in-card](https://github.com/ofekashery/vertical-stack-in-card) and `horizontal-stack-in-card`
Expand Down Expand Up @@ -34,6 +36,7 @@ If a card inside the stack has the `--keep-background` CSS style defined, it wil
| `box_shadow` | boolean | **Optional** | Will keep the `box-shadow` on **all** the child cards | `false` |
| `margin` | boolean | **Optional** | Will keep the `margin` between **all** the child cards | `false` |
| `outer_padding` | boolean | **Optional** | Will add a `padding` of `8px` to the card if `margin` is `true` | `true` if `margin` is `true`, else false |
| `border` | boolean | **Optional** | Will keep the `border` on **all** the child cards | `false` |
| `border_radius` | boolean | **Optional** | Will keep the `border-radius` on **all** the child cards | `false` |

## Example
Expand All @@ -60,6 +63,28 @@ If a card inside the stack has the `--keep-background` CSS style defined, it wil
- sun.sun
```

### Example with `keep` object

```yaml
type: custom:stack-in-card
title: My Stack In Card
mode: vertical
keep:
background: true
cards:
- type: horizontal-stack
cards:
- type: button
entity: sun.sun
- type: button
entity: sun.sun
- type: vertical-stack
cards:
- type: entities
entities:
- sun.sun
```

### Example with button-card to keep the background

This will keep the background of the button even if stacked:
Expand Down
4 changes: 4 additions & 0 deletions src/stack-in-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class StackInCard extends LitElement implements LovelaceCard {
margin: false,
box_shadow: false,
border_radius: false,
border: false,
...config.keep,
},
};
Expand Down Expand Up @@ -96,6 +97,9 @@ class StackInCard extends LitElement implements LovelaceCard {
private _updateStyle(e: LovelaceCard | null, withBg: boolean): void {
if (!e) return;
if (!this._config?.keep?.box_shadow) e.style.boxShadow = 'none';
if (!this._config?.keep?.border && getComputedStyle(e).getPropertyValue('--keep-border').trim() !== 'true') {
e.style.border = 'none';
}
if (
!this._config?.keep?.background &&
withBg &&
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface KeepConfig {
margin?: boolean;
background?: boolean;
box_shadow?: boolean;
border?: boolean;
border_radius?: boolean;
outer_padding?: boolean;
}