Create panel documentation

This commit is contained in:
Patrick 2022-10-03 21:34:59 -07:00 committed by Patrik Svensson
parent d7babcc6e4
commit 5f1121e8e1
4 changed files with 83 additions and 0 deletions

View File

@ -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"]

View File

@ -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"]

View File

@ -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.
<?# AsciiCast cast="panel" /?>
## 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;
```

View File

@ -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);
}
}
}