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
75 stars 16 forks source link

Modify gameday text logic #27

Closed austinbeam closed 1 year ago

austinbeam commented 1 year ago

Show short month plus numeric day if game not occurring within a week. Show "Today" if the game is occurring today. This helps avoid any confusion at first glance when the day of the week is shown.

Note: had trouble with the translate function of the Translator, so hardcoded this English. I'm not familiar with this, so may be an easy fix to have this display properly and include locale support.

austinbeam commented 1 year ago

Leaving it as-is (i.e. only the weekday shown) within the week provides a great visual clue to the user. If I see a date, I know it's not this Saturday, but one in the future. Definitely not defending my implementation as I'm sure it could be prettier, but I'd suggest trying to keep this distinction that stays true to the original design while offering clarity to users for dates beyond a week in the future. As noted, perfectly fine with refining the implementation and will look into a better approach.

Good point on the "Today" logic, I did that pretty quickly and know it can be improved. I'll see if I can come up with a better implementation there, but understand your concerns about added dependencies also.

vasqued2 commented 1 year ago

Good point on the visual distinction. It hit me the easiest way to test 7 days and even "today" is probably to pull just the 'dd' using toLocaleDateString() which should convert the day based on the timezone and then see if it's >6 dates from today or matches today.

That would allow just adding "Today" to the language files which wouldn't be bad.

austinbeam commented 1 year ago

@vasqued2 Take a look at the updated implementation, think I've addressed several concerns. Also added a bit of functionality including the "Tomorrow" concept and retaining the long day of week display for either Today or Tomorrow.

One thing that isn't working on my side is the translation. I think I added everything correctly but cannot get my instance to serve the updated language files. Consequently, I'm still showing '{common.today}' where Today should be using en_US and similar for tomorrow unless I hard code those texts. Let me know if I did something incorrectly or it's just an artifact of HACS and re-installing (seems like it simply refuses to update the language files though the main js will update).

Thanks.

vasqued2 commented 1 year ago

Looks like it should work. I'm out of town and don't have access to my machine so I'll try it in the next day or two and see if I can figure out what's going on. You have to make sure you clear cache and refresh when making updates to the card for it to pick up everything new. Maybe it's related to something like that, although I've never had issues w/ just the language files before.