If I create a vanilla JS component like this:
class TestComponent {
constructor(el) {
this.render(el);
}
render(el) {
var html = `
<div>
<p>Some dummy content</p>
</div>
`;
document.getElementById(el).innerHTML = html;
}
}
Can I add CSS in JS for it? I mean something like:
const styles = {
backgroundColor: 'palevioletred',
color: 'papayawhip',
};
so the above render method will look like this:
render(el) {
var html = `
<div style={styles}>
<p>Some dummy content</p>
</div>
`;
document.getElementById(el).innerHTML = html;
}
is that possible to do outside of frameworks like Angular / React ?