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

conditional state leaves a gap in card when 'off' #77

Open
Mariusthvdb opened this issue Mar 1, 2022 · 5 comments
Open

conditional state leaves a gap in card when 'off' #77

Mariusthvdb opened this issue Mar 1, 2022 · 5 comments

Comments

@Mariusthvdb
Copy link

Mariusthvdb commented Mar 1, 2022

type: vertical-stack
cards:

  - type: custom:state-switch
    entity: input_boolean.show_browser_path
    states:
      'on':
        type: custom:button-card
        aspect_ratio: 12/1
        variables:
          view: >
            [[[ return window.location.pathname.split('/')[2]; ]]]
#formatting 

  - type: custom:stack-in-card
    mode: horizontal

showing fine when 'on'

Schermafbeelding 2022-03-01 om 12 21 18

however, turning off the boolean, turns the state-switch off alright, but still leaves a gap:

Schermafbeelding 2022-03-01 om 12 21 31

clearly visible on the right hand side where both cards ideally should align

taking the state switch out of the vertical-stack and setting it individually in the view:

cards:

  - type: custom:state-switch
    entity: input_boolean.show_browser_path
    states:
      'on':
        type: custom:button-card
        aspect_ratio: 12/1
        variables:
          view: >
            [[[ return window.location.pathname.split('/')[2]; ]]]
        name: >
          [[[ function capitalizeFirstLetter(string) {
                return string.charAt(0).toUpperCase() + string.slice(1);
              }
              return capitalizeFirstLetter(variables.view.replace('_',' ')); ]]]
        styles:
          name:
            - justify-self: left

  - !include /config/lovelace/buttons/buttons_shortcut_menu.yaml

makes it behave as desired

Schermafbeelding 2022-03-01 om 13 54 34

Please let me know if this expected? or would I need to write-up an issue in vertical-stack frontend repo

@jazzyisj
Copy link

jazzyisj commented Mar 4, 2022

I experience the same. Unfortunately I have several instances where I must use a container card (I'm actually using stack-in-card). In my case it also triggers the borders/background so I have a visible line when there is an empty container.

image

I think it's possibly the same issue as this?
#63

If I had to guess the issue is the container card is created whether the state switch returns a result or not. I'm not sure there is anything Thomas can do about that with state-switch. The same thing happens with native conditional cards.

Perhaps the core container cards (vertical-stack, horizontal-stack) could check to see if they contain any cards and hide themselves if not, similar to entity-filter and the show_empty parameter?

@Mariusthvdb
Copy link
Author

yes, it probably is.
though I fear its not a state-switch issue, but are a thing of the container cards. Its been a long time thing for conditional card in core HA, so always try and use state-switch, and find a way no gaps are shown.

@jazzyisj
Copy link

Hey Marius I think this go resolved on the HA end, looks like conditional cards are fixed too. Can you confirm?

I used to get a space/border here, it's gone now.
image

@Mariusthvdb
Copy link
Author

no it is still there, showing here with a somewhat cryptic screenshot, but suffice to say the large vertical gap holds a few camera's that now are not showing, because of the condition. Should have been the same height as the vertical gap:

Scherm­afbeelding 2023-03-22 om 12 19 46

@mrgrlscz
Copy link

mrgrlscz commented Jul 4, 2023

Hi there, foud this workaround to align the cards when state-switch is not "active" (the off state display a blank card).
it's working for me
BUT
there's a little movement/animation when the view is loaded
any idea to improve that?

type: custom:stack-in-card
card_mod:
  style: |
    ha-card {
      margin-top: {{ "-8px" if is_state('your_entity','off') }}; /*maybe you'll have to adjust the '8px' value*/
    }
cards:
  - type: custom:state-switch
    entity: your_entity
    states:
      'on':
        type: ..................................

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants