Invitation accepted
You joined Northwind Outdoor.
Present ephemeral, optionally actionable feedback in an accessible bottom-end stack.
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let notificationLeadItem sequence =
fveNotification {
_id $"saved-notification-{sequence}"
_label "Changes saved"
p { "Your changes are ready." }
}
let notificationLeadRegion sequence =
let notification =
if sequence > 0 then
Some(notificationLeadItem sequence)
else
None
fveNotificationRegion {
_id "save-notifications"
_ariaLabel "Workspace notifications"
match (notification: HtmlElement option) with
| Some notification -> notification
| None -> ()
_withinContainer true
}
let simpleNotificationExample =
div {
_dataSignals ("components_notification_sequence", [ "ifmissing" ], "0")
div {
_class "flex min-h-40 items-start justify-center p-6"
fveButton {
_dataOn ("click", "$components_notification_sequence += 1; @post('/components/notifications/show')")
"Show notification"
}
}
notificationLeadRegion 0
}This example also uses Button. See their Installation sections for any additional setup.
Copy this component and its required dependencies into the consumer-owned Components project.
dotnet fve add notification --config src/Acme.Components/fve.jsonAdd to src/Acme.Web/js/app.js once, alongside your other component imports:
import '../../Acme.Components/Components/Assets/notification.js';The CLI resolves dependencies and preserves consumer-authored files. See Installation for project initialization, Tailwind, the shared runtime, and building/loading your app entry.
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let notificationLeadItem sequence =
fveNotification {
_id $"saved-notification-{sequence}"
_label "Changes saved"
p { "Your changes are ready." }
}
let notificationLeadRegion sequence =
let notification =
if sequence > 0 then
Some(notificationLeadItem sequence)
else
None
fveNotificationRegion {
_id "save-notifications"
_ariaLabel "Workspace notifications"
match (notification: HtmlElement option) with
| Some notification -> notification
| None -> ()
_withinContainer true
}
let simpleNotificationExample =
div {
_dataSignals ("components_notification_sequence", [ "ifmissing" ], "0")
div {
_class "flex min-h-40 items-start justify-center p-6"
fveButton {
_dataOn ("click", "$components_notification_sequence += 1; @post('/components/notifications/show')")
"Show notification"
}
}
notificationLeadRegion 0
}Invitation accepted
You joined Northwind Outdoor.
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let notificationWithActionsExample =
let action =
fveButton {
_variant ButtonVariant.Outline
_size Size.Small
_dataOn (
"click",
"evt.currentTarget.closest('[data-fve-notification]').querySelector('[role=status] div').textContent = 'The invitation remains pending.'"
)
"Undo"
}
fveNotificationRegion {
_id "invitation-notifications"
_ariaLabel "Invitation notifications"
_withinContainer true
fveNotification {
_id "invitation-notification"
_label "Invitation accepted"
_color Color.Info
_persistent true
p { "You joined Northwind Outdoor." }
fveNotificationActions { action }
}
}This example also uses Button. See their Installation sections for any additional setup.
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let timedNotificationItem sequence =
fveNotification {
_id $"review-notification-{sequence}"
_label "Review needed"
_color Color.Warning
_ttl 3000
p { "Two items still need your attention." }
}
let timedNotificationRegion sequence =
fveNotificationRegion {
_id "timed-notifications"
_ariaLabel "Review notifications"
_withinContainer true
if sequence > 0 then
timedNotificationItem sequence
}
let timedNotificationExample =
div {
_dataSignals ("components_timed_notification_sequence", [ "ifmissing" ], "0")
div {
_class "flex min-h-40 items-start justify-center p-6"
fveButton {
_dataOn (
"click",
"$components_timed_notification_sequence += 1; @post('/components/notifications/show-timed')"
)
"Show 3-second notification"
}
}
timedNotificationRegion 0
}This example also uses Button. See their Installation sections for any additional setup.
Use _announcement to choose Static, Polite or Assertive announcements. See Notice's announcement example for a live status update.
module NotificationDsl =
val fveNotification : ComponentElementBuilder
val fveNotificationActions : ComponentElementBuilder
val fveNotificationRegion : ComponentElementBuilder
module NotificationAttributes =
val Html._ttl.Static : value:int -> HtmlAttribute
val Html._persistent.Static : value:bool -> HtmlAttribute
val Html._withinContainer.Static : value:bool -> HtmlAttribute