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 Theme UI to material-ui transformer #164

Closed
jxnblk opened this issue Jul 5, 2019 · 11 comments
Closed

Add Theme UI to material-ui transformer #164

jxnblk opened this issue Jul 5, 2019 · 11 comments
Labels
help wanted Extra attention is needed

Comments

@jxnblk
Copy link
Member

jxnblk commented Jul 5, 2019

The material-ui library has its own, similar theming API. It'd be great to support using these components within a theme-ui application

@jxnblk jxnblk added the help wanted Extra attention is needed label Jul 5, 2019
@lemes
Copy link
Contributor

lemes commented Jul 23, 2019

I want to help with that! I've been wanting a better style api for material-ui for so long and once I saw theme-ui I was like: This is it!

Where do I get started?

@jxnblk
Copy link
Member Author

jxnblk commented Jul 23, 2019

I think it'd be a matter of looking at the material-ui docs to understand the shape of what's needed for that library and creating a transformer function that takes a theme-ui theme object and outputs that format. The @theme-ui/typography or @theme-ui/tachyons packages are probably the closest thing currently in this repo, but this one could potentially integrate with their css-in-js/context setup as well. This could also benefit from #85 if that's at all interesting to work on

@adamsoffer
Copy link

Hey @jxnblk - until something like this gets built, I'm curious, how would you personally go about using material-ui components inside a project that uses styled-system or theme-ui? Or would you just recommend using Material's system package for now?

@jxnblk
Copy link
Member Author

jxnblk commented Jul 26, 2019

@adamsoffer I haven't used Material UI myself, so I'm not sure. I believe they use JSS (which I also haven't used), but I suspect it should be compatible with Styled System

@lemes
Copy link
Contributor

lemes commented Jul 29, 2019

@adamsoffer if I understood correctly, one would still use Material-UI as it is but when wanting to update the theme, do it through theme-ui. The utility would parse the theme-ui object into Material-UI theme object.

@adamsoffer
Copy link

Thanks @lemes. What I'm doing for now is using theme-ui for everything and anywhere I need to use a material component I just manually get specific theme variables from theme-ui's context and pass it to the material-ui theme. Basically, I'm doing this for now:


export default () => {
  const context = useThemeUI()

  // Apply theme-ui settings to material-ui component
  const muiTheme = createMuiTheme({
    palette: {
      primary: {
        main: context.theme.colors.background
      },
      secondary: {
        main: context.theme.colors.grey[3]
      },
      ...
    }
  })

  return (
    <div>
      <MuiThemeProvider theme={muiTheme}>
        <MaterialTable />
      </MuiThemeProvider>
    </div>
  )
}

@jxnblk
Copy link
Member Author

jxnblk commented Jul 29, 2019

Yeah, ideally there would be a utility/component to use Material UI components within a Theme UI application, where the theme object is defined once in the standard format and used in multiple places. This should negate the need to manually map from one object to the other

An API for this could look something like this:

import React from 'react'
import { ThemeProvider } from 'theme-ui'
import { MaterialUIProvider } from '@theme-ui/material-ui'
import theme from './theme'

export default props =>
  <ThemeProvider theme={theme}>
    <MaterialUIProvider>
      {props.children}
    </MaterialUIProvider>
  </ThemeProvider>

@adamsoffer
Copy link

Nice. Yeah, that would be sweet.

@adamsoffer
Copy link

@lemes - did you by any chance take a stab at this?

@lemes
Copy link
Contributor

lemes commented Aug 30, 2019

@adamsoffer I didn't 😞but please do fell free to try it.

@jxnblk
Copy link
Member Author

jxnblk commented Jan 2, 2020

Closing this out since there hasn't been much traction here -- feel free to open a new issue or PR if anyone wants to look into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants