Skip to content

pink-gorilla/options

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

options GitHub Actions status |pink-gorilla/optionsClojars Project

features

  • many functions can need options that can be specified by the user
  • the idea is to define a "spec" whcih allows the ui to be generated automatically.
  • options is a map.
  • available specs are:
    • :bool
    • :string
    • :select (from a list, possibly with a name that is different to the selected value)

example

 
(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}
             ]})

 [options-ui {:class "bg-blue-300 options-debug options-label-left"
              :style {:width "80vw"}} config]])

demo

The demo uses the extension manager from goldly to add options to goldly.

cd demo
clj -X:demo:npm-install
clj -X:demo:compile
clj -X:demo

Open Browser at port 8080.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published