- Add Scala.js to your project.
- Add scalajs-react to your project.
- Add ScalaCss to your project.
- Add Notification to your build sbt.
libraryDependencies += "uz.scala" %%% "notification" % "2.0.1"
You need to add Notification.render()
to the render section, and add NotificationStyle.addToDocument()
before rendering
val MyComponent =
ScalaComponent.builder[Unit]
.render { _ =>
<.div(
Notification.render(),
???
)
}
.build
NotificationStyle.addToDocument()
MyComponent().renderIntoDOM(document.getElementById("need-to-render-div-id"))
Also, you can also set the notification retention time using the Notification constructor. This figure is usually 6 seconds
...
Notification.render(10) // this value in seconds
...
This library has 4 notification type for using, and these returned ScalaJs & React - Callbacks. For example:
Notification.info("This is information box!")
Notification.warning("This is warning box!")
Notification.error("This is error box!")
Notification.success("This is success box!")
For notification icons used Font Awesome 5