mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 12:11:38 +02:00
✨ Add minor improvements to notifications-hub component
This commit is contained in:
parent
7e50ab52b9
commit
57c60716f0
2 changed files with 35 additions and 32 deletions
|
@ -17,33 +17,38 @@
|
||||||
(mf/defc notifications-hub
|
(mf/defc notifications-hub
|
||||||
[]
|
[]
|
||||||
(let [message (mf/deref refs/message)
|
(let [message (mf/deref refs/message)
|
||||||
|
on-close (mf/use-fn #(st/emit! dmsg/hide))
|
||||||
on-close #(st/emit! dmsg/hide)
|
context? (and (nil? (:timeout message))
|
||||||
|
(nil? (:actions message)))
|
||||||
toast-message {:type (or (:type message) :info)
|
inline? (or (= :inline (:notification-type message))
|
||||||
:links (:links message)
|
(= :floating (:position message)))
|
||||||
:on-close on-close
|
toast? (or (= :toast (:notification-type message))
|
||||||
:content (:content message)}
|
(some? (:timeout message)))]
|
||||||
|
|
||||||
inline-message {:actions (:actions message)
|
|
||||||
:links (:links message)
|
|
||||||
:content (:content message)}
|
|
||||||
|
|
||||||
context-message {:type (or (:type message) :info)
|
|
||||||
:links (:links message)
|
|
||||||
:content (:content message)}
|
|
||||||
|
|
||||||
is-context-msg (and (nil? (:timeout message)) (nil? (:actions message)))
|
|
||||||
is-toast-msg (or (= :toast (:notification-type message)) (some? (:timeout message)))
|
|
||||||
is-inline-msg (or (= :inline (:notification-type message)) (and (some? (:position message)) (= :floating (:position message))))]
|
|
||||||
|
|
||||||
(when message
|
(when message
|
||||||
(cond
|
(cond
|
||||||
is-toast-msg
|
toast?
|
||||||
[:& toast-notification toast-message]
|
[:& toast-notification
|
||||||
is-inline-msg
|
{:type (or (:type message) :info)
|
||||||
[:& inline-notification inline-message]
|
:links (:links message)
|
||||||
is-context-msg
|
:on-close on-close
|
||||||
[:& context-notification context-message]
|
:content (:content message)}]
|
||||||
|
|
||||||
|
inline?
|
||||||
|
[:& inline-notification
|
||||||
|
{:actions (:actions message)
|
||||||
|
:links (:links message)
|
||||||
|
:content (:content message)}]
|
||||||
|
|
||||||
|
context?
|
||||||
|
[:& context-notification
|
||||||
|
{:type (or (:type message) :info)
|
||||||
|
:links (:links message)
|
||||||
|
:content (:content message)}]
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[:& toast-notification toast-message]))))
|
[:& toast-notification
|
||||||
|
{:type (or (:type message) :info)
|
||||||
|
:links (:links message)
|
||||||
|
:on-close on-close
|
||||||
|
:content (:content message)}]))))
|
||||||
|
|
|
@ -38,12 +38,10 @@
|
||||||
neutral-icon))
|
neutral-icon))
|
||||||
|
|
||||||
(mf/defc toast-notification
|
(mf/defc toast-notification
|
||||||
"These are ephemeral elements that disappear when
|
"These are ephemeral elements that disappear when the close button
|
||||||
the close button is pressed,
|
is pressed, the page is refreshed, the page is navigated to another
|
||||||
the page is refreshed,
|
page or after 7 seconds, which is enough time to be read, except for
|
||||||
the page is navigated to another page or
|
error messages that require user interaction."
|
||||||
after 7 seconds, which is enough time to be read,
|
|
||||||
except for error messages that require user interaction."
|
|
||||||
|
|
||||||
{::mf/props :obj}
|
{::mf/props :obj}
|
||||||
[{:keys [type content on-close links] :as props}]
|
[{:keys [type content on-close links] :as props}]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue