Code Monkey home page Code Monkey logo

Comments (5)

Tahul avatar Tahul commented on May 20, 2024

That is also something I'm considering, but I currently think that limiting computed styles to single attributes is also really good in terms of how it make you shape your components.

Handing big blocks of styling to computed styles would also mean these would rely on runtime styling, and this is not the state of mind Pinceau is trying to promote.

Yet, this is definitely something I could be implementing.

from pinceau.

SGAMERyu avatar SGAMERyu commented on May 20, 2024

Maybe we can design an enhanced property. Say $computed to render multiple css properties
Developers will choose them according to their actual situation, which may be a better experience for component library developers or some client pages facing the c side

css({
  ',text': {
     $computed: (props) => {
       return {
         color: `{color.${props.color}.600}`,
        fontSize: `{size.${props.size}}`
      }
    }
   }
})

from pinceau.

Tahul avatar Tahul commented on May 20, 2024

I would prefer this syntax:

css({
   '.text': (props) => ({
      color: `{color.${props.color}.600`,
      fontSize: `{size.${props.size}}}`
   })
})

I think I can implement that, but I'm just afraid of potential side-effects right now.

Also, I'm afraid it'll be misunderstood as a great way to apply style on groups of styles, while this ain't the case, variants are made for that. 😬

from pinceau.

SGAMERyu avatar SGAMERyu commented on May 20, 2024

What are the potential side effects?
I think we could suggest in the documentation a difference between variants and $computed. Like vue https://vuejs.org/guide/essentials/computed.html#computed-caching-vs-methods passages in the document
There are several computed properties which I think give a good dx experience in css pseudo-class states like hover and active focus

from pinceau.

SGAMERyu avatar SGAMERyu commented on May 20, 2024

I also think this approach can be a bit confusing,

css({
   '.text': (props) => ({
      color: `{color.${props.color}.600`,
      fontSize: `{size.${props.size}}}`
   })
})

With $comouted, developers may be able to visually display which css styles are dynamic and which are static

css({
  '.test': {
     display: 'flex',
    $computed(props) {
      return {
       'color': 'color.{props.color.600}',
       'width': 'size.${props.size}'
     }
    }
   }
})

because there are usually some fixed css styles such as display white-sapce common css properties.

from pinceau.

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.