mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 08:20:45 -05: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
|
||||
[]
|
||||
(let [message (mf/deref refs/message)
|
||||
|
||||
on-close #(st/emit! dmsg/hide)
|
||||
|
||||
toast-message {:type (or (:type message) :info)
|
||||
:links (:links message)
|
||||
:on-close on-close
|
||||
:content (:content 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))))]
|
||||
on-close (mf/use-fn #(st/emit! dmsg/hide))
|
||||
context? (and (nil? (:timeout message))
|
||||
(nil? (:actions message)))
|
||||
inline? (or (= :inline (:notification-type message))
|
||||
(= :floating (:position message)))
|
||||
toast? (or (= :toast (:notification-type message))
|
||||
(some? (:timeout message)))]
|
||||
|
||||
(when message
|
||||
(cond
|
||||
is-toast-msg
|
||||
[:& toast-notification toast-message]
|
||||
is-inline-msg
|
||||
[:& inline-notification inline-message]
|
||||
is-context-msg
|
||||
[:& context-notification context-message]
|
||||
toast?
|
||||
[:& toast-notification
|
||||
{:type (or (:type message) :info)
|
||||
:links (:links message)
|
||||
:on-close on-close
|
||||
: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
|
||||
[:& 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))
|
||||
|
||||
(mf/defc toast-notification
|
||||
"These are ephemeral elements that disappear when
|
||||
the close button is pressed,
|
||||
the page is refreshed,
|
||||
the page is navigated to another page or
|
||||
after 7 seconds, which is enough time to be read,
|
||||
except for error messages that require user interaction."
|
||||
"These are ephemeral elements that disappear when the close button
|
||||
is pressed, the page is refreshed, the page is navigated to another
|
||||
page or after 7 seconds, which is enough time to be read, except for
|
||||
error messages that require user interaction."
|
||||
|
||||
{::mf/props :obj}
|
||||
[{:keys [type content on-close links] :as props}]
|
||||
|
|
Loading…
Reference in a new issue