ofekashery / vertical-stack-in-card

📐 Home Assistant Card: Group multiple cards into a single sleek card.
MIT License
896 stars 79 forks source link

Feature/editor #125

Closed acesyde closed 2 years ago

acesyde commented 2 years ago

Description

Add editor to the vertical stack in card

Related Issue

123

Motivation and Context

How Has This Been Tested

Locally

Types of changes

Checklist

Screenshots

image image

acesyde commented 2 years ago

Hi @ofekashery

I have some problems with history-graph and humidifier I don't understand why these components keep their borders :(

Can you help me to finish ?

Sample

type: custom:vertical-stack-in-card
cards:
  - type: light
    entity: light.ceiling_lights
  - type: button
    tap_action:
      action: toggle
    entity: switch.decorative_lights
  - type: history-graph
    entities:
      - sun.sun
  - type: humidifier
    entity: humidifier.humidifier

Screenshot

image

M4D1NG3R commented 2 years ago

@acesyde I am not sure whether this is intended or not, but for me the updated card removes the ha-card-border-radius set in the theme. This issue had previously been solved: 81

M4D1NG3R commented 2 years ago

@acesyde removing ele.style.borderRadius = '0'; (line 102 & 124 in src/vertical-stack-in-card.ts) solved my issue and also removes the borders from history-graph and humidifier

Could you verify?

Please also check whether this bricks something else.

acesyde commented 2 years ago

Hi @M4D1NG3R

I removed these 2 lines of code (existing in current code)

But the borders are still here :( image

acesyde commented 2 years ago

And I don"t know why the styles are not applied on these cards

image

M4D1NG3R commented 2 years ago

ok, I am sorry, I just rebuild it, but this time it also did not work for me. I might have had the original file in cache.

M4D1NG3R commented 2 years ago

Also, I get some weird behavior when using the mushroom chip card: image on the one side the theme is applied, on the other it's not.

When comparing https://github.com/ofekashery/vertical-stack-in-card/commit/d0cb3bfcaa3f9a45f0b1b5f62cf9259d09deda23 which fixed https://github.com/ofekashery/vertical-stack-in-card/issues/81. Only a few lines changed one of them is the addition of:

line 39 card.style.overflow = 'hidden';

Unfortunately, I can't do anything with it, I'm too inexperienced for that. Does this help you?

M4D1NG3R commented 2 years ago

Ok, I may have the fix for my issue: adding overflow: hidden; after line 171 fixed my issue. this needs to be done additionally to removing ele.style.borderRadius = '0'; (line 102 & 124 in src/vertical-stack-in-card.ts)

acesyde commented 2 years ago

@M4D1NG3R ok I will add that after

But with the original card (js not ts) I have also the same problem with histroy-graph

image

M4D1NG3R commented 2 years ago

@acesyde Yeah, me too, do you have the same problem with stack-in-card?

acesyde commented 2 years ago

@acesyde Yeah, me too, do you have the same problem with stack-in-card?

I don't know, tomorrow I will try it

acesyde commented 2 years ago

It seems to works better with stack in card, thanks for the advice, so I need to investigate ;)

image

M4D1NG3R commented 2 years ago

@acesyde please try replacing line 69-77

    // Style cards
    this._cards.forEach((card) => {
      if ((card as any).updateComplete) {
        (card as any).updateComplete.then(() => this._cleanCardStyle(card));
      } else {
        this._cleanCardStyle(card);
      }
    });
  }

with:

    // Style cards
    this._cards.forEach((card) => {
      this._waitForUpdate(card);
      window.setTimeout(() => {
        this._waitForUpdate(card);
      }, 500);
    });
  }

  private _waitForUpdate(card: LovelaceCard): void {
    if ((card as any).updateComplete) {
      (card as any).updateComplete.then(() => this._cleanCardStyle(card));
    } else {
      this._cleanCardStyle(card);
    }
    this._cleanCardStyle(card);
  }
acesyde commented 2 years ago

Hey @M4D1NG3R it's better :) but the humidifier informations doesn't appear :\

image

acesyde commented 2 years ago

image

It works

acesyde commented 2 years ago

image

image

Works with mushroom but a little bug with chips :(

acesyde commented 2 years ago

@ofekashery what do you think about that ?

ofekashery commented 2 years ago

Fixed in #128.