Giter VIP home page Giter VIP logo

Comments (2)

andrew-boyd avatar andrew-boyd commented on May 28, 2024

So thinking more on this I don't think it's actually a bug — when you modify the attr directly you're literally adding the string $remove:text-orange. There is no more parsing to be done. The parsed list is what is contained is classes.outer.

Alternatives:

from formkit.

toyi avatar toyi commented on May 28, 2024

Got it, thank you for your answer!

I think it might be interesting to improve the DX here. Note that I use the conditional here, I'm still learning FormKit and it's totally possible there are very good reasons unknown to me why this is not possible.

First, the string concatenation is not very intuitive / cumbersome. "$classes.outer + ' other-class'" works, but your brain really wants to write "$classes.outer other-class".

I was also sure it was possible to manipulate the $classes.outer in a way or another... and I tested a lot of things before asking on Discord (you know, the there must be a way to do it feeling).

What came to my mind at first glance when I was looking for a solution was:

  1. Obviously, $classes.outer $remove:text-orange, but then the problem of "remove text-orange from where? $classes.outer ? What if there are multiple class pools concatened?
  2. So maybe something like $classes.outer.replace('text-orange', ''), but I know, it's not javascript, it's explained in the doc (Although it looks very much like JavaScript — schema expressions are not JavaScript. They are better thought of as a templating language) :p It's tempting through.
  3. Maybe $remove could be available in $fns? It's currently not, but since there are functions inside it, is there a way to implement something like $fns.remove($classes.outer, 'text-orange')?
  4. Maybe it could be possible to access the $classes.outer output in JS, manipulate it and then use it in the attrs.class property. This point is interesting, I think accessing the final classes of a particular section could be awesome (using a helper function, a node function or anything else).

That was feedback as a newcomer writing his first inputs. For now I managed to progress without all that so it's obviously not mandatory :p

Have a nice day!

from formkit.

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.