-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.cljs
45 lines (42 loc) · 1.2 KB
/
message.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(ns respo-message.comp.message
(:require [respo.core :refer [create-comp]]
[respo.core :refer [defcomp div <> span]]
[respo-ui.core :as ui]
[hsl.core :refer [hsl]]
[respo-message.schema :as schema]))
(def style-message
{:position :absolute,
:right 8,
:height 32,
:line-height "32px",
:font-size "14",
:background-color (hsl 0 0 100),
:border-style :solid,
:border-width "1px",
:border-radius "8px",
:border-color (hsl 200 50 80),
:color (hsl 0 0 60),
:padding "0 16px",
:min-width 64,
:text-align :left,
:overflow :hidden,
:text-overflow :ellipsis,
:max-width 320,
:cursor :pointer,
:transition-duration "400ms"})
(defcomp
comp-message
(idx message options on-remove!)
(div
{:style (merge
style-message
(:style message)
(if (:bottom? options)
{:bottom 8, :transform (str "translate(0," (- (* idx 40)) "px)")}
{:top 8, :transform (str "translate(0," (* idx 40) "px)")})),
:on-click (fn [e d! m!]
(on-remove!
{:id (:id message), :token (:token message), :index idx, :time (:time message)}
d!
m!))}
(<> span (:text message) nil)))