All Projects → roosta → Herb

roosta / Herb

Licence: epl-1.0
🌿 Clojurescript CSS styling using functions.

Programming Languages

clojure
4091 projects
clojurescript
191 projects

Projects that are alternatives of or similar to Herb

awesome-web-styling
Awesome Web Styling with CSS Animation Effects ⭐️
Stars: ✭ 109 (-9.17%)
Mutual labels:  styling
Attributedtextview
Easiest way to create an attributed UITextView (with support for multiple links and from html)
Stars: ✭ 397 (+230.83%)
Mutual labels:  styling
Polished
A lightweight toolset for writing styles in JavaScript ✨
Stars: ✭ 7,074 (+5795%)
Mutual labels:  styling
wp-datepicker-styling
jQuery UI Datepicker styling to match WordPress color schemes
Stars: ✭ 78 (-35%)
Mutual labels:  styling
Styled Components Theme
Defines themes via flexible color selectors for use with styled-components
Stars: ✭ 302 (+151.67%)
Mutual labels:  styling
Termenv
Advanced ANSI style & color support for your terminal applications
Stars: ✭ 555 (+362.5%)
Mutual labels:  styling
QlikSense-Sheet-Styler-Lite
Qlik Sense Styler for 3.2+
Stars: ✭ 17 (-85.83%)
Mutual labels:  styling
Quark
Quark.js is a microscopic atomic CSS polyfill in JS just 140 bytes
Stars: ✭ 97 (-19.17%)
Mutual labels:  styling
Dss
📄 Documented Style Sheets Parser
Stars: ✭ 375 (+212.5%)
Mutual labels:  styling
Styled System
⬢ Style props for rapid UI development
Stars: ✭ 7,126 (+5838.33%)
Mutual labels:  styling
Smart-Inspector
Fluent re-take on Unity Inspector UX. Packed with QoL improvements.
Stars: ✭ 680 (+466.67%)
Mutual labels:  styling
Stylist
Define UI styles in a hot-reloadable yaml or json file
Stars: ✭ 260 (+116.67%)
Mutual labels:  styling
Otion
Atomic CSS-in-JS with a featherweight runtime
Stars: ✭ 563 (+369.17%)
Mutual labels:  styling
ra-compact-ui
Enhanced components for popular framework react-admin. Helps reducing the styling boilerplate code and eases layout customizations.
Stars: ✭ 77 (-35.83%)
Mutual labels:  styling
Interfacss
The CSS-inspired styling and layout framework for iOS
Stars: ✭ 92 (-23.33%)
Mutual labels:  styling
pr-title-checker
An action to automatically check if pull request titles conform to Contribution Guidelines
Stars: ✭ 38 (-68.33%)
Mutual labels:  styling
Markupkit
Declarative UI for iOS and tvOS
Stars: ✭ 508 (+323.33%)
Mutual labels:  styling
Form
Form is an iOS Swift library for building and styling UIs
Stars: ✭ 99 (-17.5%)
Mutual labels:  styling
Gemma
A lightweight CSS library.
Stars: ✭ 94 (-21.67%)
Mutual labels:  styling
Reflexjs
Starter kits, themes and blocks to help you build Gatsby and Next.js sites faster. Built on top of a best-in-class styling library.
Stars: ✭ 571 (+375.83%)
Mutual labels:  styling

Herb is a CSS styling library for Clojurescript, built using Garden, whose main focus is on component level styling using functions.

Requirements

Herb requires at least Clojure 1.9.0 and ClojureScript 1.9.542 due to use of clojure.spec.alpha to validate macro input.

Quick start

Clojars Project

(ns user
  (:require [herb.core :refer [<class]]))

(defn style []
  {:background "red"})

(defn component
  [:div {:class (<class style)}])

Herb has two main macros, <class and <id, these macros takes a function that returns a Garden style map, and returns a classname/id based on the functions fully qualified name, in this case user/style.

The style is injected into the DOM when any one of Herb's macros are called.

Pass arguments:

(ns user
  (:require [herb.core :refer [<class]]))

(defn style
  [color]
  {:color color})

(defn component []
  [:div {:class (<class style "red")}])

Extend existing functions:

(ns user
  (:require [herb.core :refer [<class]]))

(defn button-style [text-color]
  {:display "inline-block"
   :color text-color
   :text-transform "uppercase"
   :cursor "pointer"
   :padding (px 12)})

(defn red-button-style []
  ^{:extend [button "white"]}
  {:background-color "red"})

(defn button []
  [:button {:class (<class red-button-style)}])

Garden is used to translate the style map to CSS, which enables most of Gardens functionality, so familiarizing yourself with its features is a good idea.

Refer to the tutorial for a full overview and examples of Herbs features.

Advanced optimizations

During a production build add this to the :compiler config :closure-defines {"goog.DEBUG" false}. This flag tells Herb to minify styles, remove unneeded style element attributes, and ensure anonymous functions gets the correct minified name.

Debugging advanced compilation

During advanced compilation Herb minify styles and removes the data-herb attribute. If you need to debug production build it can be helpful to see the function namespaces unmunged to get a clearer image of what is happening.

To do this remove the goog.DEBUG false from production build and enable :pseudo-names:

:cljsbuild {:builds {:min {:source-paths ["src" "env/prod"]
                           :compiler {:pseudo-names true
                                      :optimizations :advanced
                                      ...
                                      }}

That way you will see both full classnames and the namespace reflected in the data-herb HTML attribute.

Development

Start figwheel main with the development build

lein fig:build

Figwheel-main will automatically push cljs changes to the browser. Once Figwheel starts up, you should be able to open http://localhost:9500 for the development server.

Testing

Either run:

lein fig:test

For a headless test environment using chrome, make sure its installed on your system.

You can also start the dev build and navigate to http://localhost:9500/figwheel-extra-main/auto-testing to get a nice interface while coding that runs the tests on each save.

License

Copyright © 2019 Daniel Berg

Distributed under the Eclipse Public License, the same as Clojure.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].