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

Fixed Theme UI usage in Storybook #19

Merged
merged 1 commit into from Nov 15, 2021

Conversation

nickytonline
Copy link
Owner

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Theme UI wasn't working in Storybook because it was conflicting with Theme UI dependencies that Storybook itself uses.

Related Tickets & Documents

Closes #10

QA Instructions, Screenshots, Recordings

  1. Run yarn to install new dependencies
  2. Run yarn storybook
  3. Storybook will open in the default browser at http://localhost:6006
  4. One story will be present for the <ExampleHeader /> component. It should have the styling and animation in the animated GIF below.

Oct-27-2021 23-13-21

UI accessibility concerns?

N/A

Added/updated tests?

  • Yes
  • No, and this is why: I added a Storybook story for the <ExampleHeader /> component that ships with the project to demonstrate that Theme UI is working properly in the context of Storybook.
  • I need help with writing tests

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

Kamala Harris saying "We did it Joe" while speaking to Joe Biden on her cell

@nickytonline nickytonline added merge by any core This tag is a signal that you are okay with any core team member merging your code for you. frontend infrastructure Anything related to frontend infrastructure. labels Oct 28, 2021
...config.resolve,
alias: {
...config.resolve.alias,
'@components': path.resolve(__dirname, '../components'),
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty much the fix. Aliasing to the correct dependencies as per the solution mentioned in #10.

@nickytonline nickytonline force-pushed the fix-theme-ui-usage-in-storybook branch 2 times, most recently from fdba76c to dd50226 Compare November 1, 2021 19:13
@vercel
Copy link

vercel bot commented Nov 1, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nickytonline/web3-starter/6zuXE73kEMxMmQ6HWZbj3kPcNbFW
✅ Preview: https://web3-starter-git-fix-theme-ui-usage-in-storybook-nickytonline.vercel.app

import { Meta } from '@storybook/react';
import { ExampleHeader } from '@components/Header';

const meta: Meta = {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a sample Storybook story for a component in the project.

'@babel/preset-react',
);
// Pulling this from the @emotion/babel-preset package in project's .babelrc
config.presets[presetReactIndex][1].importSource = 'theme-ui';
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixing the babel configuration so it behaves like the babel configuration in the project.

https://github.com/nickytonline/web3-starter/blob/fix-theme-ui-usage-in-storybook/.babelrc

{
  "presets": [
    [
      "next/babel",
      {
        "preset-react": {
          "importSource": "theme-ui",
          "runtime": "automatic",
          "throwIfNamespace": false
        }
      }
    ]
  ]
}

@nickytonline nickytonline merged commit e191fe4 into main Nov 15, 2021
@nickytonline nickytonline deleted the fix-theme-ui-usage-in-storybook branch November 15, 2021 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend infrastructure Anything related to frontend infrastructure. merge by any core This tag is a signal that you are okay with any core team member merging your code for you.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Theme UI <ThemeProvider /> does not work with Storybook
2 participants