nightwind icon indicating copy to clipboard operation
nightwind copied to clipboard

Enhance init() to allow a similar style to overreacted.io

Open osukaa opened this issue 3 years ago • 3 comments

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

osukaa avatar Nov 15 '21 05:11 osukaa

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.

jjranalli avatar Nov 15 '21 13:11 jjranalli

I've added the documentation as an example!

osukaa avatar Nov 16 '21 04:11 osukaa

@jjranalli any updates around this PR?

osukaa avatar Jan 31 '22 00:01 osukaa