Comments (6)
@jacobobryant You can use the branch garden-comp
as a base for your PR.
from girouette.
Hoping to get to this in the next couple days FYI!
from girouette.
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.
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.
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.
Oh good point, that does seem like obviously the best way to do it.
from girouette.
Related Issues (20)
- Display rule includes variants in value HOT 1
- Via the wiki: Documenting Girouette, its grammar and the preprocessor
- Preprocessor displays parse error when we delete a file
- Preprocessor should ignore clj files
- Invalid CSS is generated for `{screen}:display` rules HOT 3
- similar: https://www.npmjs.com/package/@tailwindcss/jit HOT 2
- Should it be girouette.tw to tw.girouette? HOT 1
- Dark mode variant does not work for text HOT 1
- Tailwind max-width classes only partially supported HOT 2
- Generate class lists HOT 3
- README a bit outdated HOT 1
- Upgrade to latest Tailwind v3 HOT 10
- divide-* bug HOT 3
- Add `:version` field to components
- Add Tailwind's v3 colors HOT 1
- Any way to output colors without css vars? (or maybe as hex or rgb) HOT 3
- parse error when using Creating Reagent "Components" from React Components HOT 7
- Add a recent version of Preflight
- tailwind ring styles seems to be broken HOT 1
- Can string/keyword harvesting be parameterized? HOT 2
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 girouette.