hello again! my main focus for this devlog has been on experimenting with loading/transition behavior for queries. before, the page would remove all of the card components and just show a “Results: loading…” screen and an unstyled <li> loading element, but i wanted to improve that and make it more animated and less “flashy”.
the first part of the transition comes on the “leading edge”, when the user updates their query and information has not yet been fetched. if i let the previous cards and results stay up, the site will be perceived as laggy and not responsive. so, my instinct would be to place a “skeleton UI” but that in itself would be a DOM update/layout reflow, which i wanted to avoid for performance reasons. i tried blurring individual card elements, but i didn’t like how it looked. maybe i settle with a skeleton UI or come up with some other combination of CSS effects, i don’t know. either way, i didn’t want the effect to show up if the request hits the cache, so instead of using solid.js’s existing useTransition hook, i manually combined the underlying startTransition function with my own pending signal, which i only set to true if the query was not found in the cache. this does mean that on cache hits the code looks up the map two times (once on the initial check for the pending signal, another on the resource fetch), but i don’t think trying to optimize that away with a boolean or something would end up being faster than just letting v8 optimize the double Map lookup.
for the second part–or, trailing edge–of the interaction, i had this idea of constructing a view transition so that cards that showed up previously would move nicely to their resulting spot. that unfortunately made things really laggy, especially since view-transition-name would be declared on both the cards themselves and many items within the card, as those would need to be labeled for the view transition to the product page. the visual effect was really nice though, so my plan to make it work is to finally introduce virtual scroll… yes i know i’m fixing more javascript with more javascript, but at least the site works without it! right?!
additional minor thoughts:
- i’m starting to not like the star/basket buttons. i was looking online for product card inspiration, and most of the designs i found were a lot more minimal, many of them even omit the “Learn more” button for a cleaner visual aesthetic. for now i’ll probably change out the buttons to just the underlying icon outlines, but keep the bounding box. my qualm with removing “Learn more” is discoverability on mobile, since i couldn’t disclose product page functionality through a hover effect. maybe once the card reaches a certain height on the viewport then i’ll activate the hover progresive disclosure for mobile, but idk.
- maybe i should fetch in the background? with the transition effect, it would be nice for it to apply when you backspace, and at that point the site isn’t really doing any more network stuff aside from prefetching hovered cards, so i could fetch all of the sliced versions of the query (i.e. for “beam” it would fetch “b”, “be” and “bea” in the background).
- should i persist the results count on scroll? maybe integrated within the navigation bar, or in smaller text in a pill under, idk.