status-im / status-fiddle

Online UI editor for status-react
10 stars 9 forks source link

Second try #3. WIP #6

Closed ghost closed 6 years ago

ghost commented 6 years ago

Fixes #3 status: wip

Just showing the progress. I need the your opinions Going to refactor many things here.

flexsurfer commented 6 years ago

hey @poiga thanks for your effort, this is the right direction :) is it possible to decrease number of assets and files, do we really need all these js and css files?

ghost commented 6 years ago

@flexsurfer Please try now. All should be good except styling of the divs.

flexsurfer commented 6 years ago

thanks @poiga that's exactly what we need, let's just do something like

(defn main-panel []
  [react/view {:style {:flex-direction :row :padding-vertical 50}}
   [react/view {:style {:flex 1 :padding-horizontal 50}}
    [code-mirror]]
   [react/view {:style {:flex 1 :padding-horizontal 50}}
    [dom-pane]]])

and we need two more things in this PR 1) errors handling, because now it crashes if enter something like

[:h1 "Hello World!"
  []]

2) and react-native-web support, it should be possible to enter react/view in editor

Thanks!

flexsurfer commented 6 years ago

@poiga for 2 you just need to add [status-fiddle.react-native-web :as react]

(str "(ns cljs.user
                    (:refer-clojure :exclude [atom])
                    (:require reagent.core [status-fiddle.react-native-web :as react]))

                  (def atom reagent.core/atom)"
                    (or (not-empty cljs-string)
                        "[:div]"))
flexsurfer commented 6 years ago

@poiga please share your thoughts about 1. errors handling, i think we could try on change before dispatch event , render first in some test div to do not crash our app, and if it rendered without errors we could dispatch event to render our reagent form, what do you think?

ghost commented 6 years ago

@flexsurfer I am investigating this problem at the moment. I may try your approach as well.

flexsurfer commented 6 years ago

ok, thanks @poiga , no rush, just my thoughts, let's find better way

ghost commented 6 years ago

@flexsurfer I got an idea to use same assertions as Hiccup uses before rendering.

ghost commented 6 years ago

@flexsurfer please check now!

flexsurfer commented 6 years ago

@poiga can we render the previous valid view and show warning text under form? so the idea while you typing code we should see previous valid render and warning text if current code can't be rendered, thanks

flexsurfer commented 6 years ago

@poiga and also you forgot main thing :) initialize parinfer (.init js/parinferCodeMirror cm)

flexsurfer commented 6 years ago

@poiga still crashes if type something like ["test test"] with space or ["test!"]

ghost commented 6 years ago

@flexsurfer please check now!

flexsurfer commented 6 years ago

@poiga react ns doesn't work anymore, i mean [react/view] not valid because this (not (keyword? (nth vec 0 nil))) false

ghost commented 6 years ago

@flexsurfer please check now!

flexsurfer commented 6 years ago

thanks for your effort @poiga , i think we're done!