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

css: Make background a theme-aware property #2021

Closed
benface opened this issue Nov 23, 2021 · 6 comments · Fixed by #2056
Closed

css: Make background a theme-aware property #2021

benface opened this issue Nov 23, 2021 · 6 comments · Fixed by #2056
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed released This issue/pull request has been released.

Comments

@benface
Copy link

benface commented Nov 23, 2021

Is your feature request related to a problem? Please describe.
I find it surprising and confusing that the bg shorthand can be set to a color name/key, but not background, as they read the same.

Describe the solution you'd like
I would like background to be a theme-aware property, so I can do sx={{ background: 'myCustomColorName' }}.

Describe alternatives you've considered
I can obviously use bg or backgroundColor. But once in a while, I may forget and use background, and be slightly annoyed when the color name I pass doesn’t get converted to the expected color value.

Additional context
I can send a PR for this if you (the maintainers) agree with the idea. Thank you!

@hasparus
Copy link
Member

Yeah, I think that's a nice addition. I wouldn't try to parse complex background like "center / contain no-repeat url("logo.svg")" values anyway, but simply adding background to colors scale would be convenient.

@hasparus hasparus added the enhancement New feature or request label Nov 23, 2021
@fcisio
Copy link
Collaborator

fcisio commented Nov 24, 2021

I have another great use case for this.
Making background theme-aware would allow setting gradients along with the colors in the theme 🔥

{
  primary: '#333',
  gradient: 'background: linear-gradient(#e66465, #9198e5);',
  ...
}

// sx={{ background: 'gradient' }}

@hasparus hasparus added help wanted Extra attention is needed good first issue Good for newcomers labels Nov 26, 2021
@lachlanjc
Copy link
Member

Eeh, I’m not in favor of supporting & parsing entire CSS declarations inside theme values. Let's only permit the usage of standard theme values here.

@lachlanjc lachlanjc changed the title Make background a theme-aware property css: Make background a theme-aware property Nov 29, 2021
@fcisio
Copy link
Collaborator

fcisio commented Nov 29, 2021

Hey @lachlanjc ,
Sorry, bad copy/paste, I meant:

gradient: 'linear-gradient(#e66465, #9198e5)'

@lachlanjc
Copy link
Member

Oh! Yes, that's cool with me. Semicolon-free is definitely the way to go haha

@hasparus hasparus added the prerelease This change is available in a prerelease. label Jan 3, 2022
@hasparus
Copy link
Member

hasparus commented Jan 5, 2022

🚀 Issue was released in v0.13.1 🚀

@hasparus hasparus added released This issue/pull request has been released. and removed prerelease This change is available in a prerelease. labels Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants