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.

Using media queries in decorators

See original GitHub issue

I have the following decorator in my stories:

export default {
    title: 'Components/Button',
    decorators: [storyFn => <div style={{ backgroundColor: 'black', padding: '24px' }}>{storyFn()}</div>],
};

This is because the elements support dark mode out of the box so need a black background when displayed in the Docs…

However I only want this when in Dark Mode…

So I need something like:

export default {
    title: 'Components/Button',
    decorators: [storyFn => <div style={{ @media(prefers-color-scheme: dark) { backgroundColor: 'black', } padding: '24px' }}>{storyFn()}</div>],
};

But it doesn’t like that syntax (obviously)… how can you add media queries into the decorator?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
iamdrizcommented, Nov 28, 2019

😬 pretty please? ❤️

0reactions
Bowriverstudiocommented, Jun 7, 2020

Did you manage to solve this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Media Query Decorator › zzzzBov.com - Blag
Media Query Decorator · TypeScript supports decorators which are very convenient for adding complex functionality to classes in a declarative ...
Read more >
Fundamentals / Media Queries - Page ⋅ Storybook
Media queries allow us to create responsive experiences by changing the look and feel of a component based on the given media query....
Read more >
Using media queries - CSS: Cascading Style Sheets | MDN
A media query computes to true when the media type (if specified) matches the device on which a document is being displayed and...
Read more >
Styled-component and Material component (Media queries)
I have some difficulty to understand media queries with MUI and styled component. I understand that this following syntax is from styled- ...
Read more >
The Best Way to Facilitate CSS Media Queries using SCSS ...
This article will explain how to create media queries using SCSS mixins. It will also show how to use the @include function to...
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