Need EventData from New-UDElement

Product: PowerShell Universal
Version: 1.4.6

First of all, this layout blows my mind. I used to have to do this with modulus back in the day.

Next, I’m looking to set a theme by clicking its thumbnails but I can’t figure out how to get EventData from the thing that I’ve created that is beautiful.

    New-UDLayout -Columns 3 -Content {
        Get-AllThemes | Select-Object -First 30 | ForEach-Object {
            New-UDElement -Tag div -Attributes @{
                style   = @{
                    cursor = "pointer"
                }
                onClick = {
                    #Set-ActiveTheme $EventData.Id
                    Show-UDToast -Message "$EventData"
                }
            } -Content {
                # lol IDs everywhere cuz im not sure which one is driving that event data
                New-UDCard -Id $PSItem -Content {
                    New-UDImage -Url /assets/screenshots/$PSItem-light.png -Width 256 -Height 144 -Id $PSItem
                    # need some padding
                    New-UDImage -Url /assets/screenshots/$PSItem-dark.png -Width 256 -Height 144 -Id $PSItem
                }
            } -Id $PSItem
        }
    }

Any ideas? Hopefully this is possible. I love that it’s pretty and figures out how to do the 3 columns.

2 Likes

Ohhh looks like I need to expore (Get-UDElement -Id txtNumber).Attributes["value"] brb!

Got it! This is so beautiful! #PSU4Ever

    New-UDLayout -Columns 3 -Content {
        Get-AllThemes | ForEach-Object {
            New-UDElement -Tag div -Attributes @{
                style   = @{
                    cursor       = "pointer"
                    "text-align" = "center"
                }
                onClick = {
                    Set-ActiveTheme ((Get-UDElement -Id $PSItem)).attributes.id
                }
            } -Content {
                New-UDCard -TitleAlignment Center -Title $PSItem -Content {
                    New-UDImage -Url /assets/screenshots/$PSItem-light.png -Width 256 -Height 144 -Attributes @{
                        style           = @{ 
                            paddingRight = "25px"
                        }
                    } -ClassName "photo"

                    New-UDImage -Url /assets/screenshots/$PSItem-dark.png -Width 256 -Height 144 -ClassName "photo"
                }
            } -Id $PSItem
        }
    }
3 Likes