Skip to content

Commit

Permalink
update libraries (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
oakmac authored Feb 20, 2023
1 parent 93e0b6e commit a352933
Show file tree
Hide file tree
Showing 6 changed files with 640 additions and 632 deletions.
8 changes: 4 additions & 4 deletions cljs-client/cljs_cheatsheet_client/dom.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
(defn get-element-box [el]
(let [$el ($ el)
o (.offset $el)
x (oget o "left")
y (oget o "top")
height (ocall $el "outerHeight")
width (ocall $el "outerWidth")]
x (js/parseFloat (oget o "left"))
y (js/parseFloat (oget o "top"))
height (js/parseFloat (ocall $el "outerHeight"))
width (js/parseFloat (ocall $el "outerWidth"))]
{:x1 x
:x2 (+ x width)
:y1 y
Expand Down
35 changes: 19 additions & 16 deletions cljs-client/cljs_cheatsheet_client/html.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[hiccups.core :as hiccups])
(:require
hiccups.runtime
[clojure.string :refer [blank?]]
[clojure.string :as str]
[cljs-cheatsheet.util :refer [docs-href js-log log]]
[cljs-cheatsheet-client.util :refer [extract-namespace extract-symbol split-full-name]]))

Expand All @@ -18,36 +18,37 @@
(str "code-b64c8 "
(if (even? idx) "dark-even-7aff7" "dark-odd-6cd97")))

(hiccups/defhtml code-signature [idx sig nme]
(defn CodeSignature [idx sig nme]
(let [len (count sig)
sig2 (subs sig 1 (dec len))]
[:code {:class (code-signature-class idx)}
"(" (html-encode nme)
(when-not (blank? sig2) (str " " (html-encode sig2)))
"(" nme
(when-not (str/blank? sig2)
(str " " sig2))
")"]))

(hiccups/defhtml related-fn-link [s]
(defn RelatedFnLink [s]
[:a.related-link-674b6
{:data-full-name (:full-name s)
:href (docs-href (:symbol s) (:namespace s))}
(html-encode (:symbol s))])
(:symbol s)])

(hiccups/defhtml related-links-for-ns [ns1 all-related]
(defn RelatedLinksForNs [ns1 all-related]
(let [filtered-related (filter #(= (:namespace %) ns1) all-related)]
(list
(when-not (= ns1 cljs-core-ns)
[:span.tt-literal-3cdfc "(" ns1 "/)"])
(map related-fn-link filtered-related))))
(map RelatedFnLink filtered-related))))

(hiccups/defhtml related-links [r]
(defn RelatedLinks [r]
(let [r2 (map split-full-name r)
namespaces (distinct (map :namespace r2))]
(list
[:h5.related-hdr-915e5 "Related"]
[:div.related-links-f8e49
(map #(related-links-for-ns % r2) namespaces)])))
(map #(RelatedLinksForNs % r2) namespaces)])))

(hiccups/defhtml inline-tooltip [tt]
(hiccups/defhtml InlineTooltip [tt]
(let [desc-html (:description-html tt)
id (:id tt)
full-name (:full-name tt)
Expand All @@ -62,10 +63,12 @@
[:h4.tooltip-hdr-db7c5
(when-not (= cljs-core-ns ns1)
[:span.namespace-2e700 ns1 "/"])
(html-encode symbol-name)
symbol-name
(when type [:span.type-7920d type])]
[:div.signature-4086a
(map-indexed #(code-signature %1 %2 symbol-name) signature)]
[:div.description-26a4d desc-html]
(when (and related (first related) (not (blank? (first related))))
(related-links related))]))
(map-indexed #(CodeSignature %1 %2 symbol-name) signature)]
[:div
{:dangerously-set-inner-HTML
{:__html (str "<div class='description-26a4d'>" desc-html "</div>")}}]
(when (and related (first related) (not (str/blank? (first related))))
(RelatedLinks related))]))
4 changes: 2 additions & 2 deletions cljs-client/cljs_cheatsheet_client/tooltips.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns cljs-cheatsheet-client.tooltips
(:require
[cljs-cheatsheet-client.html :refer [inline-tooltip]]
[cljs-cheatsheet-client.html :refer [InlineTooltip]]
[cljs-cheatsheet-client.state :refer [active-tooltip mouse-position mousetrap-boxes]]
[cljs-cheatsheet-client.util :refer [fetch-clj half point-inside-box?]]
[cljs-cheatsheet.util :refer [js-log log]]
Expand All @@ -24,7 +24,7 @@
;;------------------------------------------------------------------------------

(defn- create-inline-tooltip! [tt]
(.append ($ "body") (inline-tooltip tt)))
(.append ($ "body") (InlineTooltip tt)))

;;------------------------------------------------------------------------------
;; Hide and Show
Expand Down
Loading

0 comments on commit a352933

Please sign in to comment.