Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

osukaa
Copy link

@osukaa osukaa commented Nov 15, 2021

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

@jjranalli
Copy link
Owner

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.

@osukaa
Copy link
Author

osukaa commented Nov 16, 2021

I've added the documentation as an example!

@osukaa
Copy link
Author

osukaa commented Jan 31, 2022

@jjranalli any updates around this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants