Skip to content

Commit

Permalink
Created svg-components namespace
Browse files Browse the repository at this point in the history
Create the status-monitor.svg-components namespace to contain a whole range of
SVG elements that could be used for the dashboard.  Initially just a demo image
has been created.  The demo image has been added to the status-monitor dashboard
to show how well SVG components are rendered in a web page.
  • Loading branch information
practicalli-johnny committed Sep 25, 2018
1 parent a717816 commit 427c56c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/status_monitor/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[compojure.route :as route]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
[hiccup.core :refer :all]
[hiccup.page :refer :all]))
[hiccup.page :refer :all]
[status-monitor.svg-components :as svg-components]))



Expand Down Expand Up @@ -113,7 +114,17 @@
[:p "Server memory usage:"
(component-status-bar 75)]
[:p "Durable pending messages"
(component-status-bar 92)]]]]]]))
(component-status-bar 92)]]

]

;; Testing SVG components.
[:div {:class "row"}
[:h1 "Demo"]
[:div {:class "col-md-12"}
svg-components/circle-in-a-box]
]]]]))



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
50 changes: 50 additions & 0 deletions src/status_monitor/svg_components.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
(ns status-monitor.svg-components)

;; Converting HTML SVG components into equivalent Clojure code
;; Ideally create a library of components that can be easily used
;;
;; HTML SVG specification from Mozilla
;; https://developer.mozilla.org/en-US/docs/Web/SVG/Element

;; An alternative approach would be to write a parser that
;; generated Clojure Hiccup style code from HTML SVG code.




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Demos



;; Circle in a box
(def circle-in-a-box
[:svg {:version "1.1"
:base-profile "full"
:width 300
:height 200
:xmlns "http://www.w3.org/2000/svg"}

[:rect {:width "100%"
:height "100%"
:fill "blue"}]
[:circle {:cx 150
:cy 100
:r 80
:fill "green"}]
[:text {:x 150
:y 125
:font-size 60
:text-anchor "middle"
:fill "white"}
"SVG"]])

;; <svg version="1.1"
;; baseProfile="full"
;; width="300" height="200"
;; xmlns="http://www.w3.org/2000/svg">

;; <rect width="100%" height="100%" fill="red" />
;; <circle cx="150" cy="100" r="80" fill="green" />
;; <text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text>
;; </svg>

0 comments on commit 427c56c

Please sign in to comment.