vasqued2 / ha-teamtracker-card

A Home Assistant frontend custom card that will display real-time updates for teams tracked with the ha-teamtracker integration. Has custom in-game layouts for football, baseball, basketball, hockey, soccer, golf, tennis, racing, and mma.
GNU General Public License v3.0
77 stars 16 forks source link

Dark mode team logos #111

Closed SeanPM5 closed 1 month ago

SeanPM5 commented 2 months ago

The default team logos for some teams look pretty bad in dark mode, here is the Yankees for example:

Screen Shot 2024-09-01 at 4 34 57 PM

There are dark mode variants of these logos available, it would be nice if they were used instead when the user is in dark mode. It makes a big improvement for readability:

Screen Shot 2024-09-01 at 4 34 48 PM

Another before/after example:

Screen Shot 2024-09-01 at 4 58 20 PM Screen Shot 2024-09-01 at 4 58 06 PM

Here are example of URL's (same structure and filename but /500/ becomes /500-dark/):

Regular URL's that Team Tracker card currnently uses: https://a.espncdn.com/i/teamlogos/mlb/500/scoreboard/nyy.png Dark mode URL's: https://a.espncdn.com/i/teamlogos/mlb/500-dark/scoreboard/nyy.png

vasqued2 commented 2 months ago

Thanks.

Do you know if these are universally available for all the sports the APIs support? The API only returns the regular logos. I could obviously derive them if I knew they were available for all sports. Also, do you know how to programmatically determine if dark mode is selected?

vasqued2 commented 2 months ago

Quick testing indicates that dark logos are not universally available and dark mode is indicated by hass.themes.darkMode. I'll see what I can do w/o breaking current functionality when I get a chance.

SeanPM5 commented 2 months ago

Thanks for looking into it. I'm not sure how widespread the dark variant images are, but from a quick test it appears to be supported on all the "Big Four" leagues (NFL, MLB, NBA, NHL). Some additional examples here:

NFL (NY Jets): Light: https://a.espncdn.com/i/teamlogos/nfl/500/scoreboard/nyj.png Dark: https://a.espncdn.com/i/teamlogos/nfl/500-dark/scoreboard/nyj.png

NFL (NY Giants): Light: https://a.espncdn.com/i/teamlogos/nfl/500/scoreboard/nyg.png Dark: https://a.espncdn.com/i/teamlogos/nfl/500-dark/scoreboard/nyg.png

NBA (Utah Jazz): Light: https://a.espncdn.com/i/teamlogos/nba/500/scoreboard/utah.png Dark: https://a.espncdn.com/i/teamlogos/nba/500-dark/scoreboard/utah.png

NHL (Maple Leafs): Light: https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/tor.png Dark: https://a.espncdn.com/i/teamlogos/nhl/500-dark/scoreboard/tor.png

I haven't yet seen a 404 error on those "dark" URL's for these particular sports. It seems that if there's no dark-specific logo it simply returns the "light" logo rather than any kind of error. So I think it's safe for NFL, MLB, NBA, NHL but I can't say 100% for certain.

I know the card supports a lot more sports than those four leagues though.

PHI34Halladay commented 2 months ago

Just tried it for european soccer teams (Juventus) and the 500-dark also works.

The only problem I see here is, that there is no specific dark entry in the team attributes.

Anyways it would be awesome if it can be done ;)

vasqued2 commented 2 months ago

I definitely like the idea. Looks like rugby, cricket, and Australian rules football are some sports that could cause problems. I'm not getting a page not found error but am also not getting a dark logo. I'll have to make the change and see how they behave, how I can detect, etc.

Thanks for the idea

vasqued2 commented 2 months ago

Added in release v0.14.7. Thanks for the idea. It should automatically detect when the theme is in dark mode and use the dark mode logos.

SeanPM5 commented 2 months ago

Thanks! It works great and makes a big difference on my tablet.

One minor thing, the team/opponent backgrounds aren't using the dark variant logos. Doesn't bother me personally as I plan to use card-mod to hide those, but just wanted to point it out.

How it looks now (the Yankees side looks like it doesn't have a background at all, but it's just illegible):

Screen Shot 2024-09-03 at 9 41 06 PM

How it would look with dark team logo backgrounds:

Screen Shot 2024-09-03 at 9 41 19 PM
vasqued2 commented 1 month ago

I noticed but wanted time to confirm the league logos have dark mode versions too (they do) before adding.

vasqued2 commented 1 month ago

Added background dark mode logos to v0.14.9