notification.pug 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //- to be kept in sync with frontend/js/shared/components/notification.tsx
  2. include ./material_symbol
  3. mixin notificationIcon(type)
  4. if type === 'info'
  5. +material-symbol('info')
  6. else if type === 'success'
  7. +material-symbol('check_circle')
  8. else if type === 'error'
  9. +material-symbol('error')
  10. else if type === 'warning'
  11. +material-symbol('warning')
  12. mixin notification(options)
  13. - var {ariaLive, id, type, title, content, disclaimer, className, dismissId, dismissCookiePaths} = options ?? {}
  14. - var classNames = `notification notification-type-${type} ${className ? className : ''} ${isActionBelowContent ? 'notification-cta-below-content' : ''}`
  15. if dismissId && dismissedNotifications.includes(dismissId)
  16. //- Notification has been dismissed, do not render
  17. else
  18. div(
  19. aria-live=ariaLive
  20. role='alert'
  21. id=id
  22. class=classNames
  23. data-ol-dismiss-id=dismissId
  24. data-ol-dismiss-cookie-paths=dismissCookiePaths && dismissCookiePaths.join(',')
  25. )
  26. .notification-icon
  27. +notificationIcon(type)
  28. .notification-content-and-cta
  29. .notification-content
  30. if title
  31. p
  32. b #{title}
  33. | !{content}
  34. block
  35. //- TODO: handle action
  36. //- if action
  37. //- .notification-cta
  38. if disclaimer
  39. .notification-disclaimer #{disclaimer}
  40. if dismissId
  41. .notification-close-btn
  42. button(aria-label=translate('close') data-ol-dismiss-button)
  43. +material-symbol('close')