lovelace-card-mod icon indicating copy to clipboard operation
lovelace-card-mod copied to clipboard

Question from a rookie custom card developer, styling doesn't work for my card.

Open aukedejong opened this issue 2 years ago • 4 comments

Hi, I'm working on a custom card. One of the testers of the card discovered that card_mod styling doesn't work. I could reproduce the problem, but did not find a solution yet.

For some reason the class defined in the yaml, isn't applied to the ha-card element of my custom card. It works for other cards. The styling is working in de Card config panel, when you configure and add the card to the dashboard. On the dashboard the styling is gone.

Added yaml:

card_mod:
  class: top-level-card

Custom card: https://github.com/aukedejong/lovelace-windrose-card

https://community.home-assistant.io/t/lovelace-windrose-card/523319/20 Tom_I found the problem and posted some details.

Did I make a rookie mistake? I'm hoping you can point me in the right direction.

Thanks.

aukedejong avatar Feb 03 '23 16:02 aukedejong

Where is the card itself?

ildar170975 avatar Feb 04 '23 01:02 ildar170975

This is the repo

https://github.com/aukedejong/lovelace-windrose-card

Editted the post, forgot to add a link display text.

Thanks

aukedejong avatar Feb 04 '23 08:02 aukedejong

Finally found the problem. The setConfig method in the card caused the problems.

It needs to set the config property. I use an other property name and wrapped the config.

Not working:

    setConfig(config: any): void {
        this.cardConfig = new CardConfigWrapper(config);
    }

Working:

    setConfig(config: any): void {
        this.config = config;
        this.cardConfig = new CardConfigWrapper(config);
    }

I don't understand why this has impact on card_mod.

aukedejong avatar Apr 25 '23 18:04 aukedejong

Cheers for figuring this out @aukedejong, have been scratching my head at the same issue for ages.

thybag avatar Jun 09 '24 16:06 thybag