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

Add Support for ThemeProvider in other components #13

Open
hzy opened this issue Feb 13, 2018 · 2 comments
Open

Add Support for ThemeProvider in other components #13

hzy opened this issue Feb 13, 2018 · 2 comments

Comments

@hzy
Copy link
Member

hzy commented Feb 13, 2018

Problem

The ThemeProvider component is basic implemented, now we need add support in other components to make it works.

Suggestion

Just do as it referenced in react offical document, receive context from higher level components.
User may not want to use ThemeProvider, we need to default it.
Below is a example:

const GrandSonComponent = (props, context) => {
  const { startColor = 'red', endColor = 'green' } = context
  return (
    <div
      style={{
        width: '100px',
        height: '100px',
        backgroundImage: `linear-gradient(90deg, ${startColor} 0%, ${endColor} 100%)`,
      }}
    >
      Foo
    </div>
  )
}
GrandSonComponent.contextTypes = {
  endColor: PropTypes.string,
  startColor: PropTypes.string,
}

Implement

If this issue is approved, I suggest the owner of each component do this job for their components.

@MMMartt
Copy link
Collaborator

MMMartt commented Feb 15, 2018

I think we should set a default theme at somewhere like defaultTheme.js and import it when needed. Should I write one? @farawaaay

@hzy
Copy link
Member Author

hzy commented Feb 15, 2018

@MartinNey Good idea. I also have a idea that we define interface Theme and its factory with colors, fonts, and other theme factor as parameters.

So we now really provide themes rather than colors.

<ThemeProvider theme={themeFactory(... colors, ...others)}>
  ...
</ThemeProvider>

Or default,

<ThemeProvider theme={defaultTheme}>
  ...
</ThemeProvider>

As you can see, we can import defaultTheme from defaultTheme.js

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

No branches or pull requests

6 participants