• Stars
    star
    204
  • Rank 192,063 (Top 4 %)
  • Language
    Clojure
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Grammar-based, generative approach to CSS.

Girouette CircleCI

Clojars Project Cljdoc badge Project chat Clojars download_badge

Une girouette

Dès que le vent soufflera, je repartira.
Dès que les vents tourneront, nous nous en allerons.

Girouette is a grammar-based, generative approach to CSS. It translates a classname into a Garden data structure representing CSS.

(class-name->garden "w-10")
; => [".w-10" {:width "2.5rem"}]

Girouette also makes it easy to use your own grammar rules to generate anything you may dream of.

Introduction

CSS libraries like Tailwind and Tachyons provide quantities of predefined class names, hoping to cover most of the needs of their users. But because of combinatory explosion, they cannot provide all the class names users will ever need, in which case the users will have to hack their way with config files and/or handwritten CSS. When releasing for production, the unused CSS classes are removed from the CSS files using tools like PurgeCSS.

Girouette is taking the opposite approach where we first look at which class names are used, and from their names and a grammar associated with some generation rules, the corresponding CSS content is created.

This "on demand" generative approach allows to have any combination of parameters in a CSS class name, while opening the door to the most creative grammars which a human would want to use to communicate its intent.

(UPDATE: a couple of months after Girouette was released, the author of Tailwind implemented in its version 2 and 3 an "on demand" feature very similar to Girouette)

Documentation & Resources

Girouette currently has components which makes it compatible (with a few caveats) with:

Presentation @ the Bay Area Clojure Meetup:

The project has example projects in example/:

How it works

Girouette is using the awesome Instaparse library for parsing the class names, and is converting them into the Garden format.

Its API mainly consists in the function class-name->garden which is pretty explicit.

(class-name->garden "w-42%")
;=> [".w-42\\%" {:width "42%"}]

You can use Girouette processor tool to extract the CSS class names from your source code and generate the CSS in real time as you develop.

See the demo project for more information.

Advantages of this approach

With the right Girouette components in place, any parameters can be combined in class names without leaving your usual REPL workflow.

Large range on numbers

No need to stop what you are doing and to modify some config files just because mx-13 is not supported by default while mx-12 is.

Any color can be represented directly in class names, like rgba-f59d or rgba-ff5599dd.

Limitless class name descriptiveness

It is possible to create grammars which support very long class names.

;; Example of class name:
"bg-gradient-to-right-red-orange-yellow-green-blue-purple"

;; Instaparse rule:
"bg-gradient = <'bg-gradient-to-'> gradient-direction (<'-'> color)+
 gradient-direction = 'top' | 'right' | 'bottom' | 'left' | angle
 color = ...
 "

Link to other CSS projects

In Clojure

A few other alternatives are available.

In JS

Atomizer

Atomizer is an older project which is also interpreting CSS class names.

WindiCSS

Independently and in parallel of Girouette's development, WindiCSS was developed with similar ideas. Please check it out, specially if you are developing directly in the JS environment.

Who is using Girouette

(To add your project to this list, just edit this file and open a pull request)

Contribute

Contributions are very welcome, just make sure that the contributions are your own, and add proper credits in the commit messages if it is not the case.

License terms

This project is distributed under the MIT License, which is available at https://opensource.org/licenses/MIT

Copyright (c) Vincent Cantin and contributors.

More Repositories

1

vrac

[WIP] Declarative html template library from the future.
Clojure
67
star
2

minimallist

A minimalist data driven data model library, inspired by Clojure Spec and Malli.
Clojure
66
star
3

html-to-hiccup

A html->hiccup conversion function in pure CLJC
Clojure
50
star
4

diffuse

Diffuse is a library to create, use and manipulate diffs, to build the change you wish to see in your data.
Clojure
48
star
5

cdc

A library for performing Content-Defined Chunking (CDC) on data streams.
Rust
23
star
6

mate

Useful functions, some of which I wish were in the Clojure standard library.
Clojure
19
star
7

unity3d-ddp-client

Lightweight DDP client for Unity3D
C#
19
star
8

transducer-exercises

Learn how to write your own transducers. A complement from my blog post serie "Build Your Own Transducer and Impress Your Cat".
Clojure
18
star
9

ratatouille

My lein template
Clojure
9
star
10

reitit-oauth2

Adaptation of ring-oauth2 to reitit routes + example of usage
Clojure
9
star
11

embassy

[WIP] A Clojure(script) library to represent HTML diffs, to compose them together and to apply them on the DOM.
Clojure
5
star
12

girlfriend-advance

An emulator of the "Gameboy Advance" system which I wrote when I was a student.
Java
4
star
13

clojure-course

Des cours de Clojure pour les débutants
Clojure
4
star
14

advent-of-code

https://adventofcode.com/
Clojure
3
star
15

hiccdown

[WIP] Pure CLJC library to transform back and forth between markdown and hiccup
Clojure
3
star
16

vrac-template

Template for Vrac projects
Clojure
2
star
17

vrac-samples

Samples demonstrating how to use Vrac, a declarative html template library from the future.
Clojure
1
star
18

vrac-simple-sample

Simple example from Re-frame adapted to Vrac
Clojure
1
star
19

finnish-vocabulary

Finnish vocabulary from the Duolingo lessons
Clojure
1
star