feat: jump to lifter on meet pages
For large meets, it can be very difficult to find a lifter when you go
from their profile to a specific meet. This usually involves searching
through all the divisions or doing a Cmd+F
to find their name
specifically.
Instead, we can center the page on the lifter and highlight their row to
make them easier to spot. This is done by adding a #username
to all
the meet links on the lifter page, as well as a "pseudo" anchor link on
each entry of the meet page. The browser will natively jump down to the
specified anchor.
Unfortunately, the browser jumps so that the top of the page is the anchor link, which is underneath the header. Thus, we need some styling to move the anchor link half a viewport up from where it actually is. This allows the browser to put it at the top, but the actual row to be in the middle of the page.
We also need to do some trickery to get the row highlighted. rocket
's
implementation of URIs doesn't expose the #fragment
component like the
normal http
crate does, so we can't grab it from the actual URI.
However, when clicking from the lifter page to the meet page, the
referer
(intentionally misspelled) is set. We can grab this and
extract the fragment ourselves before passing it down into the template
file. This unfortunately means it won't work if someone links to the
page (i.e. the lifter won't be highlighted) but this is probably a good
starting point.
Finally, the highlight needs to be different for both OpenPowerlifting and OpenIPF (since one is dark and the other light), so we need a new SCSS variable to determine the highlight colour.
Desktop-only for now, since locally testing mobile changes doesn't seem to work for me at the moment, but will fix that in a follow-up if this idea seems reasonable.
This change:
- Adds anchor links to all the entries of a meet
- Adds some CSS and classes to highlight specific rows of a meet
- Adds a custom request extractor to get the referring path
- Passes the referring username into templates