-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[Master feature] Make stories respect responsive units#15955
Comments
One issue that this has is that it will not work for selectors that select elements that are ancestors of the One way around this is to include the original style and an inverted variant of the selector. For example, the selector |
This option also breaks, because we'd need to have a deeper understanding of the hierarchy of the document. For example Another option is to do nothing beyond the original proposal and require publishers to write their style in a way that is compatible (i.e. always specify styles on |
Would you consider amp-specific directives. For example, you have |
After today's design review (#15347), the feedback is to continue with the approach of dynamically rewriting the @jaygray0919, I don't think we would want to go the route of rolling a new component for each HTML element, but rather (where possible) we'd like to make existing HTML components work as well as possible in our system. As such, we want to respect existing responsive design techniques, as well as enabling reasonable defaults (like making the font-size responsive by default). |
This is a high priority issue but it hasn't been updated in awhile. @newmuis Do you have any updates? |
|
This is a high priority issue but it hasn't been updated in awhile. @newmuis Do you have any updates? |
2 similar comments
This is a high priority issue but it hasn't been updated in awhile. @newmuis Do you have any updates? |
This is a high priority issue but it hasn't been updated in awhile. @newmuis Do you have any updates? |
This experiment has launched, but there is a bug causing it to not be surfaced (the custom styles are placed on the |
Thanks for update. We have several stories pending the implementation of this feature so will be ready to test when you signal the next release. We also experience problems with some SVGs and will test those conditions in next release. |
@jaygray0919 sounds good. Please feel free to file a separate issue for the SVG questions you may have. |
This is a high priority issue but it hasn't been updated in awhile. @newmuis Do you have any updates? |
1 similar comment
This is a high priority issue but it hasn't been updated in awhile. @newmuis Do you have any updates? |
The fact that the amp-story desktop UI shows up to three
amp-story-page
elements in view at once can be problematic for designing responsively, because the size of the amp-story-page differs from the size of the viewport, so common responsive practices that are based on the viewport dimensions won't work (e.g. media queries, and the viewport unitsvw
/vh
/vmin
/vmax
).We can resolve this by rewriting these styles at runtime to refer to the size of the
amp-story-page
rather than the viewport, but this becomes problematic once there are multiple possibleamp-story
elements in the document (as will be possible if/when thestandalone
attribute becomes optional). As such, it becomes important to have scoping for a story's styles, so that we can determine which sizing to use for a given selector.Proposal
Design
tl;dr: The design is to achieve style isolation by having publishers create
<style>
tags that are scoped to the<amp-story>
that they affect and enforcing the isolation by using JavaScript to modify the selectors at runtime.Validation changes
standalone
attribute is missing onamp-story
,id
is requiredRuntime changes
amp-story
buildCallback
:amp-story-page
, per the page initialization section<style>
tag that matches this story'sid
, per the style modifications sectionstandalone
id
likei-amphtml-story-id-ad-1
) to eachamp-story-page
, per the page initialization section<style amp-custom>
tag from the ad fetch per the style modifications sectionPage initialization
.i-amphtml-story-id-${id}
. For example, given the following<amp-story>
tag:We would transform this to:
Style modifications
Preface each selector with one that matches the class format specified in the page initialization section above (
.i-amphtml-story-id-${id}
).For example, given the following
<style>
tag:We would transform this to:
vw
/vh
/vmin
/vmax
with thepx
values based on the size of theamp-story-page
elementamp-story-page
element instead of the viewportExamples
Example 1
Publisher-authored DOM:
DOM after
amp-story
build:Notes:
Because of the presence of the
standalone
attribute on theamp-story
tag, allamp-custom
styles for this document are assumed to be for the story present in the document. Because theid
was absent in the publisher DOM, it is auto-generated. Theid
is applied to both the story and the styles.Result:
p#hello-world
will have a red background.Example 2
Publisher-authored DOM:
DOM after
amp-story
build:Notes:
Because there is no
standalone
attribute on theamp-story
tag, anid
is specified on each of the stories. An accompanying<style>
tag is found and these styles will be used for each story respectively.Result:
p#intro
will have a green background.p#hello-world
will have an orange background.p#middle
will have a green background.p#goodbye-world
will have a blue background.Alternatives considered
Wrapping the contents of each amp-story-page in an iframe
Pros
Cons
amp-custom
styles,amp-runtime
styles, andamp-extension="*"
styles into every frameamp-story
extension to block the initialization of other AMP extensions, which goes against AMP principlesPotentially very expensive and unlikely to work on lower-end devices
Wrapping the contents of each amp-story-page in a shadow root
Pros
Cons
amp-story h1
), since the styles would need to be rewritten with an understanding of which parts of the selector refer to things in the host context and which parts of the selector refer to things in the shadow DOMamp-custom
styles,amp-runtime
styles, andamp-extension="*"
styles into every frameDynamically insert/remove
<style>
tags, keeping only one activePros
Cons
amp-story-page
level; if there are two content pages visible and one ad page visible, which style tag gets inserted?The text was updated successfully, but these errors were encountered: