diff --git a/docs/input/assets/casts/panel-plain.cast b/docs/input/assets/casts/panel-plain.cast new file mode 100644 index 0000000..9b0c989 --- /dev/null +++ b/docs/input/assets/casts/panel-plain.cast @@ -0,0 +1,3 @@ +{"version": 2, "width": 122, "height": 24, "title": "panel (plain)", "env": {"TERM": "Spectre.Console"}} +[0, "o", "\u2554\u2550\u2550\u001B[4mPasta Menu\u001B[0m\u2550\u2550\u2557\r\n\u2551 \u2551\r\n\u2551 \u2551\r\n\u2551 \u001B[31mSpaghetti\u001B[0m \u2551\r\n\u2551 \u001B[31mLinguini\u001B[0m \u2551\r\n\u2551 \u001B[31mFettucine\u001B[0m \u2551\r\n\u2551 \u001B[31mTortellini\u001B[0m \u2551\r\n\u2551 \u001B[31mCapellini\u001B[0m \u2551\r\n\u2551 \u001B[31mLasagna\u001B[0m \u2551\r\n\u2551 \u2551\r\n\u2551 \u2551\r\n\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\r\n"] + diff --git a/docs/input/assets/casts/panel-rich.cast b/docs/input/assets/casts/panel-rich.cast new file mode 100644 index 0000000..36b41d9 --- /dev/null +++ b/docs/input/assets/casts/panel-rich.cast @@ -0,0 +1,3 @@ +{"version": 2, "width": 122, "height": 24, "title": "panel (rich)", "env": {"TERM": "Spectre.Console"}} +[0, "o", "\u2554\u2550\u2550\u001B[4mPasta Menu\u001B[0m\u2550\u2550\u2557\r\n\u2551 \u2551\r\n\u2551 \u2551\r\n\u2551 \u001B[38;5;9mSpaghetti\u001B[0m \u2551\r\n\u2551 \u001B[38;5;9mLinguini\u001B[0m \u2551\r\n\u2551 \u001B[38;5;9mFettucine\u001B[0m \u2551\r\n\u2551 \u001B[38;5;9mTortellini\u001B[0m \u2551\r\n\u2551 \u001B[38;5;9mCapellini\u001B[0m \u2551\r\n\u2551 \u001B[38;5;9mLasagna\u001B[0m \u2551\r\n\u2551 \u2551\r\n\u2551 \u2551\r\n\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\r\n"] + diff --git a/docs/input/widgets/panel.md b/docs/input/widgets/panel.md new file mode 100644 index 0000000..745d7e6 --- /dev/null +++ b/docs/input/widgets/panel.md @@ -0,0 +1,61 @@ +Title: Panel +Order: 0 +RedirectFrom: panels +Description: "The **Panel** widget can be used to organize text into a rendered box." +Reference: T:Spectre.Console.Panel + +--- + +The `Panel` widget can be used to organize text into a rendered box. + + + +## Usage + +To render a table, create a `Table` instance, passing a string to its constructor to assign the contents. + +```csharp +var panel = new Panel("Hello World"); +``` + +## Appearance + +# Headers + +```csharp +// Sets the header +panel.Header = new PanelHeader("Some text"); +``` + +# Borders + +For a list of borders, see the [Borders](xref:borders) appendix section. + +```csharp +// Sets the border +panel.Border = BoxBorder.Ascii; +panel.Border = BoxBorder.Square; +panel.Border = BoxBorder.Rounded; +panel.Border = BoxBorder.Heavy; +panel.Border = BoxBorder.Double; +panel.Border = BoxBorder.None; +``` + +# Padding + +```csharp +// Sets the padding +panel.Padding = new Padding(2, 2, 2, 2); +``` + +# Expand + +Enabling the Expand property will cause the Panel to be as wide as the console. +Otherwise, the Panel width will be automatically calculated based on its content. +Note that this auto-calculation is not based on the Panel Header, so a Header that +is long in length may get truncated with certain content. + +```csharp +// Sets the expand property +panel.Expand = true; +``` \ No newline at end of file diff --git a/resources/scripts/Generator/Commands/AsciiCast/Samples/PanelSample.cs b/resources/scripts/Generator/Commands/AsciiCast/Samples/PanelSample.cs new file mode 100644 index 0000000..b99addf --- /dev/null +++ b/resources/scripts/Generator/Commands/AsciiCast/Samples/PanelSample.cs @@ -0,0 +1,16 @@ +using Spectre.Console; + +namespace Generator.Commands.Samples +{ + internal class PanelSample : BaseSample + { + public override void Run(IAnsiConsole console) + { + var panel = new Panel("[red]Spaghetti\nLinguini\nFettucine\nTortellini\nCapellini\nLasagna[/]"); + panel.Header = new PanelHeader("[underline]Pasta Menu[/]", Justify.Center); + panel.Border = BoxBorder.Double; + panel.Padding = new Padding(2, 2, 2, 2); + console.Write(panel); + } + } +} \ No newline at end of file