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.

Hi guys!!

First of all thank you very much for styled-components. We’re massively using it in our company and we’re superhappy with it! Great job!!

Lately we were forced to start using a global namespace for our css and we noticed that styled-components does not really play well with it.

Here you can find a bin with a practical example: https://www.webpackbin.com/bins/-KfvQIyzL57v9tfNRauJ .

Actual behaviour: The background is green.

Expected behaviour: The background is papayawhip.

So far we’re handling it by adding to each styled component a class self in order to style them in this way:

&.self {
  background: papayawhip;
}

But of course we’re not satisfied with this solution.

We thought it would be useful to pass to the ThemeProvider a global namespace to use for increasing the styled-components selectors specificity.

Do you have any other suggestion/solution for such a case?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
nvanselowcommented, Oct 27, 2017

The PR referenced in the previous comment is now closed. Based on a suggestion by @philpl, I have created an independent babel plugin that will automatically add && or a list of specified classes to all the styled components. I will make that publicly available as soon as I get everything setup.

0reactions
nvanselowcommented, Oct 23, 2017

We’ve run into this same issue. I’ve opened a PR that uses babel-plugin-styled-components along with some minor changes to styled-components to allow for additional classes to be added to the selectors for styled components.

https://github.com/styled-components/styled-components/pull/1260 https://github.com/styled-components/babel-plugin-styled-components/pull/101

Read more comments on GitHub >

github_iconTop Results From Across the Web

Global Namespace - Wikipedia
A Global Namespace (GNS) is a heterogeneous, enterprise-wide abstraction of all file information, open to dynamic customization based on user-defined ...
Read more >
What is Global Namespace | Manage Your Unstructured Data
A global namespace is a core capability of a distributed file system that provides a unified control and management plane to search and...
Read more >
What is global namespace? | Definition from TechTarget
Global namespace is a feature that provides a consolidated view into multiple Network File Systems (NFS), Common Internet File Systems (CIFS), ...
Read more >
What is a Global Namespace? - F5 Networks
A global namespace is a federation of file systems from any number of file storage devices, such as servers using NFS (network file...
Read more >
Global Namespaces - VMware Docs
Global namespace, a unique concept in Tanzu Service Mesh, defines an application boundary. A global namespace connects the resources and ...
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