Skip to content

Commit

Permalink
Add Padding operations to PanelBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
galassie committed Feb 17, 2023
1 parent af0e8ac commit 2e1e406
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/FsSpectre/FsSpectre.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- NuGet config -->
<PackageId>FsSpectre</PackageId>
<Version>0.4.4</Version>
<Version>0.4.5</Version>
<Authors>Enrico Galassi</Authors>
<PackageTags>fsharp;cli;dotnet;console-application;fsharp-console;</PackageTags>
<PackageProjectUrl>https://github.com/galassie/fs-spectre</PackageProjectUrl>
Expand Down
26 changes: 24 additions & 2 deletions src/FsSpectre/Widgets/PanelBuilder.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ module PanelBuilder =
Header: PanelHeader
Expand: bool
Width: int option
Height: int option }
Height: int option
Padding: Padding }

static member Default =
{ Content = Markup(String.Empty)
Expand All @@ -23,7 +24,8 @@ module PanelBuilder =
Header = PanelHeader(String.Empty)
Expand = false
Width = None
Height = None }
Height = None
Padding = Padding(1, 0, 1, 0) }

type PanelBuilder() =
member __.Yield _ = PanelConfig.Default
Expand Down Expand Up @@ -68,4 +70,24 @@ module PanelBuilder =
[<CustomOperation "height">]
member __.Height(config: PanelConfig, height: int) = { config with Height = Some height }

[<CustomOperation "pad_left">]
member __.PadLeft(config: PanelConfig, pad: int) =
{ config with
Padding = Padding(pad, config.Padding.Top, config.Padding.Right, config.Padding.Bottom) }

[<CustomOperation "pad_top">]
member __.PadTop(config: PanelConfig, pad: int) =
{ config with
Padding = Padding(config.Padding.Left, pad, config.Padding.Right, config.Padding.Bottom) }

[<CustomOperation "pad_right">]
member __.PadRight(config: PanelConfig, pad: int) =
{ config with
Padding = Padding(config.Padding.Left, config.Padding.Top, pad, config.Padding.Bottom) }

[<CustomOperation "pad_bottom">]
member __.PadBottom(config: PanelConfig, pad: int) =
{ config with
Padding = Padding(config.Padding.Left, config.Padding.Top, config.Padding.Right, pad) }

let panel = PanelBuilder()

0 comments on commit 2e1e406

Please sign in to comment.