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

[gatsby-plugin-theme-ui] How do you properly merge conflicting theme tokens? #184

Closed
daydream05 opened this issue Jul 16, 2019 · 2 comments

Comments

@daydream05
Copy link

Description

I made a gatsby theme that uses the base theme presets and extends it a bit. When used on a parent theme that used a totally different set of design tokens, it breaks.

import childTheme from ‘child-theme/src/gatsby-plugin-theme-ui’
import merge from ‘lodash.merge’

const baseTheme

export default merge({}, childTheme, baseTheme)

For example, my child theme has a fontSize array of 7 items and my base theme has only 6. With the method above, my child theme breaks if it uses the last index and turns it into pixel since it doesn’t exist any more.

How would i go about designing/merging it in a way that my theme becomes portable?

Thanks

@jxnblk
Copy link
Member

jxnblk commented Jul 16, 2019

Thanks! This is definitely an issue we're aware of, but don't have solid patterns around yet. I've posted this related RFC to the theme specification, which would mean that each array would have a fixed length: system-ui/theme-specification#5 – with something like this we could provide validation around which themes use array scales in the "blessed" way.

For now, I'd say try to keep your themes to a similar schema if you intend for them to be used together. There are also different array merging strategies you can leverage with libraries like deepmerge

@jxnblk
Copy link
Member

jxnblk commented Jan 2, 2020

Closing this since I don't think there are any clear actionable next steps here

@jxnblk jxnblk closed this as completed Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants