Created
July 8, 2017 19:10
-
-
Save wildermuthn/d2140cac62ee91dada53a6ebc0ce33e8 to your computer and use it in GitHub Desktop.
using ganymede with reagent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns client.tool-defs.log.core | |
(:require [client.tool-defs.log.elements :as el] | |
[client.widgets.form.core :refer [fdiv row pair header hr label | |
icon]] | |
[reagent.core :as r]) | |
(:require-macros [ganymede.macros :refer [div]])) | |
(defn log-item | |
[opened-items data odd-i?] | |
(let [{:keys [nmsp msg line uuid level timestamp]} data | |
opened? (get @opened-items uuid)] | |
[el/log-item-div | |
{:style (when odd-i? {:background-color "#eee"}) | |
:title timestamp} | |
[el/top-row | |
{:on-click #(swap! opened-items update uuid not)} | |
[icon {:style {:margin-right "0px" :color "black" :font-size "21px" | |
:transform (when-not opened? "rotate(270deg)")}} | |
:arrow_drop_down] | |
[el/message msg] | |
[el/rhs (str nmsp " (" line ")")]] | |
(when opened? | |
[el/bottom-section | |
{:style {"WebkitUserSelect" "auto"}} | |
[el/bottom-line (str msg)] | |
[el/bottom-line (str "level: " level)] | |
[el/bottom-line (str "time: " timestamp)] | |
[el/bottom-line (str "namespace: " nmsp)] | |
[el/bottom-line (str "line: " line)]])])) | |
(defn render | |
[_ ui-handler] | |
(let [opened-items (r/atom {})] | |
(fn [state ui-handler] | |
(let [items (or (:items state) [])] | |
[el/container | |
[el/header-container | |
[header "Application Log"] | |
[el/clear-button {:on-click #(ui-handler :log.clear-items.button.click {})} "Clear"]] | |
(into [el/log-display] | |
(map (fn [i o?] | |
[log-item opened-items i o?]) | |
items | |
(cycle [true false])))])))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment