NixOS / nixos-homepage

Sources for nixos.org
https://nixos.org
286 stars 305 forks source link

Make asciinema responsive with fit: width #1376

Closed albertchae closed 3 months ago

albertchae commented 3 months ago

Fixes https://github.com/NixOS/nixos-homepage/issues/1323

Let asciinema handle responsive design by setting fit: 'width'

https://docs.asciinema.org/manual/player/options/#fit

This is the default option but it is currently false.

It seems like we need to make a tradeoff between fitting all the text in or having a larger font. I'm betting on showing all the content being the more important of the two and that we can have terminal replays with fewer columns if we really want larger font. And it's easier to rely on asciinema's player to be responsive than to adjust font size manually ourselves.

After

So although there's a big improvement in being able to see the entire width of the terminal, for the top example there is still some bleeding of the terminal text into the border. This looks like it is only happening on Safari/webkit both on mobile and desktop. Chrome/Firefox look OK on mobile and desktop.

I opened https://github.com/asciinema/asciinema-player/issues/258 to double check if I'm doing something wrong and/or if there is a workaround

github-actions[bot] commented 3 months ago

🚀 Deployed on https://6609064bbd201684d378b549--nixos-homepage.netlify.app

ku1ik commented 3 months ago

max-width: 100% alone won't work with fit: 'width' as the player needs to know the actual/current width for the scaling of its terminal view to work. So switching to width: ... is indeed the right thing to do here :+1: