frenic / csstype

Strict TypeScript and Flow types for style based on MDN data
MIT License
1.73k stars 72 forks source link

Include a better usage example in the README.md #115

Closed arnfaldur closed 3 years ago

arnfaldur commented 3 years ago

I want to use this package in my JS project but I see no obvious way to use a CSS.Properties object. I will probably figure it out eventually but a minimal example of attaching style to an element (or another typical use-case) would be very helpful for beginners like me.

arnfaldur commented 3 years ago

I figured out a way to do this:

let element = document.createElement("button");
const style: CSS.Properties = {
    color: "red",
    margin: "1em",
};
Object.assign(element.style, style);

My issue is resolved and I created a pull request fixing it. I understand if this goes beyond the scope of this project so feel free to close both the issue and the pull request at your discretion.