-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* canvas * imports * more box drawing * lines * lines * box drawing table * fix box table * tweak test * canvas color * simplify canvas * optimization * clipping * render experiment * keyline css * tests * don't draw around invisible widgets * optimize * snapshot test * docs and examples * tab size * disclaimer * docs * changelog * snapshots * accidental add * rename for consistency * simplify color * docstrings * comment * snapshots * micro optimize * micro-optimization * typing * set over list * remove comment * docstring * punctuation * Update docs/styles/keyline.md Co-authored-by: Darren Burns <[email protected]> --------- Co-authored-by: Darren Burns <[email protected]>
- Loading branch information
1 parent
4c4e724
commit 370f5f7
Showing
25 changed files
with
6,286 additions
and
4,747 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# <keyline> | ||
|
||
The `<keyline>` CSS type represents a line style used in the [keyline](../styles/keyline.md) rule. | ||
|
||
|
||
## Syntax | ||
|
||
| Value | Description | | ||
| -------- | -------------------------- | | ||
| `none` | No line (disable keyline). | | ||
| `thin` | A thin line. | | ||
| `heavy` | A heavy (thicker) line. | | ||
| `double` | A double line. | | ||
|
||
## Examples | ||
|
||
### CSS | ||
|
||
```sass | ||
Vertical { | ||
keyline: thin green; | ||
} | ||
``` | ||
|
||
### Python | ||
|
||
```py | ||
# A tuple of <keyline> and color | ||
widget.styles.keyline = ("thin", "green") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from textual.app import App, ComposeResult | ||
from textual.containers import Grid | ||
from textual.widgets import Placeholder | ||
|
||
|
||
class KeylineApp(App): | ||
CSS_PATH = "keyline.tcss" | ||
|
||
def compose(self) -> ComposeResult: | ||
with Grid(): | ||
yield Placeholder(id="foo") | ||
yield Placeholder(id="bar") | ||
yield Placeholder() | ||
yield Placeholder(classes="hidden") | ||
yield Placeholder(id="baz") | ||
|
||
|
||
if __name__ == "__main__": | ||
KeylineApp().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Grid { | ||
grid-size: 3 3; | ||
grid-gutter: 1; | ||
padding: 2 3; | ||
keyline: heavy green; | ||
} | ||
Placeholder { | ||
height: 1fr; | ||
} | ||
hidden { | ||
visibility: hidden; | ||
} | ||
#foo { | ||
column-span: 2; | ||
} | ||
#bar { | ||
row-span: 2; | ||
} | ||
#baz { | ||
column-span:3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from textual.app import App, ComposeResult | ||
from textual.containers import Horizontal | ||
from textual.widgets import Placeholder | ||
|
||
|
||
class KeylineApp(App): | ||
CSS_PATH = "keyline_horizontal.tcss" | ||
|
||
def compose(self) -> ComposeResult: | ||
with Horizontal(): | ||
yield Placeholder() | ||
yield Placeholder() | ||
yield Placeholder() | ||
|
||
|
||
if __name__ == "__main__": | ||
app = KeylineApp() | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Placeholder { | ||
margin: 1; | ||
width: 1fr; | ||
} | ||
|
||
Horizontal { | ||
keyline: thin $secondary; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Keyline | ||
|
||
The `keyline` style is applied to a container and will draw lines around child widgets. | ||
|
||
A keyline is superficially like the [border](./border.md) rule, but rather than draw inside the widget, a keyline is drawn outside of the widget's border. Additionally, unlike `border`, keylines can overlap and cross to create dividing lines between widgets. | ||
|
||
Because keylines are drawn in the widget's margin, you will need to apply the [margin](./margin.md) or [grid-gutter](./grid/grid_gutter.md) rule to see the effect. | ||
|
||
|
||
## Syntax | ||
|
||
--8<-- "docs/snippets/syntax_block_start.md" | ||
keyline: [<a href="../../css_types/keyline"><keyline></a>] [<a href="../../css_types/color"><color></a>]; | ||
--8<-- "docs/snippets/syntax_block_end.md" | ||
|
||
|
||
## Examples | ||
|
||
### Horizontal Keyline | ||
|
||
The following examples shows a simple horizontal layout with a thin keyline. | ||
|
||
=== "Output" | ||
|
||
```{.textual path="docs/examples/styles/keyline_horizontal.py"} | ||
``` | ||
|
||
=== "keyline.py" | ||
|
||
```python | ||
--8<-- "docs/examples/styles/keyline_horizontal.py" | ||
``` | ||
|
||
=== "keyline.tcss" | ||
|
||
```sass | ||
--8<-- "docs/examples/styles/keyline_horizontal.tcss" | ||
``` | ||
|
||
|
||
|
||
### Grid keyline | ||
|
||
The following examples shows a grid layout with a *heavy* keyline. | ||
|
||
=== "Output" | ||
|
||
```{.textual path="docs/examples/styles/keyline.py"} | ||
``` | ||
|
||
=== "keyline.py" | ||
|
||
```python | ||
--8<-- "docs/examples/styles/keyline.py" | ||
``` | ||
|
||
=== "keyline.tcss" | ||
|
||
```sass | ||
--8<-- "docs/examples/styles/keyline.tcss" | ||
``` | ||
|
||
|
||
## CSS | ||
|
||
```sass | ||
/* Set a thin green keyline */ | ||
/* Note: Must be set on a container or a widget with a layout. */ | ||
keyline: thin green; | ||
``` | ||
|
||
## Python | ||
|
||
You can set a keyline in Python with a tuple of type and color: | ||
|
||
```python | ||
widget.styles.keyline = ("thin", "green") | ||
``` | ||
|
||
|
||
## See also | ||
|
||
- [`border`](./border.md) to add a border around a widget. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.