gatsby-theme-material-ui icon indicating copy to clipboard operation
gatsby-theme-material-ui copied to clipboard

[Feature] Can we add an option to customize the theme path root directory?

Open bneigher opened this issue 5 years ago • 9 comments
trafficstars

Cool library. Took a while to figure out how to set it all up, but it works nicely.

One usability / code structure OCD complaint I have is that we NEED to have the src/gatsby-theme-material-ui-top-layout/... block in our codebase. It would be really nice to be able to change this path to a custom one.. like src/styles/...

A. Is this possible today? If so perhaps adding it to the docs would help. B. If not, any reason why this is not implemented? Would love to change this.

bneigher avatar May 14 '20 04:05 bneigher

Took a while to figure out how to set it all up, but it works nicely.

@bneigher Is there anything we could improve from the official example?

oliviertassinari avatar May 14 '20 22:05 oliviertassinari

@oliviertassinari the need to have a gatsby-theme-material-ui-top-layout folder in src is a bit of annoying. It would be so much user-friendlier if we could set the path like

{
  resolve: 'gatsby-theme-material-ui',
  options: {
    themePath: require.resolve('./src/theme.js')
  }
}

p.s. Absolutely love everything else about the lib

dannymatkovsky avatar May 31 '20 06:05 dannymatkovsky

But correct me if I am wrong but you dont have to use the top-layout. If you look at the code in there you see that it just uses some basic material-ui stuff that you can add to your own code like this:

import { CssBaseline, Container } from '@material-ui/core';
import { ThemeProvider } from '@material-ui/core/styles';
import theme from '../../theme';

const Layout = (props) => {
...

  return (
    <ThemeProvider theme={theme}>
      <CssBaseline />
      <Container>
        {children}
      </Container>
    </ThemeProvider>
  );
};

rejas avatar Jun 01 '20 14:06 rejas

@rejas How do you make sure to wrap the client and server React tree?

oliviertassinari avatar Jun 01 '20 14:06 oliviertassinari

to be honest: i dont know (or what you mean exactly). you can see my page code at https://github.com/rejas/veeck.de if you want to take a look yourself

rejas avatar Jun 01 '20 14:06 rejas

Ok, it works because of https://github.com/rejas/veeck.de/blob/9313878c70b289dd11446460cb0044e06db2dfad/gatsby-config.js#L74

oliviertassinari avatar Jun 01 '20 15:06 oliviertassinari

I hope that it a correct way of doing it? I am not very familiar with the whole SSR thing (as can be read here: https://twitter.com/hansalbern/status/1252477133743628288)

rejas avatar Jun 01 '20 15:06 rejas

Ok, it works because of https://github.com/rejas/veeck.de/blob/9313878c70b289dd11446460cb0044e06db2dfad/gatsby-config.js#L74

What does that line do exactly?

kleenkanteen avatar Jul 04 '21 07:07 kleenkanteen

I also think it would be a nice addition to customize the path

When you open src and start seeing things like that :

image

Glorious

adelin-b avatar Dec 08 '21 01:12 adelin-b