error-message-index icon indicating copy to clipboard operation
error-message-index copied to clipboard

Code examples are sometimes too wide for their box

Open david-christiansen opened this issue 2 years ago • 7 comments

Right now, code examples that are too wide overflow the allowed space. This is especially a problem on mobile browsers.

Screenshots: Screenshot from 2022-10-20 18-58-01

Screenshot_20221020-185859_Firefox

david-christiansen avatar Oct 20 '22 17:10 david-christiansen

I'm happy to address this issue. I have received a lot of help from folks in the Haskell community and have been looking for a way to give something back. If you would like me to do so I can get back to you in a few days with my thoughts on changes?

klequis avatar Oct 29 '22 16:10 klequis

It would be great if you could do that! Thanks!

david-christiansen avatar Oct 29 '22 19:10 david-christiansen

It seems like most sites, including my own, use a horizontal scrollbar when a code example is too wide for the screen.

For the error message, which isn't in a table, the overflow can be corrected with

pre {
  overflow-x: auto;
}

However, this doen't work in a table (atleast I couldn't get it to do so or find a answer searching) and therefore doesn't work for the before and after examples.

Personally, I think the before and after should be horizontal (side-by-side) on screens that are wide enough but should switch to a vertical layout for for narrow screens / phones. To achieve this the examples need to be taken out of a table and flexbox is introduced to the CSS.

Please let me know if you want to stick with tables or try the flexbox approach.

I created a live demo to show this http://haskell-error-index.s3-website-us-west-2.amazonaws.com/, but that's an odd looking link from a stranger so here are screenshots.

Full-screen

full-screen

iPad portrait

ipad-portrait

Width of iPhone 11

but made taller

width-of-iphone11

Extra narrow

to force the before and after to overflow

extra-narrow

Screen capture from my Samsung S8 phone

samsung-s8-phone

klequis avatar Nov 02 '22 23:11 klequis

This looks great!

I don't see any reason not to do the flexbox approach, but I'm not an expert on modern CSS. It's important to me that the site remain easy to build, contribute to, and run, and that means that we don't require the installation of extra preprocessors or other tools not on Hackage. It's also important that we support a reasonable collection of web browsers, but MDN says that Flexbox has been basically supported everywhere since 2015, which seems fine to me.

Please send a PR :-)

david-christiansen avatar Nov 03 '22 06:11 david-christiansen

On your demo site, I see React errors in the JS console. I'd really like to avoid heavyweight JS like React on this site, and keep it as a collection of static HTML and CSS, with bits of JS thrown in for optional creature comforts. This is for the sake of minimizing the skills needed to contribute to and maintain the site. If we ask for both Haskell and React skills, then we're excluding a lot of potential contributors.

david-christiansen avatar Nov 03 '22 06:11 david-christiansen

The demo on S3 is fully static with no React. I gutted and hijacked the local web server and build process from a react project so I could get the demo together without having to learn Hakyll first.

klequis avatar Nov 03 '22 14:11 klequis

Ah, great! I'd hate for you to put in a ton of work and then end up not merging due to mismatching long-term tech priorities on the project.

david-christiansen avatar Nov 03 '22 15:11 david-christiansen