remix-run / react-router-website

The React Router website
https://reactrouter.com
MIT License
152 stars 35 forks source link

fix: code elements should at least be full parent width #64

Closed IAmYoungbossy closed 1 year ago

IAmYoungbossy commented 1 year ago

Description

This pull request resolves the issue of the code element not assuming the full width of its parent element (pre), thereby causing the highlighting span elements (children of the code element) not to span the entire length of the code they are highlighting.

The issue occurred because the code element is an inline property, which means it flows with surrounding text. However, by setting the display property to inline-block, we can change the display behavior of the element to behave like a block-level element, allowing us to set the width and height properties.

To ensure that the code element assumes the width of its parent container, we explicitly set the min-width property to 100%. This allows the code element to expand to the full available width of its parent element (pre), resorting to the code highlighter spanning the entire line of code where it is applied

I have included screenshots of before and after the fix on both desktop and mobile views below.

Screenshots

Before Fix: Desktop View

before-fix-desktop-view

After Fix: Desktop View

desktop-view

After Fix: Mobile View

mobile-view

Pull Request Reference

This pull request is based on issue from this pull request #33.