Code Monkey home page Code Monkey logo

Comments (6)

green-coder avatar green-coder commented on August 12, 2024 1

@jacobobryant You can use the branch garden-comp as a base for your PR.

from girouette.

jacobobryant avatar jacobobryant commented on August 12, 2024 1

Hoping to get to this in the next couple days FYI!

from girouette.

jacobobryant avatar jacobobryant commented on August 12, 2024

Not having dug into the code base much, I wrote this as a naive solution:

(declare class-name->garden)

(def apply-classes
  '{btn [p-3 bg-rgba-343a40ff text-white rounded]})

(def apply-components
  (vec
    (for [[from to] apply-classes]
      {:id (keyword from)
       :rules (str "\n" from " = <'" from "'>\n")
       :garden (fn [_]
                 (->> to
                   (map (comp second class-name->garden str))
                   (reduce merge)))})))

So far I don't see any situation in which this wouldn't work, as long as you don't do '{foo [foo]} ;)

from girouette.

jacobobryant avatar jacobobryant commented on August 12, 2024

Actually this doesn't work for state variants. would there be a simple way to make this approach work? e.g. for '{foo [hover:bg-red-200 ...]} somehow let the garden fn return [[:&:hover {:--gi-bg-opacity 1, :background-color "rgba(254,202,202,var(--gi-bg-opacity))"}] ...] instead of just {:--gi-bg-opacity 1, :background-color "rgba(254,202,202,var(--gi-bg-opacity))" ...} ?

In the mean time I'm defining a separate class for the hover state:

[:button.btn.hover:btn-hover ...

(def apply-classes
  '{btn [...]
    btn-hover [...]})

...

                 (->> to
                   (map (comp second class-name->garden str))
                   (filter map?)  ; <- added this line
                   (reduce merge)))})))

from girouette.

green-coder avatar green-coder commented on August 12, 2024

I think that this apply function should operate directly on garden-data structures. No need to involve Girouette's grammar into the process.

I will write a small API and some tests in a separated branch which should be the base code for this feature. Ideally, it should have no dependency on Girouette and could hypothetically be moved to the Garden project.

from girouette.

jacobobryant avatar jacobobryant commented on August 12, 2024

Oh good point, that does seem like obviously the best way to do it.

from girouette.

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.