amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

How to set/change CSS properties from amp-list response

Open vamshi5889 opened this issue 8 years ago • 4 comments

Good day All,

Currently I'm working on creating a Product Listing Page (E-Commerce) with AMP.

As part of this i have a requirement of showing variant options of each product as shown in the picture below (color boxes), image

I'm getting the color codes (Ex. #0000FF for blue) in the response. But i don't know how to set that color code as background-color to that boxes because, AMP doesn't support inline styles.

Is there a way to achieve this? Let me know if you need more clarification on the problem i'm facing.

Any help would be really appreciated. @choumx

Thanks, Vamshi

vamshi5889 avatar Mar 15 '18 13:03 vamshi5889

I also tried to use SVG's but amp-mustache is blocking SVGs and below is the thread tracked for that. https://github.com/ampproject/amphtml/issues/1156

vamshi5889 avatar Mar 15 '18 13:03 vamshi5889

@vamshi5889 Supporting inline-style is in the works by @alabiaga as we speak. See https://github.com/ampproject/amphtml/issues/11881 for details.

Until that feature lands, only work-around I can think of is enumerating all possible color values you could have in CSS (if HEX is truly arbitrary then you are out of luck) and setting the class in amp-list

aghassemi avatar Mar 15 '18 21:03 aghassemi

Closing this issue as dup of #11881.

aghassemi avatar Mar 15 '18 21:03 aghassemi

@aghassemi I got the work-around you are talking about and will be waiting for the inline feature.

Thanks for the quick response

vamshi5889 avatar Mar 16 '18 05:03 vamshi5889