Skip to content

Commit

Permalink
deduce linked badge
Browse files Browse the repository at this point in the history
  • Loading branch information
niquola committed Aug 31, 2023
1 parent 7b7fa19 commit 4a56970
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
27 changes: 17 additions & 10 deletions src/zd/view/doc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
[:div (pr-str d)]])]))


(defmethod methods/renderann :link-badge
[ztx ctx {data :data k :key}]
(defn link-badge [k data]
[:div {:class (c :border [:m 1] :inline-flex :rounded [:p 0])}
[:a {:href data
:target "_blank"
Expand All @@ -77,15 +76,23 @@
{:font-weight "400" :border-radius "4px 0 0 4px"})}
k]])

(defmethod methods/renderann :link-badge
[ztx ctx {data :data k :key}]
(link-badge k data))

(defmethod methods/renderann :badge
[ztx ctx {key :key :as block}]
[:div {:class (c :border [:my 1] [:mr 2] :inline-flex :items-center :rounded :shadow-sm)}
[:div {:class (c :inline-block [:px 2] [:bg :gray-100] [:py 0.5] :text-sm [:text :gray-700]
:border-r
{:font-weight "400" :border-radius "4px 0 0 4px"})}
key]
[:div {:class (c [:px 1] [:py 0.5] :inline-block :text-sm)}
(methods/rendercontent ztx ctx block)]])
[ztx ctx {ann :annotations data :data key :key :as block}]
(if (and (or (nil? (:type ann)) (= :edn (:type ann)))
(string? data) (or (str/starts-with? (str/trim data) "http:")
(str/starts-with? (str/trim data) "https:")))
(link-badge key data)
[:div {:class (c :border [:my 1] [:mr 2] :inline-flex :items-center :rounded :shadow-sm)}
[:div {:class (c :inline-block [:px 2] [:bg :gray-100] [:py 0.5] :text-sm [:text :gray-700]
:border-r
{:font-weight "400" :border-radius "4px 0 0 4px"})}
key]
[:div {:class (c [:px 1] [:py 0.5] :inline-block :text-sm)}
(methods/rendercontent ztx ctx block)]]))

(defn badge [ztx ctx key data]
[:div {:class (c :border [:my 1] [:mr 2] :inline-flex :items-center :rounded :shadow-sm)}
Expand Down
6 changes: 2 additions & 4 deletions src/zd/view/errors.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
(for [[docname errors] (->> (store/errors ztx)
(sort-by #(str (first %))))]
[:div {:class (c [:py 1] [:mb 1])}
[:div {:class (c [:pt 1] [:pb 0.5] :border-b [:mb 1])}
[:b (utils/symbol-link ztx docname)]
" "
(str docname)]
[:div {:class (c :flex :items-center [:space-x 4] [:pt 1] [:pb 0.5] :border-b [:mb 1])}
(utils/symbol-link ztx docname)]
(for [e errors]
[:div {:class (c :flex [:space-x 3] :borer-b :items-baseline)}
[:div "" (str (:type e))]
Expand Down

0 comments on commit 4a56970

Please sign in to comment.