Skip to content

Commit

Permalink
#270: Add outline support for buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Badgerati committed Feb 26, 2022
1 parent c9ca7d3 commit 715799a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
14 changes: 14 additions & 0 deletions docs/Tutorials/Elements/Button.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,17 @@ To open the URL in a new tab, supply the `-NewTab` switch:
```powershell
New-PodeWebButton -Name 'Repository' -Icon Link -Url 'https://github.com/Badgerati/Pode.Web' -NewTab
```

## Outlined

By default a button will be displayed as a block colour, but you can show a button as an outline by using the `-Outline` switch:

```powershell
New-PodeWebButton -Name 'Example' -Colour Cyan -Outline -ScriptBlock {
# logic
}
```

Which looks like below:

![button_outline](../../../images/button_outline.png)
Binary file added docs/images/button_outline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions examples/full.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ Start-PodeServer -StatusPageExceptions Show {
Show-PodeWebToast -Message "Message of the day: $($WebEvent.Data.Value)"
Show-PodeWebNotification -Title 'Hello, there' -Body 'General Kenobi' -Icon '/pode.web/images/icon.png'
}
New-PodeWebButton -Name 'Click Me Outlined' -DataValue 'PowerShell Rules!' -NoAuth -Icon 'console-line' -Colour Green -Outline -ScriptBlock {
Show-PodeWebToast -Message "Message of the day: $($WebEvent.Data.Value)"
Show-PodeWebNotification -Title 'Hello, there' -Body 'General Kenobi' -Icon '/pode.web/images/icon.png'
}
New-PodeWebButton -Name 'Example' -Colour Cyan -Outline -NewLine -ScriptBlock {
Show-PodeWebToast -Message "Message of the day: $($WebEvent.Data.Value)"
Show-PodeWebNotification -Title 'Hello, there' -Body 'General Kenobi' -Icon '/pode.web/images/icon.png'
}
New-PodeWebContainer -Content @(
New-PodeWebButton -Name 'Dark Theme' -NoAuth -Icon 'moon-new' -Colour Dark -ScriptBlock { Update-PodeWebTheme -Name Dark }
New-PodeWebButton -Name 'Light Theme' -NoAuth -Icon 'weather-sunny' -Colour Light -ScriptBlock { Update-PodeWebTheme -Name Light }
Expand Down
10 changes: 9 additions & 1 deletion src/Public/Elements.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1525,11 +1525,18 @@ function New-PodeWebButton

[Parameter(ParameterSetName='Url')]
[switch]
$NewTab
$NewTab,

[switch]
$Outline
)

$Id = Get-PodeWebElementId -Tag Btn -Id $Id -Name $Name

$colourType = Convert-PodeWebColourToClass -Colour $Colour
if ($Outline) {
$colourType = "outline-$($colourType)"
}

$element = @{
ComponentType = 'Element'
Expand All @@ -1545,6 +1552,7 @@ function New-PodeWebButton
IconOnly = $IconOnly.IsPresent
Colour = $Colour
ColourType = $ColourType
Outline = $Outline.IsPresent
CssClasses = ($CssClass -join ' ')
CssStyles = (ConvertTo-PodeWebStyles -Style $CssStyle)
NewLine = $NewLine.IsPresent
Expand Down

0 comments on commit 715799a

Please sign in to comment.