bento: customize jss insertion point to support shadow#29794
Closed
samouri wants to merge 3 commits intoampproject:masterfrom
Closed
bento: customize jss insertion point to support shadow#29794samouri wants to merge 3 commits intoampproject:masterfrom
samouri wants to merge 3 commits intoampproject:masterfrom
Conversation
Member
Author
|
Not going forward with this approach. Doing a hybrid (compile away for amp/bento, use react-jss proper for preact mode) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
There are many tradeoffs to weigh when thinking about how to use jss/react-jss with preact-based amp components.
This PR gets us out of a weird half done stage using the naive approach, although I personally think the "compiled" approach makes more sense long term and I'd like to discuss that.
Naive method: using libraries as-is
The most naive way of using the two libraries means using them at runtime. For lightdom, the default location of
document.headas the insertion point for the<style>tag is fine, but for shadow dom (amp mode) we have to specify our owninsertionPoint. TheuseStyleshook inreact-jsswill grab the nearest jss instance in Context, so we can pretty easily customize insertion point.Pros:
jssinstances to customize the outputted cssCons:
Compiled
We use the JSS format and library only at compile time in order to create standard css files.
We then ship each preact component with a separate css file. This would be trivial to include in amp mode, as well as for consumers of individual bento amp components.
Within the ecosystem, it is also relatively common for components to ship css files that must be manually included, for example the popular date picker library, react-dates that we already use in AMP.
Pros:
Cons: