mishaaq / sun-card

Lovelace card for sun component - Home Assistant
MIT License
51 stars 10 forks source link

Name can't be hidden #11

Closed kquinsland closed 4 years ago

kquinsland commented 4 years ago

Describe the bug The name: field is optional, but blank or unset values do not hide the name from the card

To Reproduce

  1. configure the sun card in lovelace
  2. set the name: property to False or comment it out entirely in the config
  3. observe the default Sun still showing up on the card.

Expected behavior I would expect that a value of False or an unset value would hide the label/name from the card

Additional context I am trying to achieve a dense lovelace UI for a project. Every vertical pixel matters and i would like to reclaim the pixels that the name: takes up.

mishaaq commented 4 years ago

Fixed in f92431e9bfea2d1f3171e3c7d6316a6a188accc2

kquinsland commented 4 years ago

What value should i put in my lovelace config? I do not see any code that hides the element:

    const header = this._config.name === undefined
      ? sunEntity.friendly_name || localize('domain.sun')
      : this._config.name;

If nothing is provided, a reasonable fall back is chosen, it looks like.

mishaaq commented 4 years ago

Just remove the default value in config editor (set empty value). If an empty value is provided, the "header" slot in a card takes null value and is being omited in rendering process.

kquinsland commented 4 years ago

I'm not using the UI editor; just YAML. See the attached screenshots. When i comment out the name: field, the default vault is present...

// Probably evaluates to true
this._config.name === undefined?

// Probably evaluates to undefined OR sun
sunEntity.friendly_name || localize('domain.sun')

// This does not become relevant because of the OR condition
      : this._config.name;  

I have put together some screenshots here that should make it clear:

https://imgur.com/a/MaYH4Lg

EDIT: I have also tried w/ the name: setting defined in YAML, but with no value and with an empty string value:

          - type: "custom:sun-card"
            # Omit the name to hide it.
            # Waiting for feedback..
            # See: https://github.com/mishaaq/sun-card/issues/11#issuecomment-568936942
            name:
            meridiem: true

and


          - type: "custom:sun-card"
            # Omit the name to hide it.
            # Waiting for feedback..
            # See: https://github.com/mishaaq/sun-card/issues/11#issuecomment-568936942
            name: ""
            meridiem: true
``
mishaaq commented 4 years ago

Right. Try to set an empty string value in yaml therefore: name: "" It should work.

kquinsland commented 4 years ago

Can you confirm that either of the two yaml snips i provided do work? If they do, then that means something else is adding the name back... and it will take some time to trace from where as the entire HA/Py code base and the JS client side would be in question/scope. I will try to put a debugger on the JS assets once i figure out how to do that :).

mishaaq commented 4 years ago

I can confirm that both variations work (the first one with empty value is being replaced with null value after save, though).