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

Decorator inheritance / replacing only changed keys #700

Open
Paril opened this issue Oct 16, 2024 · 4 comments
Open

Decorator inheritance / replacing only changed keys #700

Paril opened this issue Oct 16, 2024 · 4 comments
Labels
discussion Meta talk and feedback enhancement New feature or request

Comments

@Paril
Copy link
Contributor

Paril commented Oct 16, 2024

When trying to use media queries to change decorators, it seems like a @decorator rule completely replaces the other instead of just changing the key that are different;

@decorator arrow_left : image
{
    image-src: /gfx/cursor.png;
    image-fit: contain;
}

@media (theme: bg-contain)
{
	@decorator arrow_left : image {
	    image-src: /gfx/cursor-select.png;
	}
}

If the theme is set, image-fit ends up getting reset. Right now, our menus need several combinations of things (we have three sizing modes and 5 different BG images depending on language), so we need 5 x 3 different lines just to represent all of the different combinations, but being able to do the above would reduce it to 5 + 3.

@mikke89
Copy link
Owner

mikke89 commented Oct 16, 2024

We do actually have a bit of a hidden feature when it comes to decorators, they actually support inheritance. So you should be able to do this:

@decorator arrow_left_base : image
{
    image-src: /gfx/cursor.png;
    image-fit: contain;
}

@media (theme: bg-contain)
{
	@decorator arrow_left : arrow_left_base {
	    image-src: /gfx/cursor-select.png;
	}
}

@Paril
Copy link
Contributor Author

Paril commented Oct 16, 2024

Interesting - but how would that work if I had two things to modify? I have three themes that change the fit, and then five themes that change the BG image. I guess in theory one of the themes would always be set so there'd always be a base to inherit from, but somehow I don't think that'll end up working...

@mikke89
Copy link
Owner

mikke89 commented Oct 17, 2024

Hm, right, I guess you would need something more like multiple inheritance in that situation. I think for now you'll just have to use media queries for the different combinations. At least you'll have the option to use this inheritance for common properties between them.

With that said, I do think the idea of inheriting individual properties in a CSS-way when using the same @decorator name could be interesting.

@mikke89 mikke89 added enhancement New feature or request discussion Meta talk and feedback labels Oct 17, 2024
@Paril
Copy link
Contributor Author

Paril commented Oct 18, 2024

Yeah I think that would make the most sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Meta talk and feedback enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants