Fork me on GitHub
#reveal
<
2021-02-27
>
vlaaad11:02:40

If anyone's curious what I've been up to, I'm prototyping "spec forms" — form builder that helps to create values according to spec. 2 main problems I'm trying to solve here is teaching the expected data shape and streamlined creation of data that can then be immediately passed somewhere to see the results of this data. Imagine converting vega json schema to spec and then getting UI builder to create and see vega visualizations immediately! So far I'm not happy with the results: I want to show both data shape and spec hints like names/predicates, and it looks quite messy. The search goes on...

metal 9
👀 6
phronmophobic01:02:53

At some point I was working on a similar concept. It worked ok, but I stopped work on it since I wanted to editor to run in the browser, but the mechanism relied on being able to produce and eval code which is a real pain to do with cljs. My approach was slightly different. I built a handful of different types of editors: • text area • number slider • toggle • counter • key-value editor • List editor • Label (no editing, just display the value) • etc Editors could be composed. For example, a key-value editor could be composed of labels (for keys) and number sliders (for numeric values). Each editor could return whether it could edit a value produced by a given spec. Each editor could also provide extra options for configuration (eg. the key-value editor had options for its layout). I used https://github.com/stathissideris/spec-provider so that I could generate specs from example data. I also implemented a function that given a spec, would use heuristics to try and create what it thought would be the most appropriate editor. I even had an editor-editor so that you could tweak the editor that was produced heuristically.

(start-form-builder {:x 2,
                       :y 10,
                       :data ":/gamedata/enemies/test-enemy.json",
                       :character
                       {:role "Enemy",
                        :wisdom 10,
                        :weapon "",
                        :firearm "",
                        :experience 100,
                        :mana 10,
                        :inventory
                        [{:data ":/gamedata/items/plants/healing-herb.json", :count 2}
                         {:data ":/gamedata/items/weapons/sword.json", :count 2}],
                        :strength 10,
                        :healthMax 200,
                        :manaMax 10,
                        :health 200,
                        :gender "male",
                        :stealth 0}})
The example form is below. There's also the editor-editor which is super ugly, but would let you tweak the produced form.

vlaaad15:02:36

Nice! Fortunately, in clj there are no restrictions on code evaluation, so spec forms can fully work with all the validation

toot 3