Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scale sideMenu labels according to computed font size #1356

Merged
merged 2 commits into from
Aug 20, 2020
Merged

fix: scale sideMenu labels according to computed font size #1356

merged 2 commits into from
Aug 20, 2020

Conversation

wopian
Copy link
Contributor

@wopian wopian commented Aug 19, 2020

Closes #1180.

See #1180 (comment) for the width change.

See #1180 (comment) for the font-family change.


Setting units in px and (r)em uses the CSS-defined font-size units (in this case 7px) and not the computed font-size, which means the label size does not scale with the increased minimum font sizes users can set in their browser's settings. Minimum font size is a setting in pretty much every browser on Windows, Linux and MacOS and is likely set to None by default (hence why it was not reproducable in #1180)

If a user sets the minimum font size above 7px (for example 10px) then the label width (a static 32px) becomes too short for the text width.

The ex unit is supported by Chrome 1+, Edge 12+, Firefox 1+, IE 4+ and Safari 1+.

Description 32px 9ex
7px font size and no minimum font size (7px computed) image image
7px font size and a minimum font size of 10px (10px computed) image image
7px font size and a mimimum font size of 10px (4K display, 7px computed) image image

If `Verdana` isn't present, the system/browser default serif font would be used instead. Fixes #1180 (comment)
@@ -16,7 +16,7 @@ export const OperationBadge = styled.span.attrs((props: { type: string }) => ({
background-repeat: no-repeat;
background-position: 6px 4px;
font-size: 7px;
font-family: Verdana; // web-safe
font-family: Verdana, sans-serif; // web-safe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is important!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what it looks like for me without it:

image

@RomanHotsiy RomanHotsiy merged commit fed9a06 into Redocly:master Aug 20, 2020
@RomanHotsiy
Copy link
Member

This is awesome @wopian 👏

Thanks for the detailed explanation!

@wopian
Copy link
Contributor Author

wopian commented Aug 20, 2020

Thank you 😀

@wopian wopian deleted the patch-1 branch August 20, 2020 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Side-menu : operation-type label width too short when display "PATCH" in Chrome.
3 participants