Comments (5)
Alternatively just allowing us to point the target directly to a style
tag would also solve the issue for me.
Lines 11 to 24 in 2b2d422
Maybe adding an early return to the getSheet
function here:
export let getSheet = (target) => {
if (typeof window === 'object') {
if (target instanceof HTMLStyleElement) {
return target;
}
//...
}
//...
}
from goober.
Hey @ecustic, thanks for opening this issue! Nice topic π
Before getting into it just wanted to let you know that I don't have knowledge on the Obsidian inner workings.
About polluting the window
, would goober the only one that would be polluting? More precisely I believe most of the UI related frameworks will pollute in a way or another.
Creating goober instances is another way of handling these as well and I've been thinking about it. One of the things that I don't really like is that with instances the import of goober would have to be changed a bit:
// src/utils/styled.js
export const styled = createGoober({
// here will go the config part
});
// src/components/button.js
import { styled } from 'src/utils/styled';
Now, the question is, is this better? Debatable π
from goober.
I think the optimal solution would be to have both.
Export { styled, css, createGoober }
. createGoober
should return { styled, css }
. The module should then internally call createGoober
with default config and expose the styled
and css
it returns. This would allow the API to remain unchanged for the 99% who use goober as it currently is, while still having a single implementation instead of differentiating between instanced and global implementations.
from goober.
About polluting the window, would goober the only one that would be polluting? More precisely I believe most of the UI related frameworks will pollute in a way or another.
This is very true and one of the reasons I chose goober after being frustrated with the tools I normally use: emotion
and styled-components
. There are some unique limitations when you're developing an app which is going to be plugged-in to a larger codebase and expected to co-exist without any knowledge of what anything else is doing. Out of all the CSS-in-JS frameworks I tested, goober ended up being the easiest to wrangle into doing what I needed. Specifically due to it being bound to a single identifier, which I could find and remove when needed.
To avoid clashes I'm currently using an extremely hacky temporary solution where I've just written a small esbuild plugin to replace the three instances of the string _goober
in the resolved goober module to _my_plugin_name_goober
.
But in fact there should be no need to use id
at all. Replacing the id
with a data attribute such as data-goober-id
and then having the default value just be 'goober'
, but let users configure the id, would work just as well but not polute window
.
from goober.
Hello,
since setup call is mandatory - we can optionally pass id to setup
from goober.
Related Issues (20)
- extractCss() returns empty string in Solid SSR environment HOT 2
- The behavior of `glob()` was changed in 2.1.11.
- Support for concurrent rendering + server components HOT 8
- Replace babel with swc HOT 1
- How to put styles inside web component? HOT 1
- Have component names inside classnames when in dev mode HOT 2
- Help solve typescript error trying to add new prop and doing conditional style HOT 2
- Use Proxy() for styled.div HOT 2
- How does goober compare to linaria? HOT 3
- Emotion is framework-agnostic
- [ Goober + Preact ] Error rendering during testing. HOT 2
- CSS string values do not work with extracted CSS HOT 4
- `css()` taken by surprise when `this` is `window` (in βold-schoolβ JS environment) HOT 1
- Duplicated styles within dynamic classes
- Unexpected behaviour when extending components HOT 1
- Running prefixer for nested objects
- Usage with rollup HOT 1
- Shave challenge clarification: which file should we be looking at? HOT 2
- deno server-side-render error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goober.