Giter VIP home page Giter VIP logo

Comments (3)

aspizu avatar aspizu commented on July 26, 2024 1
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.

nmn avatar nmn commented on July 26, 2024 1

@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.

nmn avatar nmn commented on July 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.