Skip to content

Commit

Permalink
finished the profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
humorless committed Sep 15, 2024
1 parent fd84c20 commit e162559
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
17 changes: 17 additions & 0 deletions repl-sessions/participants.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
[co.gaiwan.compass.model.assets :as assets]
[datomic.api :as d]))

(defn test-user-eid
"Query the database to find out a certain login by discord user"
[user-name]
(db/q
'[:find ?e .
:in $ ?u
:where
[?e :public-profile/name ?u]]
(db/db) user-name))

(def user-eid
(test-user-eid "Laurence"))

(def new-session-eid
17592186045455)
;; Avatar source URL https://github.com/alohe/avatars
Expand All @@ -27,9 +40,13 @@
(fn [x]
{:db/id (str "temp-" x)
:user/uuid (random-uuid)
:user/contacts user-eid
:discord/email (str "temp-email-" x "@gaiwan.co")
:public-profile/hidden? (if (even? x) true false)
:public-profile/name (str "temp-user-" x)
:public-profile/bio "problic-bio"
:private-profile/bio "private-bio"
:private-profile/name "private-name"
:public-profile/avatar-url (assets/download-image (str avatar-url-part x ".png"))})
(range 1 11))
;; Below is for session join
Expand Down
23 changes: 18 additions & 5 deletions src/co/gaiwan/compass/html/profiles.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,35 @@
[:.link :w-full :flex :flex-1 :py-1 :font-size-3]
[:.link-type :w-12 :px-2]
[:.link-ref :flex-grow :px-2]]

[:.contact-card :my-2]
([{:public-profile/keys [name hidden?]
:user/keys [uuid] :as user} viewer]
[:<>
[:div [c/image-frame {:profile/image (user/avatar-css-value user)}]]
[:div.details
[:h3.title name]
[:div.bio
(m/component (m/md->hiccup (:public-profile/bio user)))]
(when (:public-profile/bio user)
[:div.bio
(m/component (m/md->hiccup (:public-profile/bio user)))])
[:div.links
(for [link (:public-profile/links user)]
[:div.link
[:div.link-type (:profile-link/type link)]
[:div.link-ref (:profile-link/href link)]])]]

;; hide edit button unless it's your own profile
;; if the user is connected (contact), show "contact card"
(when (some #{(:db/id viewer)} (map :db/id (:user/contacts user)))
[:div.contact-card
[:div.details
[:h3.title (:private-profile/name user)]
(when (:private-profile/bio user)
[:div.bio
(m/component (m/md->hiccup (:private-profile/bio user)))])
[:div.links
(for [link (:private-profile/links user)]
[:div.link
[:div.link-type (:profile-link/type link)]
[:div.link-ref (:profile-link/href link)]])]]])
;; hide edit button unless it's your own profile
(when (= (:db/id viewer) (:db/id user))
[:div.actions
[edit-profile-btn user]])]))
Expand Down

0 comments on commit e162559

Please sign in to comment.