Skip to content

Commit

Permalink
add comp-tabs, comp-placeholder; alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYong committed Jun 22, 2020
1 parent 6902384 commit 8888966
Show file tree
Hide file tree
Showing 7 changed files with 1,125 additions and 16 deletions.
1,004 changes: 997 additions & 7 deletions calcit.cirru

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"author": "jiyinyiyong",
"license": "MIT",
"devDependencies": {
"shadow-cljs": "^2.9.10"
"shadow-cljs": "^2.9.12"
},
"dependencies": {}
}
2 changes: 1 addition & 1 deletion release.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{:version "0.3.14"
{:version "0.3.15-a1"
:group-id "respo"
:artifact-id "ui"
:description "Tiny collection of styles used in Respo"
Expand Down
4 changes: 2 additions & 2 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
:cache-blockers #{cumulo-util.build}
:dependencies [
[mvc-works/hsl "0.1.2"]
[mvc-works/shell-page "0.1.10"]
[respo "0.12.1"]
[mvc-works/shell-page "0.1.13-a3"]
[respo "0.12.3-a1"]
[respo/router "0.4.0"]
[respo/markdown "0.2.5"]
[cumulo/util "0.1.12"]
Expand Down
49 changes: 49 additions & 0 deletions src/respo_ui/comp.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

(ns respo-ui.comp
(:require [respo.core
:refer
[defcomp div list-> input textarea button span select option a <>]]
[respo.comp.space :refer [=<]]
[respo-ui.core :as ui]
[hsl.core :refer [hsl]]))

(defcomp
comp-placeholder
(text)
(div
{:style (merge
ui/center
{:padding 16,
:font-family ui/font-fancy,
:color (hsl 0 0 80),
:font-size 12,
:font-style :italic})}
(<> text)))

(defn comp-sidebar [] )

(defcomp
comp-tabs
(options tabs on-route)
(list->
{:style (merge
(if (:vertical? options) ui/column ui/row)
{:padding "8px 16px 0", :width (:width options)}
(:style options))}
(->> tabs
(map
(fn [info]
[(:name info)
(div
{:style (merge
{:padding "0 8px",
:font-family ui/font-fancy,
:font-weight 300,
:cursor :pointer,
:font-size 16,
:color (hsl 0 0 70),
:line-height "32px"}
(if (= (:selected options) (:name info))
{:font-weight 500, :color (hsl 0 0 30)})),
:on-click (fn [e d!] (on-route info d!))}
(<> (:title info)))])))))
76 changes: 73 additions & 3 deletions src/respo_ui/comp/components.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,74 @@

(ns respo-ui.comp.components
(:require [respo.core :refer [defcomp div a <>]] [respo.comp.space :refer [=<]]))
(:require [respo.core :refer [defcomp >> div a <> pre code]]
[respo.comp.space :refer [=<]]
[respo-ui.comp :refer [comp-tabs comp-placeholder]]
[respo-ui.core :as ui]
[hsl.core :refer [hsl]]))

(defcomp
comp-snippet
(text)
(pre
{:style {:font-size 12,
:font-family ui/font-code,
:color (hsl 0 0 40),
:line-height "18px"}}
(code {:inner-text text})))

(def style-title
{:margin-top 40, :font-size 18, :font-family ui/font-fancy, :color (hsl 0 0 70)})

(defcomp
comp-demo-placeholder
()
(div
{:style style-title}
(div {} (<> "Placeholder demo"))
(comp-placeholder "This is a demo")
(comp-placeholder "中文 Demo")
(comp-snippet
"respo-ui.comp/comp-placeholder\n\n(comp-placeholder \"demo\")\n(comp-placeholder \"中文\")")))

(defcomp
comp-demo-tabs
(states)
(let [cursor (:cursor states)
state (or (:data states) {:selected nil})
en-tabs [{:name :book, :title "Book"}
{:name :card, :title "Card"}
{:name :pl, :title "Programming language"}]]
(div
{}
(div {:style style-title} (<> "Tabs demo"))
(comp-tabs
{:selected (:selected state)}
en-tabs
(fn [info d!]
(println "selected" info)
(d! cursor (assoc state :selected (:name info)))))
(comp-tabs
{:selected (:selected state)}
[{:name :book, :title "书本"} {:name :card, :title "纸牌"} {:name :pl, :title "编程语言"}]
(fn [info d!]
(println "selected" info)
(d! cursor (assoc state :selected (:name info)))))
(comp-tabs
{:selected (:selected state), :style {:border-bottom (str "1px solid " (hsl 0 0 90))}}
en-tabs
(fn [info d!]
(println "selected" info)
(d! cursor (assoc state :selected (:name info)))))
(comp-snippet
"respo-ui.comp/comp-tabs\n\n(comp-tabs\n {:selected (:selected state) :style {}}\n [{:name :book, :title \"Book\"}\n {:name :card, :title \"Card\"}\n {:name :pl, :title \"Programming language\"}]\n (fn [info d!]\n (println \"selected\" info)\n (d! cursor (assoc state :selected (:name info)))))")
(comp-tabs
{:selected (:selected state), :vertical? true, :width 200, :style {}}
en-tabs
(fn [info d!]
(println "selected" info)
(d! cursor (assoc state :selected (:name info)))))
(comp-snippet
"respo-ui.comp/comp-tabs\n\n(comp-tabs\n {:selected (:selected state) :style {}, :vertical? true, :width 200}\n tabs (fn [info d!]))"))))

(defn render-entry [url title] (div {} (a {:href url, :inner-text title})))

Expand All @@ -9,7 +77,7 @@
(states)
(let [state (or (:data states) false)]
(div
{}
{:style {:padding-bottom "50vh"}}
(div
{}
(<> "There are also components follow the guidelines of Respo UI:")
Expand All @@ -26,4 +94,6 @@
(a
{:href "https://github.com/Respo/respo-ui/blob/master/src/respo_ui/comp/components.cljs",
:target "_blank",
:inner-text "Source"})))))
:inner-text "Source"}))
(comp-demo-placeholder)
(comp-demo-tabs (>> states :tabs)))))
4 changes: 2 additions & 2 deletions src/respo_ui/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(merge
base-info
{:styles [(<< "http://~(get-ip!):8100/main.css") "/entry/main.css"],
:scripts ["/client.js"],
:scripts [{:src "/client.js", :defer? true}],
:inline-styles []})))

(def page-routes
Expand All @@ -38,7 +38,7 @@
(merge
base-info
{:styles [(:release-ui config/site)],
:scripts (map #(-> % :output-name prefix-cdn) assets),
:scripts (map #({:src (-> % :output-name prefix-cdn), :defer? true}) assets),
:ssr "respo-ssr",
:inline-styles [(slurp "./entry/main.css")]}))))

Expand Down

0 comments on commit 8888966

Please sign in to comment.