Closed marcmrf closed 3 years ago
Would it be possible to place the style tags in the root element of the script? You should be able to place style tags anywhere in the DOM and have them work. I don't think simply placing stuff in <head>
will always work (e.g. for Shadow DOM) so I think having a way of specifying where to put the style tags would make sense outside of the <amp-script>
use case.
/cc @kristoferbaxter
inlining the styles in the elements, which is not amp-valid
Inline styles via style
attribute are valid as of sometime last year. :)
Unfortunately, dynamically rendering <style>
tags won't be allowed without style encapsulation e.g. via shadow DOM.
Hi, I am also trying to use styled-compoents
and is fetching data from an JSON endpoint.
My goal for
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
Describe the new feature or change to an existing feature you'd like to see
As amp docs says, amp-script opens the door to create custom ui components using frameworks like react or vuejs. Most of the styling options for these frameworks cannot work with amp-scripts, as they create style tags in the head like styled-components, which is not implemented in worker-dom https://github.com/ampproject/worker-dom/blob/master/web_compat_table.md, or inlining the styles in the elements, which is not amp-valid. Can document.head be implemented in worker dom, proxying the styles are attached to it for being transfered to the original document.head?
Describe alternatives you've considered
<style amp-custom>
. This means to define the css outside the react component, like a normal css file, or using a normal css import in js withcss-loader
andMiniCssExtractPlugin
, adding the whole css of the component, no matter if it's used or not at the initial state. This forces to maintain two different styling architectures, one of them far from the current state of the art for styling in react, depending if it's amp or not and goes against purely standalone components.