New-UDButton parameters not working?

Being very new to UD, I figured I’d try something simple - a dashboard with a few buttons on.

It works fine with the defaults but the buttons are a bit small for my needs so I figured I’d test with the code here:[https://github.com/ironmansoftware/universal-dashboard/blob/master/src/UniversalDashboard/Help/New-UDButton.md]

Button sizes

New-UDButton -Text "Big" -Height 300 -Width "100"

results in error: A parameter cannot be found that matches parameter name ‘Height’.

Custom styles

New-UDButton -Text "Custom" -Style @{
    Font-Size = 36 px
    Height = 300 px
}

results in error:

  •     Font-Size = 36 px
    
  •         ~
    

Missing ‘=’ operator after key in hash literal.

Are these known issues or am I missing something ?

Cheers

Hi @Badgerface,

Welcome to the UD forums dude!

Update the module to 2.8.3 which was released… a couple of days ago. The helpfile on github is always updated to the current “nightly builds” and may not be present on the Powershell Gallery version until a new release is added.

Happy hunting!

Thanks for the welcome @BoSen29 :slight_smile:

Updated and reloaded - now I don`t get an error :+1: but, this doesn’t look like it’s 300 pixels high and its definitely not 100% screen width

image

which apparently it should be ?

Cheers

Hi again @Badgerface!

Are you attempting the -style hashtable or the -height and -width params?
The -style will take preference over the height/width params.

Try to quote the stuff:

New-UDButton -Text "Custom" -Style @{
    Width = "100%"
    Height = "300px"
}

The 100% width is 100% of the parent, IE you’d need a column with some sizespesification (ie -mediumsize 12) to have the button span the entire width of the page.

The -style param doesn’t format anything before sending it, the height and width param however, will suffix with “px” if it is an intreger. I also do believe you cannot have a space before the “px” part.

Give it a shot!

@BoSen29

Nope, no -style hashtable, below is the code I used:

$Dashboard = New-UDDashboard -Title “Button Size Test” -color “Orange” -Content {
New-UDButton -Text “Big” -Height 300 -Width “100”
}
Start-UDDashboard -Dashboard $Dashboard -Port 10001

I then tried using -style as you suggested:

$Dashboard = New-UDDashboard -Title “Button Size Test” -color “Orange” -Content {
New-UDColumn -MediumSize 12 -Content {
New-UDButton -Text “Custom” -Style @{
Width = “100%”
Height = “300px”
}
}
Start-UDDashboard -Dashboard $Dashboard -Port 10001

image

Still not 300px height or 100% width :slightly_frowning_face:

I did not put the space before the “px” part, it was a straight copy 'n paste from GitHub

Cheers

Hi again @Badgerface!

This is weird… could you do a shift-f5 (migth be control f5?) reload of UD for me? Might be some clientside javascript caching interfering?

If that doesn’t work, could you download the react-components plugin to chrome, and inspect the buttons “state” and check if the style attributes are passed correctly?

@BoSen29 - progress … :smiley:

Ctrl-F5 reload got the -Height working. I then added the ‘%’ to -Width just to see if that made a difference and it worked so, this is what I have now:

$Dashboard = New-UDDashboard -Title “Button Size Test” -color “Orange” -Content {
New-UDButton -Text “Big” -Height 300 -Width “100%”
}
Start-UDDashboard -Dashboard $Dashboard -Port 10001

Thanks for the help, its very much appreciated. :+1:

Cheers

Awesome!

The -width and -height params will asume it is “px” if nothing else is specified. IE “100” will be “100px” in the end. Hence the “100%” is necessary.

@BoSen29

Fair enough, I know that now thanks to you but if it’s not made clear in the docs, it will cause confusion.

No mention of the ‘%’ being needed for the -width parameter below and it’s not the code example either…

Button sizes

New-UDButton -Text "Big" -Height 300 -Width "100"

Creates a button with height of 300px and 100% width. Note: the “px” will be appended automatically if not specified.

Anyway, thanks again for your help

Hi @Badgerface,

Teeny tiny typo from my side sadly, should be updated once Adam approves my PR:

Thanks for pointing this out! :slight_smile: