Skip to content

Commit 982d8a8

Browse files
committed
IFrame control + example added
1 parent a485492 commit 982d8a8

File tree

5 files changed

+68
-8
lines changed

5 files changed

+68
-8
lines changed

pglet.psm1

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ New-Alias -Name GridColumn -Value New-PgletGridColumn
2121
New-Alias -Name Grid -Value New-PgletGrid
2222
New-Alias -Name Html -Value New-PgletHtml
2323
New-Alias -Name Icon -Value New-PgletIcon
24+
New-Alias -Name IFrame -Value New-PgletIFrame
2425
New-Alias -Name Image -Value New-PgletImage
2526
New-Alias -Name LineChart -Value New-PgletLineChart
2627
New-Alias -Name LineChartData -Value New-PgletLineChartData
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Pglet.Controls;
2+
using System.Management.Automation;
3+
4+
namespace Pglet.PowerShell
5+
{
6+
[Cmdlet(VerbsCommon.New, "PgletIFrame")]
7+
[OutputType(typeof(IFrame))]
8+
public class NewPgletIFrameCommand : NewControlCmdletBase
9+
{
10+
[Parameter(Mandatory = false, Position = 0)]
11+
public string Src { get; set; }
12+
13+
[Parameter(Mandatory = false)]
14+
public string Title { get; set; }
15+
16+
[Parameter(Mandatory = false)]
17+
public string Border { get; set; }
18+
19+
protected override void ProcessRecord()
20+
{
21+
var control = new IFrame
22+
{
23+
Src = Src,
24+
Title = Title,
25+
Border = Border
26+
};
27+
28+
SetControlProps(control);
29+
30+
WriteObject(control);
31+
}
32+
}
33+
}

src/Pglet/Controls/IFrame.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace Pglet.Controls
2+
{
3+
public class IFrame : Control
4+
{
5+
protected override string ControlName => "iframe";
6+
7+
public string Src
8+
{
9+
get { return GetAttr("src"); }
10+
set { SetAttr("src", value); }
11+
}
12+
13+
public string Title
14+
{
15+
get { return GetAttr("title"); }
16+
set { SetAttr("title", value); }
17+
}
18+
19+
public string Border
20+
{
21+
get { return GetAttr("border"); }
22+
set { SetAttr("border", value); }
23+
}
24+
}
25+
}

tests/buttons.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ Connect-PgletApp -Name "pglet-buttons" -ScriptBlock {
8181

8282
Text "Split buttons" -Size Large
8383
Button -Split -Text "Standard" -MenuItems @(
84-
MenuItem -Text "Email message" -Icon "Mail"
85-
MenuItem -Text "Calendar event" -Icon "Calendar"
84+
MenuItem -Text "Email message" -Icon "Mail" -OnClick { Write-Trace "Email message clicked!" }
85+
MenuItem -Text "Calendar event" -Icon "Calendar" -OnClick { Write-Trace "Calendar clicked!" }
8686
)
8787
Button -Split -Primary -Text "Primary" -MenuItems @(
8888
MenuItem -Text "Email message" -Icon "Mail"

tests/iframe.ps1

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Remove-Module pglet -ErrorAction SilentlyContinue
22
Import-Module ([IO.Path]::Combine((get-item $PSScriptRoot).parent.FullName, 'pglet.psd1'))
33

4-
Connect-PgletPage -Name "index" -NoWindow
4+
Connect-PgletApp -ScriptBlock {
5+
$page = $PGLET_PAGE
56

6-
Invoke-Pglet "clean page"
7-
8-
Invoke-Pglet "add
9-
iframe src='https://pglet.io' width='100%' border1='2px solid red'
10-
"
7+
$page.title = "IFrame example"
8+
$page.add(
9+
(IFrame -Src 'https://pglet.io' -Width '100%' -Height 300 -Border '2px solid red')
10+
)
11+
}

0 commit comments

Comments
 (0)