Skip to content

Commit 5f1121e

Browse files
patrickfreilingerpatriksvensson
authored andcommitted
Create panel documentation
1 parent d7babcc commit 5f1121e

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{"version": 2, "width": 122, "height": 24, "title": "panel (plain)", "env": {"TERM": "Spectre.Console"}}
2+
[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"]
3+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{"version": 2, "width": 122, "height": 24, "title": "panel (rich)", "env": {"TERM": "Spectre.Console"}}
2+
[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"]
3+

docs/input/widgets/panel.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Title: Panel
2+
Order: 0
3+
RedirectFrom: panels
4+
Description: "The **Panel** widget can be used to organize text into a rendered box."
5+
Reference: T:Spectre.Console.Panel
6+
7+
---
8+
9+
The `Panel` widget can be used to organize text into a rendered box.
10+
11+
<?# AsciiCast cast="panel" /?>
12+
13+
## Usage
14+
15+
To render a table, create a `Table` instance, passing a string to its constructor to assign the contents.
16+
17+
```csharp
18+
var panel = new Panel("Hello World");
19+
```
20+
21+
## Appearance
22+
23+
# Headers
24+
25+
```csharp
26+
// Sets the header
27+
panel.Header = new PanelHeader("Some text");
28+
```
29+
30+
# Borders
31+
32+
For a list of borders, see the [Borders](xref:borders) appendix section.
33+
34+
```csharp
35+
// Sets the border
36+
panel.Border = BoxBorder.Ascii;
37+
panel.Border = BoxBorder.Square;
38+
panel.Border = BoxBorder.Rounded;
39+
panel.Border = BoxBorder.Heavy;
40+
panel.Border = BoxBorder.Double;
41+
panel.Border = BoxBorder.None;
42+
```
43+
44+
# Padding
45+
46+
```csharp
47+
// Sets the padding
48+
panel.Padding = new Padding(2, 2, 2, 2);
49+
```
50+
51+
# Expand
52+
53+
Enabling the Expand property will cause the Panel to be as wide as the console.
54+
Otherwise, the Panel width will be automatically calculated based on its content.
55+
Note that this auto-calculation is not based on the Panel Header, so a Header that
56+
is long in length may get truncated with certain content.
57+
58+
```csharp
59+
// Sets the expand property
60+
panel.Expand = true;
61+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Spectre.Console;
2+
3+
namespace Generator.Commands.Samples
4+
{
5+
internal class PanelSample : BaseSample
6+
{
7+
public override void Run(IAnsiConsole console)
8+
{
9+
var panel = new Panel("[red]Spaghetti\nLinguini\nFettucine\nTortellini\nCapellini\nLasagna[/]");
10+
panel.Header = new PanelHeader("[underline]Pasta Menu[/]", Justify.Center);
11+
panel.Border = BoxBorder.Double;
12+
panel.Padding = new Padding(2, 2, 2, 2);
13+
console.Write(panel);
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)