Skip to content

Commit

Permalink
Improve word highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
djblue committed May 12, 2023
1 parent 6ddb05e commit 6f58917
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
21 changes: 13 additions & 8 deletions src/portal/ui/viewer/date_time.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns portal.ui.viewer.date-time
(:require [clojure.spec.alpha :as s]
[portal.colors :as c]
[portal.ui.inspector :as ins]
[portal.ui.styled :as d]
[portal.ui.theme :as theme]))

Expand Down Expand Up @@ -62,17 +63,20 @@
:align-items :center}}
[d/span
{:title "Hour" :style style}
(let [hour (mod hour 12)]
(if (= hour 0) 12 hour))]
[ins/highlight-words
(str
(let [hour (mod hour 12)]
(if (= hour 0) 12 hour)))]]
[d/span {:style border} ":"]
[d/span
{:title "Minute" :style style}
(when (< minute 10) "0") minute]
[ins/highlight-words
(str (when (< minute 10) "0") minute)]]
[d/span {:style border} ":"]
[d/span
{:title "Second" :style style}
(when (< second 10) "0")
second]
[ins/highlight-words
(str (when (< second 10) "0") second)]]
[d/div {:style {:width "0.25em"}}]
[d/span
{:style keyword}
Expand All @@ -94,15 +98,16 @@
:align-items :center}}
[d/span
{:title (nth months month) :style style}
(inc month)]
[ins/highlight-words (str (inc month))]]
[d/span {:style border} "/"]
[d/span
{:title (nth days day) :style style}
(when (< date 10) "0") date]
[ins/highlight-words
(str (when (< date 10) "0") date)]]
[d/span {:style border} "/"]
[d/span
{:title "Year" :style style}
year]]))
[ins/highlight-words (str year)]]]))

(defn inspect-date-time [value]
(let [value (parse value)]
Expand Down
10 changes: 6 additions & 4 deletions src/portal/ui/viewer/exception.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@
:white-space :pre-bold
:color (::c/exception theme)
:padding [(:padding theme) (* 2 (:padding theme))]}}
(if message
message
(pr-str (:phase value type)))]
[ins/highlight-words
(if message
message
(pr-str (:phase value type)))]]
[d/div
{:style {:display :flex
:align-items :stretch
Expand All @@ -152,7 +153,8 @@
{:style {:display :flex
:align-items :center
:padding [(:padding theme) (* 2 (:padding theme))]}}
(when message (pr-str (:phase value type)))]
[ins/highlight-words
(when message (pr-str (:phase value type)))]]
(when-let [value (:runtime value)]
[d/div
{:style {:padding (:padding theme)
Expand Down
4 changes: 1 addition & 3 deletions src/portal/ui/viewer/log.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@
{:border-right [1 :solid (::c/border theme)]
:border-top-right-radius (:border-radius theme)
:border-bottom-right-radius (:border-radius theme)}))}
(:ns log)
":"
(:line log)]
[ins/highlight-words (str (:ns log) ":" (:line log))]]
(when runtime?
[d/div
{:style
Expand Down

0 comments on commit 6f58917

Please sign in to comment.