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

Opacities Scale #863

Closed
peduarte opened this issue Apr 21, 2020 · 2 comments · Fixed by #866
Closed

Opacities Scale #863

peduarte opened this issue Apr 21, 2020 · 2 comments · Fixed by #866

Comments

@peduarte
Copy link
Contributor

Is your feature request related to a problem? Please describe.
In Modulz, we're exposing Opacity Tokens, however:

Describe the solution you'd like
I'd like to be able to use the CSS function with an opacities scale:

css({
  opacity: 1 // should return 50%
})({
  theme: {
    opacities: ["0%", "50%", "100%"]
  }
})

Describe alternatives you've considered
The CSS function defaults to mapping to a scale named after the property. It's probably not intentional, @jxnblk would appreciate some context here.

Because of that, if we have a scale called opacity, it works:

css({
  opacity: 1 // should return 50%
})({
  theme: {
    opacity: ["0%", "50%", "100%"]
  }
})

Additional context
Here's a Codesandbox Demo with my expectation and workaround mentioned above

@jxnblk
Copy link
Member

jxnblk commented Apr 21, 2020

I certainly have never really used opacity in this sort of way, and tend to avoid it due to z-index issues, but this makes sense to me. For context, the fallback to picking up theme[CSSProperty] is intended to catch things like this that aren't currently supported by a given scale name

@peduarte
Copy link
Contributor Author

peduarte commented Apr 21, 2020

Gotcha. You cool with me explicitly adding an opacities scale mapping in theme-ui/css then?

peduarte pushed a commit to peduarte/theme-ui that referenced this issue Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants