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.

Custom StyleSheet

See original GitHub issue

https://github.com/emotion-js/emotion/blob/ce9873faabef8baf4eeebf8fab0d7b1a46ff74c7/packages/react/src/global.js#L94

Hi! I found emotion in creating a new Sheet based on the old sheet. Is it possible to get rid of this behavior, or use the same constructor as the cache.sheet has?

I’m handling a very special environment and I must implement my own StyleSheet class to insert rules. It’s be like this:

    const emotionCache = createEmotionCache({ key: keyA })
    const styleSheet = new MySpecialStyleSheet(keyA, shadow)
    emotionCache.sheet = styleSheet

It works well besides the global styles. Global styles using the emotion’s original implementation therefore I cannot control the insertRule behavior.

If I can provide my own StyleSheet implementation, or at least emotion can write this to use my StyleSheet:

let sheet = new cache.sheet.constructor({
    ...
})

it will be great! thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Mar 9, 2022

Would you be open to preparing a PR for the cache.sheet.constructor change?

1reaction
Andaristcommented, Mar 7, 2022

Hi there,

nice to see you here - thank you for your great OSS work! I can’t wait for throw types to happen 😉

Using cache.sheet.constructor within Global seems like something that we could do. Considering it’s a simple change and that it wouldn’t break anything and doesn’t really introduce any new options/configuration etc this is a solution that I would prefer. Especially that you could only tweak your cache once and the rest of the thing would “just work”.

If you prepare a PR for such a change with tests then I would happily merge it.

I’m handling a very special environment and I must implement my own StyleSheet class to insert rules.

Out of my curiosity - could you describe this in more detail? I love learning about quirky use cases 😛

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding a Custom Stylesheet | Gantry Documentation
This tutorial will take you through the steps needed to add a custom stylesheet to your Gantry template, without worrying about lost changes...
Read more >
Create, edit, and attach CSS files to style your site
On theTemplates tab, scroll to CSS & Stylesheets. To add a stylesheet, click + Add style sheet. Click the X beside an attached...
Read more >
Custom stylesheet - Harvard's Digital Accessibility Services
Use responsive design to allow your content to zoom and respond to various screen sizes. Present content without loss of information or functionality,...
Read more >
About Custom Style Sheets - Oracle
A custom style sheet extends the styles defined in the style sheet for a parent look and feel. In ADF UIX, a custom...
Read more >
Apply a Custom Stylesheet - Asciidoctor Docs
Specify the custom stylesheet. Asciidoctor looks for the stylesheet file specified by the stylesheet document attribute. If the value of this attribute is...
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