-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
awb99
committed
Oct 20, 2023
1 parent
68a81e1
commit cb71564
Showing
6 changed files
with
173 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,103 @@ | ||
(ns demo.page.options | ||
(:require | ||
[reagent.core :as r] | ||
[options.core :refer [options-ui]])) | ||
|
||
(def state (r/atom {})) | ||
|
||
(def config | ||
{:state state | ||
:current {; select | ||
:year 2023 | ||
:client 2 | ||
:pet :hamster | ||
; bool | ||
:run-parallel true | ||
:debug? false | ||
; string | ||
:search "" | ||
; view | ||
:msg "hello!"} | ||
:options [{:path :year | ||
:name "Year" | ||
:spec (range 2018 2024)} | ||
{:path :client | ||
:name "Client" | ||
:spec [{:id 1 :name "Batman"} | ||
{:id 2 :name "Robin"} | ||
{:id 3 :name "Harry Potter"} | ||
{:id 4 :name "Dumbledor"} | ||
{:id 5 :name "The Hulk"}] | ||
:class "placeholder-gray-400 text-gray-700 relative bg-white rounded text-sm border border-gray-400 outline-none focus:outline-none focus:shadow-outline"} | ||
{:path :pet | ||
:name "Pet" | ||
:spec [:cat :dog :parrot :hamster] | ||
:class "placeholder-gray-400 text-gray-700 relative bg-white rounded text-sm border border-gray-400 outline-none focus:outline-none focus:shadow-outline"} | ||
|
||
{:path :run-parallel | ||
:name "RunParallel?" | ||
:spec :bool | ||
:class "pt-0 px-2 py-1 placeholder-gray-400 text-gray-700 relative bg-white rounded text-sm border border-gray-400 outline-none focus:outline-none focus:shadow-outline"} | ||
{:path :debug? | ||
:name "DebugMode" | ||
:spec :bool} | ||
{:path :search | ||
:name "SearchBox" | ||
:spec :string | ||
:class "px-2 py-1 placeholder-gray-400 text-gray-700 relative bg-white bg-white rounded text-sm border border-gray-400 outline-none focus:outline-none focus:shadow-outline"} | ||
{:name "Go!" | ||
:spec :button | ||
:class "bg-blue-500 hover:bg-blue-700 text-white font-bold rounded" ; py-2 px-4 | ||
:on-click #(js/alert "yeah!")} | ||
|
||
{:name "view" | ||
:spec :view | ||
:path :msg | ||
} | ||
{:name "bad" | ||
:spec :view2} | ||
]}) | ||
|
||
|
||
(defn h1 [s] | ||
[:<> | ||
[:hr] | ||
[:br] | ||
[:h1 {:class "pt-5 pb-5 text-xl text-bold text-blue-700"} s]]) | ||
|
||
(defn page-options [_] | ||
[:div.grid.grid-cols-2 | ||
|
||
[options-ui {:class "bg-blue-300 grid grid-cols-2" | ||
:style {;:width "50vw" | ||
;:height "40vh" | ||
:border "3px solid green"}} | ||
{:current {; select | ||
:year 2023 | ||
:client 2 | ||
:pet :hamster | ||
; bool | ||
:run-parallel true | ||
:debug? false | ||
; string | ||
:search ""} | ||
:options {:year {:name "Year" | ||
:spec (range 2018 2024)} | ||
:client {:name "Client" | ||
:spec [{:id 1 :name "Batman"} | ||
{:id 2 :name "Robin"} | ||
{:id 3 :name "Harry Potter"} | ||
{:id 4 :name "Dumbledor"} | ||
{:id 5 :name "The Hulk"}] | ||
:class "placeholder-gray-400 text-gray-700 relative bg-white rounded text-sm border border-gray-400 outline-none focus:outline-none focus:shadow-outline"} | ||
:pet {:name "Pet" | ||
:spec [:cat :dog :parrot :hamster] | ||
:class "placeholder-gray-400 text-gray-700 relative bg-white rounded text-sm border border-gray-400 outline-none focus:outline-none focus:shadow-outline"} | ||
|
||
:run-parallel {:name "Run in Parallel?" | ||
:spec :bool | ||
:class "pt-0 px-2 py-1 placeholder-gray-400 text-gray-700 relative bg-white rounded text-sm border border-gray-400 outline-none focus:outline-none focus:shadow-outline"} | ||
:debug? {:name "Debug Mode" | ||
:spec :bool} | ||
:search {:name "SearchBox" | ||
:spec :string | ||
:class "px-2 py-1 placeholder-gray-400 text-gray-700 relative bg-white bg-white rounded text-sm border border-gray-400 outline-none focus:outline-none focus:shadow-outline"}}}]]) | ||
[:div | ||
|
||
[h1 "state"] | ||
[:div (pr-str @state)] | ||
|
||
[h1 "unstyled"] | ||
[options-ui {:class "bg-blue-300 options-debug" | ||
:style {:width "50vw" | ||
;:height "40vh" | ||
}}config] | ||
|
||
[h1 "label-top"] | ||
[options-ui {:class "bg-blue-300 options-debug options-label-top" | ||
:style {:width "50vw" | ||
;:height "40vh" | ||
}}config] | ||
|
||
[h1 "label-left"] | ||
[options-ui {:class "bg-blue-300 options-debug options-label-left" | ||
:style {:width "50vw" | ||
;:height "40vh" | ||
}}config] | ||
|
||
[h1 "label-left-small"] | ||
[options-ui {:class "bg-blue-300 options-debug options-label-left" | ||
:style {:width "20vw" | ||
;:height "40vh" | ||
}}config] | ||
|
||
[h1 "label-left-big"] | ||
[options-ui {:class "bg-blue-300 options-debug options-label-left" | ||
:style {:width "80vw" | ||
;:height "40vh" | ||
}}config]]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
.options-label-top { | ||
display: grid; | ||
gap: "1rem"; | ||
grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); | ||
grid-template-rows: 20px 20px repeat(auto-fill, 20px); | ||
grid-auto-flow: column; | ||
/* overflow-x: scroll; scroll does not look nice */ | ||
overflow-x: hidden; | ||
} | ||
|
||
.options-label-left { | ||
display: grid; | ||
gap: "1rem"; | ||
grid-template-columns: repeat(auto-fit, 100px 200px ); /* minmax(200px,1fr) */ | ||
grid-template-rows: repeat(auto-fill, 30px); | ||
grid-auto-flow: row; | ||
|
||
} | ||
|
||
|
||
.options-debug { | ||
border: 3px solid green; | ||
background-color: tomato; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(ns options.editor.button) | ||
|
||
; for ideas for props for button look at: | ||
; https://github.com/knipferrc/tails-ui/blob/master/src/components/Button.re | ||
|
||
(defn editor-button [{:keys [_set-fn options]} _current-val] | ||
(let [{:keys [class style name on-click] | ||
:or {class "" | ||
name "" | ||
style {}}} options] | ||
[:button | ||
{:class class | ||
:style style | ||
:on-click (fn [_ & _] | ||
(when on-click | ||
(on-click)))} | ||
name])) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
(ns options.editor.view) | ||
|
||
(defn editor-view [{:keys [set-fn options]} current-val] | ||
(let [{:keys [class] :or {class ""}} options] | ||
[:span {:class class} current-val])) | ||
(defn editor-view [{:keys [options]} current-val] | ||
(let [{:keys [class] | ||
:or {class ""}} | ||
options] | ||
[:span {:class class} (pr-str current-val)])) |