Skip to content

Commit

Permalink
Introduce defrules, defprop, defutil
Browse files Browse the repository at this point in the history
  • Loading branch information
plexus committed Jun 8, 2024
1 parent 12f843e commit 654ca6f
Show file tree
Hide file tree
Showing 5 changed files with 291 additions and 79 deletions.
2 changes: 1 addition & 1 deletion bb.edn
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{:deps
{lambdaisland/open-source {:git/url "https://github.com/lambdaisland/open-source"
:git/sha "2dc2a8ef9978a3fc45e8f524b0e46253caa40fe2"}}}
:git/sha "4cb6231e7df947ee8f5434e7ad48ffd8e273bcf5"}}}
16 changes: 8 additions & 8 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{:paths ["src" "resources"]

:deps
{org.clojure/clojure {:mvn/version "1.11.1"}
{org.clojure/clojure {:mvn/version "1.11.3"}
garden/garden {:mvn/version "1.3.10"}
girouette/girouette {:mvn/version "0.0.10"}
meta-merge/meta-merge {:mvn/version "1.0.0"}}

:aliases
{:dev
{:extra-paths ["dev"]
:extra-deps {djblue/portal {:mvn/version "0.46.0"}
io.github.nextjournal/clerk {:mvn/version "0.14.919"}
com.lambdaisland/hiccup {:mvn/version "0.0.33"} }}
:extra-deps {djblue/portal {:mvn/version "0.56.0"}
io.github.nextjournal/clerk {:mvn/version "0.16.1016"}
com.lambdaisland/hiccup {:mvn/version "0.7.42"} }}

:byo
{:extra-deps {hawk/hawk {:mvn/version "0.2.11"}
com.lambdaisland/glogi {:mvn/version "1.3.169"}
io.pedestal/pedestal.log {:mvn/version "0.6.0"}}}
io.pedestal/pedestal.log {:mvn/version "0.6.4"}}}

:test
{:extra-paths ["test"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.86.1355"}
:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}
lambdaisland/kaocha-cljs {:mvn/version "1.5.154"}
org.clojure/clojurescript {:mvn/version "1.11.60"}
org.clojure/clojurescript {:mvn/version "1.11.132"}
com.lambdaisland/glogi {:mvn/version "1.3.169"}
;; for lambdaisland.hiccup and lambdaisland.thicc, used in testing
lambdaisland/webstuff {:git/url "https://github.com/lambdaisland/webstuff"
:git/sha "78033fbda228c5e2fc0745619e7830b005407156"
:git/sha "f3ae2a2d41a4335d3da1757a3a21aa1dd1125eb1"
#_#_:local/root "/home/arne/github/lambdaisland/webstuff"}}}

:cssparser
Expand Down
60 changes: 59 additions & 1 deletion repl_sessions/poke.clj
Original file line number Diff line number Diff line change
@@ -1,13 +1,71 @@
(ns poke
(:require [lambdaisland.ornament :as o]))
(:require
[lambdaisland.ornament :as o]
[lambdaisland.hiccup :as hiccup]))

(set! *print-namespace-maps* false)

(o/defstyled freebies-link :a
{:font-size "1rem"
:color "#cff9cf"
:text-decoration "underline"})

(o/rules freebies-link)

(freebies-link {:href "/episodes/interceptors-concepts"} "hello")

[:a {:class ["poke__freebies_link"]
:href "/episodes/interceptors-concepts"} "hello"]

(o/defstyled foo :div
{:margin size-2})
(o/css foo)
(o/defprop size-2 "2rem")
(o/defrules main-styles
"Main application styles"
[:.link {:color "blue"}]
[:.link:visited {:color "purple"}]
[:main
[:.container {:width size-2}]])

(garden.compiler/expand size-2)
main-styles
(o/defutil square {:aspect-ratio 1})
o/props-registry
(o/defined-garden)
(o/defined-styles)
(o/defstyled avatar :img
{size-2 size-2}
#_#_(garden.stylesheet/at-media {"print" true} [:& {:color "blue"}])
(garden.stylesheet/at-keyframes "myanim" [:100% {:height "10px"}])
)
(#'garden.compiler/expand-stylesheet {size-2 size-2})
(garden.compiler/compile-css [:& {size-2 size-2}])

(hiccup/render [avatar {:style {size-2 "3rem"}}])
(map class (o/process-rules
(o/rules avatar)))
duration |
easing-function |
delay |
iteration-count |
direction |
fill-mode |
play-state |
name

(o/defanimation pulse
:duration
"2s"
:keyframes
["0%" "100%" {:opacity 1}]
["50%" {:opacity 0.5}])

(o/css avatar)

*e
(o/defined-styles)

(hiccup/render [:div {:class [square]}])

()
Loading

0 comments on commit 654ca6f

Please sign in to comment.