Skip to content
Advertisement

How do I implement Coloris npm package as a custom element?

I have been trying to implement an NPM called Coloris, to provide end-user color customization capability to a Wix website through a web component. From what I can see, the javascript isn’t working/executing. I’ve tried a few solutions for getting javascript to work in innerHTML, but they haven’t worked so far. This issue has stumped me for a week and I still can’t get the Coloris color picker to show/render. I can get as an HTML/IFrame embed, but need to make it work as a custom component

Below is the code for the web component. Any help/solutions would be greatly appreaciated

JavaScript

Advertisement

Answer

I tested it, ColorIs does not work on DOM Elements inside shadowDOM

Your code can be made easier; to inject the <script> and <link> in the document.head

Note: ColorIs does not work properly in this SO snippet either;
here is a JSFiddle: https://jsfiddle.net/WebComponents/5j7h3ygw/

JavaScript
Advertisement