Giter Site home page Giter Site logo

Docz cannot "find" custom theme about docz HOT 10 CLOSED

doczjs avatar doczjs commented on April 29, 2024
Docz cannot "find" custom theme

from docz.

Comments (10)

Swapnull avatar Swapnull commented on April 29, 2024

@mrmartineau Should it not have a trailing / as it is a folder? Like this

export default {
  theme: '../../src/docz-theme-fx/',
}

That works for me when I point to a custom theme that contains an index.js :)


I think that will only work if the entry point is index.js though, not sure if you will have to actually supply the index name if its a typescript file? Like -

export default {
  theme: '../../src/docz-theme-fx/index.tsx',
}

from docz.

mrmartineau avatar mrmartineau commented on April 29, 2024

@Swapnull thanks for your help, but I still cannot get this to work. Neither adding a trailing slash, or the path to the full file works. Should the copy I created need compiling for it to work?

from docz.

Swapnull avatar Swapnull commented on April 29, 2024

Hey, Here is what I am doing - https://github.com/Swapnull/docz-test and that seems to work.
That was just a copy from the base version and then taking it out of typescript for ease :)

Not sure it needs compiling first? Hope that helps :)

from docz.

mrmartineau avatar mrmartineau commented on April 29, 2024

@Swapnull thanks again, but I tried using your version too and it still didn't work. Can you tell me if there's anything else that I should do beyond having the theme within my project and setting the correct path in the config?

from docz.

pedronauck avatar pedronauck commented on April 29, 2024

Hi @mrmartineau, as you can see in the Theming section on Project configuration, theme filepath need to be relative to your src folder or the root folder of your project...

This is defined in webpack on resolve.modules configuration:
https://github.com/pedronauck/docz/blob/master/packages/docz-core/src/bundlers/webpack/config.ts#L141-L143

So, if you pass a filepath on theme, webpack will search this file on root, src, or node_modules, but just project files will be parsed by loader, node_modules will be rejected!

from docz.

mrmartineau avatar mrmartineau commented on April 29, 2024

Hi @pedronauck, I still cannot get this to work... when you mention src above, the docs say to use source instead, is that what you're referring to?

My config is as follows:

export default {
  theme: 'src/docz-theme-fx',
  source: './',
}

That config should work, right?

My project structure is as follows:

. (root)
 - src
   - components
   - docz-theme-fx (this is a copy of the default theme with a few changes)

The value in root.jsx is exactly the same as the value in the config, e.g.

import Theme from 'src/docz-theme-fx'

Can you show me an example of what the above line should look like with a custom theme?

from docz.

renatorib avatar renatorib commented on April 29, 2024

Hey @mrmartineau, can you provide a repo with minimal failing setup so I can take a look?

from docz.

Swapnull avatar Swapnull commented on April 29, 2024

@mrmartineau does it not need to be theme: 'src/docz-theme-fx/src/ ? I thought it had to point to the src file inside the theme, assuming you copied the basic theme?

from docz.

mrmartineau avatar mrmartineau commented on April 29, 2024

@Swapnull adding src to the path (like so: theme: 'src/docz-theme-fx/src) was what was needed. Thank you.

I used the non-Typescript version that you created (above) and it is now working, but I had to install recompose and lodash.merge to get it to work fully.

The shame of it is, is that I wanted to update the <Playground> component to have a themeable (or at the very least, a dark background), which I edited, but I realise that while the styles can be modified, no new props can be added to a theme without them being in docz core. @pedronauck am I correct in that assumption? If so, I will look at submitting a PR for it to go into core rather than my theme.

Thanks for your help guys

from docz.

pedronauck avatar pedronauck commented on April 29, 2024

You can path your own render component like here @mrmartineau
https://github.com/pedronauck/docz/blob/master/packages/docz-theme-default/src/index.tsx#L19

from docz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.