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

Doczrc themeConfig not applying heading styles as expected #1309

Closed
Yihwan opened this issue Dec 8, 2019 · 11 comments
Closed

Doczrc themeConfig not applying heading styles as expected #1309

Yihwan opened this issue Dec 8, 2019 · 11 comments
Labels
bug Something isn't working fixed Issue fixed and released pending-release Issue fixed but not published to npm yet stale v2

Comments

@Yihwan
Copy link

Yihwan commented Dec 8, 2019

I'm attempting to customize styles using the doczrc config, and I've found that heading styles aren't applied as expected.

For example:

export default {
  themeConfig: {
    fonts: { // this works
      body: 'serif',
      heading: 'serif',
    },
    styles: {
      h2: { // this does not work
        color: 'red',
        fontWeight: 400,
      }
    }
  }
}

Does anyone have ideas why? I've resorted to shadowing the Heading component to apply some default styles, but that doesn't seem sustainable long-term.

I was able to reproduce this issue on a fresh project and can upload/link to that if helpful.

@zhangguimei
Copy link

I have the same issue

@rakannimer rakannimer added bug Something isn't working v2 labels Dec 11, 2019
rakannimer added a commit that referenced this issue Dec 11, 2019
Replaces MDXProvider with ThemeProvider

Allows customization of all mdx components from themeConfig

#1309

https://theme-ui.com/mdx-components
https://theme-ui.com/theme-spec
@rakannimer
Copy link
Contributor

rakannimer commented Dec 11, 2019

Hey !

Thanks for reporting this issue and providing an easy way to reproduce it.

There was indeed an issue with theming mdx components.
Fixed by 3a9bdb7.

The new version is released on the next tag under 2.2.1-alpha.0. You can try it out now by running :

yarn add docz@next

And will soon be in latest under 2.2.1 👍

PS: For more information about styling using themeConfig check : https://theme-ui.com/theme-spec

@rakannimer rakannimer added fixed Issue fixed and released pending-user-response labels Dec 11, 2019
@Yihwan
Copy link
Author

Yihwan commented Dec 11, 2019

hey @rakannimer thanks for taking a look!

unfortunately i am still seeing this issue with 2.2.1-alpha.0. You can check it out at this branch: https://github.com/Yihwan/gatsby-docz-flicker-issue/tree/theming-issue

I used this doczrc.js, and am only seeing the serif fonts in body applied:

export default {
  themeConfig: {
    fonts: {
      body: 'serif',
    },
    style: {
      h2: {
        color: 'red',
        fontWeight: 500,
      }, 
    }
  }
}

@rakannimer
Copy link
Contributor

I think it's still happening in the repo you provided because you have shadowed all the files in gatsby-theme-docz which is preventing the fix from being applied in the updated gatsby-theme-docz.

In particular the fix which is in base/Layout and index.js is being over-written by :

I advise you to remove the theme and only keep the file(s) that you really need to shadow to be able to benefit from new features and fixes 👍

@Yihwan
Copy link
Author

Yihwan commented Dec 11, 2019

hmm interesting, i just removed the entire gatsby-theme-docz directory and i am still noticing the styles not being applied in the above repo. maybe i missed something else?

@rakannimer
Copy link
Contributor

I found 2 other issues :

  1. you updated docz but gatsby-theme-docz was still on the previous version.
  2. there was a typo in your doczrc you wrote style instead of styles.

Could you give Yihwan/gatsby-docz-flicker-issue#1 a try and let me know ?

@Yihwan
Copy link
Author

Yihwan commented Dec 11, 2019

so weird, i just merged your PR into https://github.com/Yihwan/gatsby-docz-flicker-issue/tree/theming-issue, but am still not seeing a change. but if you can see the h2 elements turn red on the same branch, maybe it is just something to do with my local env.

@Yihwan
Copy link
Author

Yihwan commented Dec 12, 2019

@rakannimer i just got this fix working on a separate repo, so i am guessing i couldn't figure it out this morning due to lack of coffee. 😆

thank you again, and i'll let you know if i notice any other strange things!

@rakannimer
Copy link
Contributor

rakannimer commented Dec 12, 2019

Awesome ! Happy to hear that 😄

I will keep this issue open until we release 2.3.0

@rakannimer rakannimer added pending-release Issue fixed but not published to npm yet and removed pending-user-response labels Dec 12, 2019
@zhangguimei
Copy link

y!

感谢您报告此问题并提供了一种简单的方法来重现它。

主题mdx组件确实存在问题。
3a9bdb7修复

新版本发布在的next标记下2.2.1-alpha.0。您可以运行以下命令立即尝试:

yarn add docz@next

并将很快出现在latest2.2.1下👍

PS:有关使用themeConfig样式的更多信息,请检查:https ://theme-ui.com/theme-spec

Hey !

Thanks for reporting this issue and providing an easy way to reproduce it.

There was indeed an issue with theming mdx components.
Fixed by 3a9bdb7.

The new version is released on the next tag under 2.2.1-alpha.0. You can try it out now by running :

yarn add docz@next

And will soon be in latest under 2.2.1 👍

PS: For more information about styling using themeConfig check : https://theme-ui.com/theme-spec

themeConfig: {
styles: {
h2: {
fontSize: 18,
marginBottom: 10,
},
pre: { marginTop: '8px', 'margin-bottom': '20px' },
},
},
The marginBottom in pre and h2 is not work as expected, and I can use margin-bottom to replace it。

@stale
Copy link

stale bot commented Feb 15, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 15, 2020
@stale stale bot closed this as completed Feb 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Issue fixed and released pending-release Issue fixed but not published to npm yet stale v2
Projects
None yet
Development

No branches or pull requests

3 participants