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

Bug when extending styles #218

Open
atersolis opened this issue Dec 31, 2020 · 3 comments · May be fixed by #220
Open

Bug when extending styles #218

atersolis opened this issue Dec 31, 2020 · 3 comments · May be fixed by #220
Labels
bug Something isn't working

Comments

@atersolis
Copy link

atersolis commented Dec 31, 2020

First of all, thanks for this lib, I'm amazed by how much it can do while being less than 1kb.
I have reduced my bundle size by a lot using this with preact.

Unfortunately I have run into a bug while extending styles.
Here is a minimal code sample to reproduce the bug:

import React from 'react'
import { render } from 'react-dom'
import { styled, setup } from "goober"

setup(React.createElement)

const RedBase = styled('div')`color: red;`
const Orange = styled(RedBase)`color: orange;`
const Blue = styled(RedBase)`color: blue;`
const UnderlinedBlue = styled(Blue)`text-decoration: underline;`

const App = () => {
	return <div>
		<Orange>Orange</Orange>
		<UnderlinedBlue>UnderlinedBlue</UnderlinedBlue>
	</div>
};

render(<App />, document.getElementById('app'))

In this situation the text in UnderlinedBlue should be blue, but it's red because of a wrong order of the class names in the class attribute. In that case, the classname of RedBase is after the classname of Blue and overwrite it.
Sorry the class names are actually in the right order. The problem most likely comes from the order in which the classes are declared in the generated CSS.

However if I remove <Orange>Orange</Orange>, it is blue as expected.

I am using goober 2.0.19-next.1
I will try to find some time to fix it.

happy new year !

atersolis added a commit to atersolis/goober that referenced this issue Jan 2, 2021
@atersolis atersolis linked a pull request Jan 2, 2021 that will close this issue
@cristianbote
Copy link
Owner

Hey @atersolis! Happy New Year! 🎉

Thank you for opening this issue and an already working PR! Amazing! 🙏

The issue is really odd 🤦 was actually convinced that this got fixed a while ago. Gonna dig a bit to look into it more.

@cristianbote cristianbote added the bug Something isn't working label Jan 4, 2021
@riccardogiorato
Copy link

Hey @cristianbote I am having the same issue, is there any fix on this behaviour possible?

@thebrubaker
Copy link

Thanks for working on this one! Having the same issue and this would be 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants