question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Guide request for breaking longer theme files into separate components

See original GitHub issue

Hello!

Amazing to see the docs expand and all the content you have created for this since it launched! Thank-you for the hard work on this - it makes using theme-ui so much better. As my theme-ui index.js file gets longer and more complicated with variants and styles I have tried a few times to split it into separate files using deepmerge. I keep hitting errors when I do this and just revert back to my big index.js file as this works fine for me with no problems. My hope in breaking it into smaller pieces is to make it easier to shadow in gatsby themes and also just to make it simpler for editing/management going forward…ignore the fact that I haven’t setup typography.js yet, I really should be using that instead of a bunch of fontSizes, fontWeights, etc.

My index.js file when broken down looks something like this:

import merge from "deepmerge"
import colors from "./colors"
import fonts from "./fonts"
import fontSizes from "./fontSizes"
import fontWeights from "./fontWeights"
import lineHeights from "./lineHeights"
import spaces from "./spaces"
import sizes from "./sizes"
import breakpoints from "./breakpoints"
import styles from "./styles"
import variants from "./variants"

export default merge(
  colors,
  fonts,
  fontSizes,
  fontWeights,
  lineHeights,
  spaces,
  sizes,
  breakpoints,
  styles,
  variants
)

This seems to work with deepmerge but then the following code, which was working fine before with one big index.js starts failing…using the sx={{}} object.

gridTemplateRows: [
          theme => theme.sizes.headerHeight,
          theme => theme.sizes.headerHeightTablet,
          theme => theme.sizes.headerHeightLaptop,
        ],

It no longer seems to be able to reader those values which is odd to me. I am sure there is a reasonably easy way to do this and I imagine other gatsby theme others are thinking similar things as their variants usage starts to expand and grow leading to big index.js files.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cobrazcommented, Jul 25, 2020

Should I add a PR for it?

1reaction
ehoweycommented, Sep 17, 2019

Thanks - I was looking at gatsby-theme-blog and they were using deepmerge so I assumed I needed that as well. The work on this is amazing keep it up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Customize Your WordPress Theme (5 Step-by ... - Kinsta
Need to change the look of your WordPress theme? Learn how to customize WordPress themes properly using one of the best methods (tutorial)....
Read more >
How to Update WordPress Theme without Losing Customization
You'll need to copy any changes you have made to those files, and paste them at the bottom of your child theme's files....
Read more >
How to Change WordPress Theme in 2022 (The Best Way)
Once the theme is installed go to Appearance → Themes → Select the Live Preview in the new theme.
Read more >
Breaking changes in v5, part one: styles and themes - MUI
This is a reference guide to all of the breaking changes introduced in Material v5, and how to handle them when migrating from...
Read more >
Migrating to Material Components for Android
This guide uses a simplified app to demonstrate the migration process. It uses an AppCompat theme, widgets from the Design Support Library ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found