Skip to content

Commit 1237400

Browse files
committed
feat(dashboard): adds draft for query top components
1 parent 9af62bd commit 1237400

File tree

4 files changed

+157
-0
lines changed

4 files changed

+157
-0
lines changed

:w

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
(ns codes.clj.docs.frontend.components.query
2+
(:require ["@mantine/core" :refer [Alert Grid Group LoadingOverlay SimpleGrid
3+
Text Title Indicator Avatar Anchor]]
4+
["@tabler/icons-react" :refer [IconInfoCircle]]
5+
[codes.clj.docs.frontend.infra.helix :refer [defnc]]
6+
[helix.core :refer [$]]))
7+
8+
(defnc latest-interactions [{:keys [value loading? error]}]
9+
($ SimpleGrid {:cols 1}
10+
($ Title {:order 1} "Recently Updated")
11+
12+
(if error
13+
($ Alert {:variant "light" :color "red" :radius "md" :title "Error" :icon ($ IconInfoCircle)}
14+
(str error))
15+
16+
($ Group {:pos "relative"}
17+
($ LoadingOverlay {:visible loading? :zIndex 1000 :overlayProps #js {:radius "sm" :blur 2}})
18+
($ SimpleGrid {:cols 2}
19+
($ Text "Top Authors"))))))
20+
21+
(defnc top-author [{:keys [value loading? error]}]
22+
($ SimpleGrid {:cols 1}
23+
($ Title {:order 1} "Top Authors")
24+
25+
(if error
26+
($ Alert {:variant "light" :color "red" :radius "md" :title "Error" :icon ($ IconInfoCircle)}
27+
(str error))
28+
29+
($ Group {:pos "relative"}
30+
($ LoadingOverlay {:visible loading? :zIndex 1000 :overlayProps #js {:radius "sm" :blur 2}})
31+
($ Grid {:grow false :gutter "md"}
32+
(map
33+
(fn [{:keys [author-id login account-source interactions avatar-url]}]
34+
($ (.-Col Grid) {:key (str "avatar" author-id)
35+
:span 2}
36+
($ Indicator {:inline true :label interactions :size 16}
37+
($ Anchor {:href (str "/author/" login "/" account-source)}
38+
($ Avatar {:size "md" :src avatar-url})))))
39+
value))))))
40+
41+
; <Indicator inline label="New" size={16}>
42+
; <Avatar
43+
; size="lg"
44+
; radius="sm"
45+
; src="https://raw.githubusercontent.com/mantinedev/mantine/master/.demo/avatars/avatar-2.png"
46+
; />
47+
; </Indicator>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
(ns codes.clj.docs.frontend.components.query
2+
(:require ["@mantine/core" :refer [Alert Anchor Avatar Grid Group Indicator
3+
LoadingOverlay SimpleGrid Text Title
4+
Tooltip]]
5+
["@tabler/icons-react" :refer [IconInfoCircle]]
6+
[codes.clj.docs.frontend.infra.helix :refer [defnc]]
7+
[helix.core :refer [$]]
8+
[helix.dom :as dom]))
9+
10+
(defnc latest-interactions [{:keys [value loading? error]}]
11+
($ SimpleGrid {:cols 1}
12+
($ Title {:order 1} "Recently Updated")
13+
14+
(if error
15+
($ Alert {:variant "light" :color "red" :radius "md" :title "Error" :icon ($ IconInfoCircle)}
16+
(str error))
17+
18+
($ Group {:pos "relative" :grow true}
19+
($ LoadingOverlay {:visible loading? :zIndex 1000 :overlayProps #js {:radius "sm" :blur 2}})
20+
($ SimpleGrid {:cols 2}
21+
(map
22+
(fn [{:keys [author]}]
23+
(let [{:keys [author-id login account-source avatar-url]} author]
24+
($ Group {:key (str "latest" author-id) :grow true}
25+
($ Anchor {:href (str "/author/" login "/" account-source)}
26+
($ Avatar {:size "md" :src avatar-url}))
27+
28+
(dom/div
29+
($ Text "banana")))))
30+
31+
value))))))
32+
33+
; <UnstyledButton className={classes.user}>
34+
; <Group>
35+
; <Avatar
36+
; src="https://raw.githubusercontent.com/mantinedev/mantine/master/.demo/avatars/avatar-8.png"
37+
; radius="xl"
38+
; />
39+
;
40+
; <div style={{ flex: 1 }}>
41+
; <Text size="sm" fw={500}>
42+
; Harriette Spoonlicker
43+
; </Text>
44+
;
45+
; <Text c="dimmed" size="xs">
46+
47+
; </Text>
48+
; </div>
49+
;
50+
; <IconChevronRight style={{ width: rem(14), height: rem(14) }} stroke={1.5} />
51+
; </Group>
52+
; </UnstyledButton>
53+
54+
(defnc top-author [{:keys [value loading? error]}]
55+
($ SimpleGrid {:cols 1}
56+
($ Title {:order 1} "Top Authors")
57+
58+
(if error
59+
($ Alert {:variant "light" :color "red" :radius "md" :title "Error" :icon ($ IconInfoCircle)}
60+
(str error))
61+
62+
($ Group {:pos "relative"}
63+
($ LoadingOverlay {:visible loading? :zIndex 1000 :overlayProps #js {:radius "sm" :blur 2}})
64+
($ Grid {:grow false :gutter "lg"}
65+
(map
66+
(fn [{:keys [author-id login account-source interactions avatar-url]}]
67+
($ (.-Col Grid) {:key (str "top" author-id)
68+
:span "lg"}
69+
($ Indicator {:withBorder true :inline true :label interactions :size 16 :position "bottom-end"}
70+
($ Anchor {:href (str "/author/" login "/" account-source)}
71+
($ Tooltip {:label (str login " with " interactions " interactions")
72+
:withArrow true}
73+
($ Avatar {:size "md" :src avatar-url}))))))
74+
value))))))
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(ns codes.clj.docs.frontend.panels.dashboards.view
2+
(:require ["@mantine/core" :refer [Container Space]]
3+
[codes.clj.docs.frontend.components.query :as components.query]
4+
[codes.clj.docs.frontend.infra.helix :refer [defnc]]
5+
[helix.core :refer [$]]))
6+
7+
(def latest-interactions [{:see-also-id #uuid "6e7aa601-1ce6-4801-83a3-5bbad76084d0", :definition-id "org.clojure/clojure/clojure.core/contains?/0", :definition-id-to "org.clojure/clojure/clojure.string/includes?/0", :created-at #inst "2024-05-03T21:59:49.844695000-00:00", :author {:author-id #uuid "b58e81a2-3647-4c71-aa4f-1499cff15c59", :login "strobelt", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/669994?v=4", :created-at #inst "2024-05-03T21:43:23.766762000-00:00"}} {:example-id #uuid "14f2c72d-e0b3-466d-bd69-8dfdf7bb4bff", :definition-id "org.clojure/clojure/clojure.core/contains?/0", :body ";; contains? looks for keys in a map and not values in a sequence\n;; so this works as expected\n(contains? {:a 1} :a) ;=> true\n\n;; but this doesn't\n(contains? [:a :b :c] :b) ;=> false\n(contains? \"Clojure is awesome\" \"awesome\") ;=> false\n\n;; For strings you can use clojure.string/includes?\n(clojure.string/includes? \"Clojure is awesome\" \"awesome\") ;=> true\n\n;; And for vectors you can use java's .indexOf\n(.indexOf [:a :b :c] :b) ;=> 1", :created-at #inst "2024-05-03T21:59:38.985240000-00:00", :author {:author-id #uuid "b58e81a2-3647-4c71-aa4f-1499cff15c59", :login "strobelt", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/669994?v=4", :created-at #inst "2024-05-03T21:43:23.766762000-00:00"}, :editors [{:author-id #uuid "b58e81a2-3647-4c71-aa4f-1499cff15c59", :login "strobelt", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/669994?v=4", :created-at #inst "2024-05-03T21:43:23.766762000-00:00", :edited-at #inst "2024-05-03T21:59:38.985240000-00:00"}]} {:example-id #uuid "c9e76ca3-f41c-4846-9d7b-e563fd79dc45", :definition-id "org.clojure/clojure/clojure.core/defmulti/0", :body ";; Define the multimethod\n(defmulti my-test\n (fn [param1 param2] {:param1 param1 :param2 param2}))\n\n;; Defining handlers/implementation for resulting dispatch values \n(s/defmethod my-test {:param1 :something\n :param2 :something-else}\n [param1 :- s/Keyword\n param2 :- s/Keyword]\n (+ 3 4))\n\n(s/defmethod my-test {:param1 :this\n :param2 :that}\n [param1 :- s/Keyword\n param2 :- s/Keyword]\n (+ 4 5))\n\n(s/defmethod my-test :default\n [param1 :- s/Keyword\n param2 :- s/Keyword]\n \"ERROR\")\n\n;; Invoking it\n(my-test :something :something-else)\n;; => 7\n\n(my-test :something :undefined)\n;; Should go do the default because no other implementation was found, return \n;; => \"ERROR\"\n", :created-at #inst "2024-04-03T20:17:11.131558000-00:00", :author {:author-id #uuid "05c01718-00b0-4ebe-a28b-280cd1be9a31", :login "kroncatti", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/56690659?v=4", :created-at #inst "2024-03-25T16:07:54.244916000-00:00"}, :editors [{:author-id #uuid "05c01718-00b0-4ebe-a28b-280cd1be9a31", :login "kroncatti", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/56690659?v=4", :created-at #inst "2024-03-25T16:07:54.244916000-00:00", :edited-at #inst "2024-04-03T20:12:24.936298000-00:00"} {:author-id #uuid "05c01718-00b0-4ebe-a28b-280cd1be9a31", :login "kroncatti", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/56690659?v=4", :created-at #inst "2024-03-25T16:07:54.244916000-00:00", :edited-at #inst "2024-04-03T20:17:11.131558000-00:00"}]} {:see-also-id #uuid "8d18bf94-195e-4459-81ad-f3a0fcb2b85d", :definition-id "org.clojure/clojure/clojure.core/take/0", :definition-id-to "org.clojure/clojure/clojure.core/repeatedly/0", :created-at #inst "2024-03-28T15:37:09.314558000-00:00", :author {:author-id #uuid "36a91f13-2cf9-4b80-a9f0-619b5dbe6ec5", :login "rafaeldelboni", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/1683898?v=4", :created-at #inst "2024-03-11T14:16:54.404609000-00:00"}} {:example-id #uuid "dcaccd23-50fe-4a10-a66b-611fc4e776d5", :definition-id "org.clojure/clojure/clojure.core/take/0", :body "; 6 random integers (from 0 to 60)\n(take 6 (repeatedly #(rand-int 60)))", :created-at #inst "2024-03-28T15:36:49.571386000-00:00", :author {:author-id #uuid "36a91f13-2cf9-4b80-a9f0-619b5dbe6ec5", :login "rafaeldelboni", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/1683898?v=4", :created-at #inst "2024-03-11T14:16:54.404609000-00:00"}, :editors [{:author-id #uuid "36a91f13-2cf9-4b80-a9f0-619b5dbe6ec5", :login "rafaeldelboni", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/1683898?v=4", :created-at #inst "2024-03-11T14:16:54.404609000-00:00", :edited-at #inst "2024-03-28T15:36:49.571386000-00:00"}]} {:see-also-id #uuid "3daba272-d969-4e55-92f4-052c7ce64a64", :definition-id "org.clojure/clojure/clojure.core/remove/0", :definition-id-to "org.clojure/clojure/clojure.core/keep/0", :created-at #inst "2024-03-27T11:43:50.674432000-00:00", :author {:author-id #uuid "36a91f13-2cf9-4b80-a9f0-619b5dbe6ec5", :login "rafaeldelboni", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/1683898?v=4", :created-at #inst "2024-03-11T14:16:54.404609000-00:00"}} {:see-also-id #uuid "2657682d-fb87-4b71-807d-9ba86c9160ba", :definition-id "org.clojure/clojure/clojure.core/keep/0", :definition-id-to "org.clojure/clojure/clojure.core/remove/0", :created-at #inst "2024-03-27T11:43:32.582037000-00:00", :author {:author-id #uuid "36a91f13-2cf9-4b80-a9f0-619b5dbe6ec5", :login "rafaeldelboni", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/1683898?v=4", :created-at #inst "2024-03-11T14:16:54.404609000-00:00"}} {:example-id #uuid "2a0253a8-6edf-4f94-9b63-c9f558064c55", :definition-id "org.clojure/clojure/clojure.core/keep/0", :body "; removes nil from list or vector\n(keep identity [:a :b nil :d nil :f])\n; => (:a :b :d :f)", :created-at #inst "2024-03-27T11:41:57.364949000-00:00", :author {:author-id #uuid "36a91f13-2cf9-4b80-a9f0-619b5dbe6ec5", :login "rafaeldelboni", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/1683898?v=4", :created-at #inst "2024-03-11T14:16:54.404609000-00:00"}, :editors [{:author-id #uuid "36a91f13-2cf9-4b80-a9f0-619b5dbe6ec5", :login "rafaeldelboni", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/1683898?v=4", :created-at #inst "2024-03-11T14:16:54.404609000-00:00", :edited-at #inst "2024-03-27T11:41:57.364949000-00:00"}]} {:example-id #uuid "a00a79c8-d3a2-44c8-8688-b61b4a7672b9", :definition-id "nubank/matcher-combinators/matcher-combinators.matchers/embeds/0", :body "(flow \"Return transactions by category\"\n (match? {:status 200 :body {:transactions (m/embeds [{:category \"Food\"}])}}\n (servlet/request {:method :get :uri \"/transaction/:category\" \n :replace {:category \"Food\"}})", :created-at #inst "2024-03-26T20:43:52.489997000-00:00", :author {:author-id #uuid "750b1ede-fcb5-4989-bb56-f6bbad2b9e66", :login "dimmyjr-nu", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/87130196?v=4", :created-at #inst "2024-03-25T19:20:38.580572000-00:00"}, :editors [{:author-id #uuid "750b1ede-fcb5-4989-bb56-f6bbad2b9e66", :login "dimmyjr-nu", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/87130196?v=4", :created-at #inst "2024-03-25T19:20:38.580572000-00:00", :edited-at #inst "2024-03-26T20:43:52.489997000-00:00"}]}])
8+
(def top-author
9+
[{:author-id #uuid "36a91f13-2cf9-4b80-a9f0-619b5dbe6ec5", :login "rafaeldelboni", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/1683898?v=4", :created-at #inst "2024-03-11T14:16:54.404609000-00:00", :interactions 10}
10+
{:author-id #uuid "3b5b49a2-a731-4c12-81c0-88b1d74415a2", :login "vloth", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/49727703?v=4", :created-at #inst "2024-03-16T10:43:31.732700000-00:00", :interactions 3} {:author-id #uuid "86ebb308-6839-46d0-b3da-b3832c94ad9e", :login "matheusfrancisco", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/6428732?v=4", :created-at #inst "2024-03-16T08:24:15.745224000-00:00", :interactions 2} {:author-id #uuid "b58e81a2-3647-4c71-aa4f-1499cff15c59", :login "strobelt", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/669994?v=4", :created-at #inst "2024-05-03T21:43:23.766762000-00:00", :interactions 2} {:author-id #uuid "05c01718-00b0-4ebe-a28b-280cd1be9a31", :login "kroncatti", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/56690659?v=4", :created-at #inst "2024-03-25T16:07:54.244916000-00:00", :interactions 2} {:author-id #uuid "750b1ede-fcb5-4989-bb56-f6bbad2b9e66", :login "dimmyjr-nu", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/87130196?v=4", :created-at #inst "2024-03-25T19:20:38.580572000-00:00", :interactions 1} {:author-id #uuid "d6e7b8d2-590d-4e53-9691-c8a900703d16", :login "daveliepmann", :account-source "github", :avatar-url "https://avatars.githubusercontent.com/u/974443?v=4", :created-at #inst "2024-03-25T15:30:44.171709000-00:00", :interactions 1}])
11+
12+
(defnc all []
13+
; todo get from fetch
14+
(let [latest-interactions-response {:value latest-interactions
15+
:loading? false
16+
:error nil}
17+
top-author-response {:value top-author
18+
:loading? false
19+
:error nil}]
20+
($ Container {:p "sm"}
21+
22+
($ components.query/latest-interactions {:& latest-interactions-response})
23+
24+
($ Space {:h "xl"})
25+
26+
($ components.query/top-author {:& top-author-response}))))

src/codes/clj/docs/frontend/routes.cljs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
(:require [codes.clj.docs.frontend.infra.auth.github.view :as auth.github.view]
33
[codes.clj.docs.frontend.panels.author.state :as author.state]
44
[codes.clj.docs.frontend.panels.author.view :as author.view]
5+
[codes.clj.docs.frontend.panels.dashboards.view :as dashboards.view]
56
[codes.clj.docs.frontend.panels.definition.state :as definition.state]
67
[codes.clj.docs.frontend.panels.definition.view :as definition.view]
78
[codes.clj.docs.frontend.panels.definitions.state :as definitions.state]
@@ -56,6 +57,15 @@
5657
(set-title! "Projects - docs.clj.codes")
5758
(projects.state/document-projects-fetch))}]}]
5859

60+
["dashboards"
61+
{:name :dashboards
62+
:view dashboards.view/all
63+
:link-text "dashboards"
64+
:controllers [{:start (fn [& _params]
65+
(set-title! "Dashboards - docs.clj.codes")
66+
; fetch todo
67+
)}]}]
68+
5969
["search"
6070
{:name :search
6171
:view search.view/search-page

0 commit comments

Comments
 (0)