src/Console/Components/New-Alert.ps1
|
using module ../Context.psm1 <# .SYNOPSIS Renders an alert. .INPUTS The child content. .OUTPUTS The rendered component. #> function New-UIAlert { [Alias("uiAlert")] [CmdletBinding()] [OutputType([string])] param ( # The child content. [Parameter(Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName)] [object] $Content, # The CSS class names to apply to the underlying element. [Parameter(ValueFromPipelineByPropertyName)] [ValidateNotNull()] [string[]] $Class = @(), # A contextual modifier. [Parameter(ValueFromPipelineByPropertyName)] [Context] $Context = [Context]::Info, # Value indicating whether this alert can be dismissed. [Parameter(ValueFromPipelineByPropertyName)] [switch] $Dismissible, # Value indicating whether to apply a transition. [Parameter(ValueFromPipelineByPropertyName)] [switch] $Fade, # The icon displayed next to the alert message. [Parameter(ValueFromPipelineByPropertyName)] [string] $Icon = "" ) process { div -Class alert, "alert-$(Get-UIContext $Context -CssClass)", ($Dismissible ? "alert-dismissible" : ""), ($Fade ? "fade show" : ""), ($Class -join " ") { div -Class d-flex, align-items-center { i -Class icon, flex-shrink-0, me-2 ($Icon ? $Icon : (Get-UIContext $Context -Icon)) div $Content } if ($Dismissible) { button -Class btn-close -DataSet @{ BsDismiss = "alert" } -Type button } } } } |