hyperfiddle-2020 icon indicating copy to clipboard operation
hyperfiddle-2020 copied to clipboard

UX: editor tabstate can be driven by fragment

Open dustingetz opened this issue 7 years ago • 2 comments

Problem is that Reagent tab wrap already hardcodes uses wrapper [:a] and you can't nest them.

Here is the change:

(defn fiddle-src-renderer [val ctx {:keys [:embed-mode] :as props}]
  (let [ctx (shadow-fiddle ctx)
        target-route (context/target-route ctx)
        selected-tab (or (get target-route 3) (:initial-tab props) :hf.src/query)]
    [:div (select-keys props [:class])
     #_(if-not embed-mode
         [:h3 "Source: " (str @(r/cursor (:hypercrud.browser/data ctx) [:fiddle/ident]))])
     ; Design constraint: one codemirror per tab, and it will expand to fill height.
     [horizontal-tabs
      ; F U recom: Validation failed: Expected 'vector of tabs | atom'. Got '[:query :links :view :css :fiddle]'
      :tabs [{:id :hf.src/query} {:id :hf.src/links} {:id :hf.src/markdown}
             {:id :hf.src/view} {:id :hf.src/css} {:id :hf.src/fiddle}]
      :id-fn :id
      :label-fn (fn [{:keys [id]}]
                  (let [root-rel-path (runtime/encode-route (:peer ctx) (router/dissoc-frag target-route))]
                    [:a {:href (str root-rel-path "#" (encode-rfc3986-pchar (encode-ednish (pr-str id))))}
                     (name id)]))
      :model selected-tab
      :on-change #()]
     [(get tabs selected-tab) val ctx {:embed-mode embed-mode}]]))

dustingetz avatar Oct 14 '18 14:10 dustingetz

It actually already is driven externally by fragment deeplink, it is just initial state only and doesn't sync after that. http://tank.hyperfiddle.net/:dustingetz!html5-video-m3u8/#:hf.src!view

dustingetz avatar Oct 14 '18 14:10 dustingetz

Pushy causes major fuckery here, it ends up hard navigating. If the pathname is omitted which i believe is legal for a page-relative hash, pushy eats the page segment and the URL ends up out of sync with the view.

image

dustingetz avatar Mar 07 '19 20:03 dustingetz