custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.97k stars 242 forks source link

Add screen / media_query to triggers_update #864

Open Mariusthvdb opened 3 months ago

Mariusthvdb commented 3 months ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

requiring updating the button-card upon screen rotation to set various numbers in animations like

  available: >
     [[[ return window.matchMedia('(max-width:370px)').matches &&
                window.matchMedia('(orientation:portrait)').matches
         ? 25 : 36; ]]]

which currently cant be done, as there is no entity for those properties, hence the template wont update other than on reload of the view

Describe the solution you'd like A clear and concise description of what you want to happen. aadd window/screen/media_query to triggers_update

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

only other workaround now is duplicate the card, and set type: conditional or layout card, as documented extensively in https://community.home-assistant.io/t/how-to-make-scroll-time-speed-and-translatex-string-length-dependent-in-css-animation/754407/8

  - type: conditional
    conditions:
      - condition: screen
        media_query: "(min-width:400px)"
    card: !include /config/dashboard/includes/button/button_marquee_alerts_css_wide.yaml
  - type: conditional
    conditions:
      - condition: screen
        media_query: "(max-width:399px)"
      - condition: screen
        media_query: "(orientation:portrait)"
    card: !include /config/dashboard/includes/button/button_marquee_alerts_css_narrow.yaml

Additional context Add any other context or screenshots about the feature request here. see link to community above.

All it would take is the button-card to update on those screen orientations/sizing of the view

Hope you can consider, thanks!