-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow for multiple theme files #5
Comments
ah, that might not be as easy :) babel plugins are processing one file at a time. let me think about it? |
...still nothing comes to mind :) It might have to be a limitation of the plugin to require themes to be in a single file. Are your themes too large if consolidated into a single file? |
Very much haha!
Now the goal is to create a preset with the first (big) theme, then extend and overwrite parts of it. In this case, it could all be contained in a single file. The doc also mentions the advantage of splitting the code.
I'll think about possible solutions!This is what my theme currently looks like: |
got it - its BIG :) |
My repo is private, but I can create a fixture for sure. I should be sending that over by tomorrow 👌 |
@fcisio - my best guess so far would be to use a webpack source loader that will merge all theme imports into a single theme file at build-time. Haven't found a ready-made webpack loader that does this. If none is found, we can go ahead and make our own. |
Oh damn... Could we actually import the file to resolve the value of the theme? |
@hasparus - don't think so - as there might be values that need instrumenting in the imported file (a variation of theme composition : https://github.com/atanasster/babel-plugin-theme-ui#theme-composition) example:
theme.js
|
But if we imported Right now you're transforming one expression to another, and my idea is
I may be missing some context, though. |
ah maybe, let me try :
|
Can't this be done in a babel plugin or macro? |
I'll try to test my idea this weekend. |
Great, looking forward to your results. I dont see how to do it in a babel plugin, and havent used babel macros. |
Hey, just had an idea! Now I think we should still prioritize alternatives, but essentially... We could transform all the theme scales into variables printed on the body (same as colors currently are). Using the same pattern as colors, this would mean:
|
@fcisio - thats a good idea, however it will have a big impact (including we will have to separate the spaces into their own key of the theme or some other mean of identifying the spaces). Also it doest really solve the general problem of modifying 'sub-files'. But we can put it to voting from the community. I am still on the webpack source loader bandwagon (mostly because it would not rely on internal changes to the library itself), if @hasparus idea test doesnt work out. |
I started work on a babel macro last week which explores others ideas in addition to those in this thread. https://github.com/deckchairlabs/theme-ui.macro |
I've started to implement the plugin in one of my projects and I was able to notice this.
Everything works, as long as the theme is contained in a single file.
theme.js/ts
In many cases, the theme will get pretty big and will need to be split-up. For example:
The text was updated successfully, but these errors were encountered: