I’m playing around with the idea of a theme switcher in UD, like switching from light to dark, and here is what I have so far:
$Theme_Azure = Get-UDTheme -Name Azure
$Theme_Blue = Get-UDTheme -Name Blue
$Board = New-UDDashboard -Theme $Theme_Azure -Title "Test Themes" -Content {
$Session:BGColor = $Theme_Azure.Definition.UDCard.BackgroundColor
$Session:Color = $Theme_Azure.Definition.UDCard.FontColor
New-UDLayout -Columns 2 -Content {
1..5 | % {
new-udcard -BackgroundColor $Session:BGColor -FontColor $Session:Color -Id "card$_" -Title "Card #$_"
}
New-UDSwitch -Id themeSwitcher -OnText "Blue" -OffText "Azure" -OnChange {
switch ($EventData)
{
$true
{
$Session:BGColor = $Theme_Blue.Definition.UDCard.BackgroundColor
$Session:Color = $Theme_Blue.Definition.UDCard.FontColor
}
$false
{
$Session:BGColor = $Theme_Azure.Definition.UDCard.BackgroundColor
$Session:Color = $Theme_Azure.Definition.UDCard.FontColor
}
}
1..5 | % {
$Id = "card$_"
$Attributes = Get-UDElement -Id $Id | select -exp Attributes
$Attributes.style.backgroundColor = $Session:BGColor
$Attributes.style.color = $Session:Color
Set-UDElement -Id $Id -Attributes $Attributes
Sync-UDElement -Id $Id
}
}
}
}
Start-UDDashboard -Dashboard $Board
It’s a little unwieldy, but with the right design it might be kinda cool. Let me know what you think.