nightwind
nightwind copied to clipboard
Enhance init() to allow a similar style to overreacted.io
I'm enhancing theinit()
method from the helper, to copy a similar style of what is done in the overreacted.io style. By adding
-
window.__theme
to track current theme -
window.__onThemeChange
to allow a component to track whenever the dark mode gets toggled.
Simplified version of overreacted.io Layout.js
class Layout extends React.Component {
state = {
theme: null,
};
componentDidMount() {
this.setState({ theme: window.__theme });
window.__onThemeChange = () => {
this.setState({ theme: window.__theme });
};
}
}
This should be a non-breaking change, and backwards compatible
Sweet, thanks for the PR @osukaa! At a first glance it seems fine to me, will give it a try later today and if all goes well I'll include it in v1.1.13.
In the meantime, it would be great if you could also update the Helper readme section to briefly describe these additional features.
I've added the documentation as an example!
@jjranalli any updates around this PR?