Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

Added Support for Size in New-PodeWebText

Open the-mentor opened this issue 3 years ago • 2 comments

I've added support for text size.

image

the following code can be used to test this out

Import-Module Pode,Pode.Web 

Start-PodeServer {
    # add a simple endpoint
    Add-PodeEndpoint -Address localhost -Port 8090 -Protocol Http

    # set the use of the pode.web templates
    Use-PodeWebTemplates -Title 'Example' -Theme Light

    # add the page
    Add-PodeWebPage -Name test -Icon Activity -Layouts @(
        New-PodeWebCard -Name test -Content @(
            New-PodeWebText -Value test2 
            New-PodeWebRaw -Value '<br>'
            New-PodeWebText -Value test2 -Style 'strikethrough' -Size 50px
            New-PodeWebText -Value test3 -Size 10px -InParagraph
            New-PodeWebText -Value test4 -Size 250% -InParagraph
            New-PodeWebText -Value test5 -Size xxx-large
            
        )
    )
}

the-mentor avatar Jul 25 '21 19:07 the-mentor

I actually really like the way you've done this, and it's given me an idea:

On New-PodeWebTextbox we have a -Width that's an integer which gets forced to be %. What if we take your approach but make it so that there's a default "type"?

Ie, if you do -Size 50 that would fail currently, but -Size 50px would work.; it kinda requires people to have some knowledge of CSS. Soo what if when they just give it a raw number ($Size -imatch '^[\d\.]+$') then we auto-append px - so Size 50 internally becomes 50px 🤔

Likewise for Width, -Width 50 becomes 50%, but it allows people who know some CSS to be able to go -Width 15em.

What do you think?

Badgerati avatar Jul 26 '21 19:07 Badgerati

I have something like this in my PSWriteHTML project for sizes. Basically assumes px when given just int. Accepts everything else as is when user knows what he/she wants.

https://github.com/EvotecIT/PSWriteHTML/blob/0d2f962187d3479aabc40d2dd192b3a4e40972ff/Private/ConvertFrom-Size.ps1#L1-L23

PrzemyslawKlys avatar Jul 26 '21 21:07 PrzemyslawKlys