stormgateworld / web

Community Website with Leaderboards, Profiles and more for Stormgate.
https://stormgateworld.com
14 stars 8 forks source link

SolidJS widget to format date[time]s #98

Closed acarapetis closed 8 months ago

acarapetis commented 8 months ago

Here's my attempt at #42: a SolidJS component FormatDate that can render as an absolute date, absolute datetime or a relative time ago. I've replaced all usage of TimeAgo with it, and also updated MatchPreview to use it.

I've got one annoyign bug hanging around - when using a non-relative format, the rendered HTML is not updating currently when hydrating on the client - the UTC times just hang around forever. The console.log debugging call I've got in there is outputting what I expect on the client, so the code is definitely running; it's just not rendering correctly for some reason.

This is my first time touching both Astro and SolidJS so I figured I'd ask for help rather than spend any more time banging my head against it - there's clearly something I don't understand either in how the SSR hydration works, or just how SolidJS works. Also open to any other feedback :)

robertvanhoesel commented 8 months ago

Thanks, I'll take a look!

acarapetis commented 8 months ago

@robertvanhoesel Thanks for the review! I've pushed some changes following your advice and removed the debugging code.