-
Notifications
You must be signed in to change notification settings - Fork 54
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
Fixes https://github.com/primer/design/issues/141 #221
Conversation
Fixes [primer#141](primer/design#141) This styled component imported on pageload by React engine and applied to the images included with tutorials on [primer.style](https://primer.style/) The component includes directive `max-width: 100%`, which prevents images to stretch to their original full width thus avoiding possible `overflow-x` and forcing images to be responsive In general this trick should be enough to achieve the goal, 'cause if image property `height` in css is not declared explicitly, by default it respects the state of property `width` and scales accordingly itself. This behaviour is taken as usual and almost like an axiom, since for a long time all common browsers have been treating this situation in the same way But current actual builds of `Safari` *v14.x.x* (the latest one for this moment is *14.0.3 16610.4.3.1.4*) break this idyll - due to some bug in `Safari` css interpreter, with this browser `height` property on images doesn't rely on `width` as usual This miss like a snowball leads to serious abnormalities fon the whole page render - since `height` is not deriving the proper scale from `width`, the css interpreter inspects the project's css rules for explicit declaration for `height` (or does not inspect indeed; this is only my guess, since this step is mandatory according to `css specifications`), and since there's no matching rule declared, `Safari` applies to `height` the default (initial) value, which for `height` property means the original image height in pixels This results in total mess on pages which utilize large images to illustrate text content. Since directive `max-width: 100%` clearly and undoubtedly by `css specifications` prevents images to stretch in width over main content area, `width` is rendered according to the limits declared by layout. But at the same time `height` is scaled to the original image height The consequences are ugly and disgusting, 'cause every large illustration on the page gets dreadfully stretched, and the page looks totally broken In upcoming `Safari` *14.2* this bug is already fixed and now for this moment it renders the same pages on [primer.style](https://primer.style/) correctly (this beta is available for download at [developer.apple.com](https://developer.apple.com/safari/technology-preview/) as `Safari Technology Preview` Release 120 / v14.2, WebKit 16612.1.2.6) The update in this commit overrides the destructive behaviour of actual builds of `Safari`, forcing image `height` property to follow `width` by explicit declaration of `height` value as `100%`.The value declared thru directive `height: 100%` is relative, so the css interpreter is forced to utilize the exact relative value for final calculations. And since `100%` for `width` property de facto is always bound by `max-width: 100%` to the limits of content area layout, `height` scales accordingly and the goal is achieved Inequality with existing and applied directive (`height` vs `max-width`) is affected by concept of web design per se. The width of pages has always been limited by the screen width, so `max-width` directive is reasonable and acceptable, while the scrollable concept of web pages turns the height attribute into the abstraction. In common cases this always leads `max-height: 100%` directive to be equal to original (full) height of an object and thus makes it useless
|
This pull request is being automatically deployed with Vercel (learn more). gatsby-theme-primer-example – ./🔍 Inspect: https://vercel.com/primer/gatsby-theme-primer-example/9rXRpyKjmHvfhVPP4SLvndHgpuvU doctocat – ./🔍 Inspect: https://vercel.com/primer/doctocat/5SiZaSrbJ6W1wg4uHN8jqCFP8grS |
the rule
|
I'm new to The case seems to be a bit complicated For this moment there're three @primer repos plus one website involved in this pull: @primer/doctocat, @primer/design, @primer/css and https://primer.style
Due to the above I find it difficult to provide the requested |
@juliyvchirkov Thank you for all your hard work on this! ❤️ I'll try to get around to reviewing this next week. |
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
Fixes #141
This styled component imported on pageload by React engine and applied to the images included with tutorials on primer.style
The component includes directive
max-width: 100%
, which prevents images to stretch to their original full width thus avoiding possibleoverflow-x
and forcing images to be responsiveIn general this trick should be enough to achieve the goal, 'cause if image property
height
in css is not declared explicitly, by default it respects the state of propertywidth
and scales accordingly itself. This behaviour is taken as usual and almost like an axiom, since for a long time all common browsers have been treating this situation in the same wayBut current actual builds of
Safari
v14.x.x (the latest one for this moment is 14.0.3 16610.4.3.1.4) break this idyll - due to some bug inSafari
css interpreter, with this browserheight
property on images doesn't rely onwidth
as usualThis miss like a snowball leads to serious abnormalities for the whole page render - since
height
is not deriving the proper scale fromwidth
, the css interpreter inspects the project's css rules for explicit declaration forheight
(or does not inspect indeed; this is only my guess, since this step is mandatory according tocss specifications
), and since there's no matching rule declared,Safari
applies toheight
the default (initial) value, which forheight
property means the original image height in pixelsThis results in total mess on pages which utilize large images to illustrate text content. Since directive
max-width: 100%
clearly and undoubtedly bycss specifications
prevents images to stretch in width over main content area,width
is rendered according to the limits declared by layout. But at the same timeheight
is scaled to the original image heightThe consequences are ugly and disgusting, 'cause every large illustration on the page gets dreadfully stretched, and the page looks totally broken
In upcoming
Safari
14.2 this bug is already fixed and now for this moment it renders the same pages on primer.style correctly (this beta is available for download at developer.apple.com asSafari Technology Preview
Release 120 / v14.2, WebKit 16612.1.2.6)The update in this commit overrides the destructive behaviour of actual builds of
Safari
, forcing imageheight
property to followwidth
by explicit declaration ofheight
value as100%
.The value declared thru directiveheight: 100%
is relative, so the css interpreter is forced to utilize the exact relative value for final calculations. And since100%
forwidth
property de facto is always bound bymax-width: 100%
to the limits of content area layout,height
scales accordingly and the goal is achievedInequality with existing and applied directive (
height
vsmax-width
) is affected by concept of web design per se. The width of pages has always been limited by the screen width, somax-width
directive is reasonable and acceptable, while the scrollable concept of web pages turns the height attribute into the abstraction. In common cases this always leadsmax-height: 100%
directive to be equal to original (full) height of an object and thus makes it useless