notification.pug 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //- to be kept in sync with frontend/js/shared/components/notification.tsx
  2. mixin notificationIcon(type)
  3. if type === 'info'
  4. span.material-symbols(aria-hidden="true") info
  5. else if type === 'success'
  6. span.material-symbols(aria-hidden="true") check_circle
  7. else if type === 'error'
  8. span.material-symbols(aria-hidden="true") error
  9. else if type === 'warning'
  10. span.material-symbols(aria-hidden="true") warning
  11. mixin notification(options)
  12. - var {ariaLive, id, type, title, content, disclaimer, className} = options
  13. - var classNames = `notification notification-type-${type} ${className ? className : ''} ${isActionBelowContent ? 'notification-cta-below-content' : ''}`
  14. div(
  15. aria-live=ariaLive,
  16. role="alert",
  17. id=id,
  18. class=classNames
  19. )
  20. .notification-icon
  21. +notificationIcon(type)
  22. .notification-content-and-cta
  23. .notification-content
  24. if title
  25. p
  26. b #{title}
  27. | !{content}
  28. //- TODO: handle action
  29. //- if action
  30. //- .notification-cta
  31. if disclaimer
  32. .notification-disclaimer #{disclaimer}
  33. //- TODO: handle dismissible notifications
  34. //- TODO: handle onDismiss
  35. //- if isDismissible
  36. //- .notification-close-btn
  37. //- button(aria-label=translate('close'))
  38. //- span.material-symbols(aria-hidden="true") close