`transformers` middleware for theme values
See original GitHub issueIn our custom theme implementation on our team at work, we used functions to get tokens. for example:
<div
css={theme => ({
color: theme.color('red')
})}
>
This is our token red
</div>
This enabled us to do some cool things, for example, to use https://github.com/VinSpee/alpha-string-to-rgba so we could do this:
<div
css={theme => ({
color: theme.color('red.5')
})}
>
This is our token red, transformed to 50% opacity by `aRGB`.
</div>
Maybe the API could look like something like this (just spitballing here):
const theme = {
colors: {
red: '#E62A1E'
},
transformers: {
colors: currentTheme => val => aRGB(currentTheme.colors)(val),
},
};
any thoughts on something like this? It’s like a middleware
for tokens. It could (optionally, and simply) open up a lot of possibilities.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Routing in ASP.NET Core - Microsoft Learn
When a routing middleware executes, it sets an Endpoint and route values to a request feature on the HttpContext from the current request:....
Read more >Condition in actix_web::middleware - Rust - UCSD CSE
Middleware for conditionally enabling other middleware. ... ConditionMiddleware<T::Transform, S>. The TransformService value created by this factory ...
Read more >Configuration - Scribe documentation - Read the Docs
Default: /docs . middleware : List of middleware to be attached to the documentation endpoint ... By default, this will be the value...
Read more >A Lightweight XML-based Middleware Architecture - CiteSeerX
of platform and language, support both value and reference ... in parsers [12] and transformers [13, 14]. ... quently, this topic is not...
Read more >Plugins
An open source Traefik Middleware that enables Authentication via LDAP in a ... Apply themes from [theme.park](theme-park.dev) to supported applications.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For anyone else coming here wanting to stick to theme-ui’s API but want to change some of the ways theme data is stored you can use a
Proxy
For example, my theme operates on a base-8 scale. So if I want spacing to act like
<Box margin={3}/>
to give me{ margin: 24px; }
I can set a Proxy for the space prop.Note Be aware of the support for Proxy: https://caniuse.com/#search=proxy https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
Going to close this out, since I think @johno covered some of the rationale with how we’re approaching theming here