Comments (3)
export const color = stylex.defineVars({
shadow: "0, 0, 0",
shadowStrength: "0.1",
})
export const shadow = stylex.defineVars({
md: `0 2px 2px rgba(${color.shadow}, ${color.shadowStrength}`,
})
Having to repeat stuff like this is bad. This should be patched in stylex itself.
defineVars could keep track of variables it depends on, then createTheme can patch them.
from stylex.
@aspizu This is a subjective issue as one behaviour isn't automatically better. After all, we're replicating the behaviour in CSS itself.
That said, we recognise how the CSS behaviour may not match expectations and have considered many possible solutions none of which seem to quite work. If you have a longer proposal on how the whole system should work, we're happy to consider your ideas.
from stylex.
This is how CSS variables work, so the way things work today is expected. The workaround is to create a theme to "re-set" the derived variable:
import stylex from "@stylexjs/stylex"
import {biz, foo} from "~/tokens.stylex"
const styles = stylex.create({
foo: {
aspectRatio: 1,
background: biz.boo,
width: "100px"
}
})
const theme = stylex.createTheme(foo, {
bar: "blue"
})
const themeBoo = stylex.createTheme(biz, {
boo: foo.bar,
})
export function App() {
return (
<div {...stylex.props(theme, themeBoo)}>
<div {...stylex.props(styles.foo)}></div>
</div>
)
}
This will do what you expect.
from stylex.
Related Issues (20)
- A good way to write complex css + compose local styles would be nice. HOT 1
- esbuild plugin has undeclared dependency on babel-plugin-syntax-hermes-parser
- How to Contribute
- Examples for reference for better understanding HOT 1
- Support of swapping underlying variables while using hierarchical variable references HOT 12
- Remove non-standard CSS properties from types
- Unable to run StyleX with Next.js HOT 14
- How to Contribute
- Question: what pattern should be used for DRY values in style keys?
- @stylexjs/[email protected] tarball without lib directory HOT 2
- [@stylexjs/valid-styles]: overflow: 'clip' not allowed HOT 1
- @stylexjs/cli Missing Plugin HOT 2
- Stop transforming textAlign:start/end HOT 3
- Documentation for `useCSSLayers` and CLI package HOT 1
- Cleaning up CSS Properties with null value HOT 3
- stylex.firstThatWorks() not correctly linted HOT 2
- Can I use stylex in Next.JS with SWC? HOT 2
- How would you use dataset propertiers / attributes in stylexjs?
- Support for creating custom properties as functions HOT 2
- Allow variables in themes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stylex.