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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an API to update the theme from down the tree #21273

Open
1 task done
devskope opened this issue May 31, 2020 · 2 comments
Open
1 task done

Provide an API to update the theme from down the tree #21273

devskope opened this issue May 31, 2020 · 2 comments
Labels
new feature New feature or request waiting for 馃憤 Waiting for upvotes

Comments

@devskope
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 馃挕

It makes sense to me to abstract the theme generation APIs into a single hook interface that returns the generated theme and a setter function to modify the theme.

Examples 馃寛

I published the useMuiTheme hook (@devskope/use-mui-theme) to solve this problem.

import useMuiTheme from '@devskope/use-mui-theme';
  ...
 
const App = (props) => {
  const [theme, setTheme] = useMuiTheme({
       themeOptions = {name: 'winter-blue', palette:{ ...paletteOpts }},
       themeArgs = [],
       responsiveFonts = true,
       fontOptions = {factor: 1},
     });
 
  return (
    <>
      <ThemeProvider theme={theme}>
        <CssBaseline />
        <NavBar setTheme={setTheme} />
      </ThemeProvider>
    </>
  );
};
@oliviertassinari
Copy link
Member

@devskope Thanks for opening an issue. It's the third time I see somebody asking for a theme setter. From what I recall, it was about enabling the dark theme without having to handle the boilerplate around the React's context. What problem do you intend on solving?

@devskope
Copy link
Author

devskope commented May 31, 2020

@oliviertassinari Same problem, cutting down boilerplate and focusing on features .

@oliviertassinari oliviertassinari changed the title Aggregate theme creation functions, bake in dynamic theme updates. Provide an API to update the theme from down the tree May 31, 2020
@oliviertassinari oliviertassinari added new feature New feature or request waiting for 馃憤 Waiting for upvotes labels May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request waiting for 馃憤 Waiting for upvotes
Projects
None yet
Development

No branches or pull requests

2 participants