mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Docs scrollbar gutter (#695)
* Add scrollbar-gutter docs * Add scrollbar-gutter docs * Add syntax and values section * Rewording
This commit is contained in:
@@ -2,11 +2,12 @@
|
|||||||
# See https://pre-commit.com/hooks.html for more hooks
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.2.0
|
rev: v4.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
|
args: ['--unsafe']
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 22.3.0
|
rev: 22.3.0
|
||||||
hooks:
|
hooks:
|
||||||
|
|||||||
28
docs/examples/styles/scrollbar_gutter.py
Normal file
28
docs/examples/styles/scrollbar_gutter.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from textual.app import App
|
||||||
|
from textual.widgets import Static
|
||||||
|
|
||||||
|
TEXT = """I must not fear.
|
||||||
|
Fear is the mind-killer.
|
||||||
|
Fear is the little-death that brings total obliteration.
|
||||||
|
I will face my fear.
|
||||||
|
I will permit it to pass over me and through me.
|
||||||
|
And when it has gone past, I will turn the inner eye to see its path.
|
||||||
|
Where the fear has gone there will be nothing. Only I will remain."""
|
||||||
|
|
||||||
|
|
||||||
|
class ScrollbarGutterApp(App):
|
||||||
|
CSS = """
|
||||||
|
Screen {
|
||||||
|
scrollbar-gutter: stable;
|
||||||
|
}
|
||||||
|
Static {
|
||||||
|
color: floralwhite;
|
||||||
|
background: darkmagenta;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
def compose(self):
|
||||||
|
yield Static(TEXT)
|
||||||
|
|
||||||
|
|
||||||
|
app = ScrollbarGutterApp()
|
||||||
47
docs/styles/scrollbar_gutter.md
Normal file
47
docs/styles/scrollbar_gutter.md
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Scrollbar gutter
|
||||||
|
|
||||||
|
The `scrollbar-gutter` rule allows authors to reserve space for the vertical scrollbar.
|
||||||
|
|
||||||
|
Setting the value to `stable` prevents unwanted layout changes when the scrollbar becomes visible.
|
||||||
|
|
||||||
|
## Syntax
|
||||||
|
|
||||||
|
```
|
||||||
|
scrollbar-gutter: [auto|stable];
|
||||||
|
```
|
||||||
|
|
||||||
|
### Values
|
||||||
|
|
||||||
|
| Value | Description |
|
||||||
|
|------------------|--------------------------------------------------|
|
||||||
|
| `auto` (default) | No space is reserved for the vertical scrollbar. |
|
||||||
|
| `stable` | Space is reserved for the vertical scrollbar. |
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
In the example below, notice the gap reserved for the scrollbar on the right side of the
|
||||||
|
terminal window.
|
||||||
|
|
||||||
|
=== "scrollbar_gutter.py"
|
||||||
|
|
||||||
|
```python
|
||||||
|
--8<-- "docs/examples/styles/scrollbar_gutter.py"
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "Output"
|
||||||
|
|
||||||
|
```{.textual path="docs/examples/styles/scrollbar_gutter.py"}
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS
|
||||||
|
|
||||||
|
```sass
|
||||||
|
/* Reserve space for vertical scrollbar */
|
||||||
|
scrollbar-gutter: stable;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Python
|
||||||
|
|
||||||
|
```python
|
||||||
|
self.styles.scrollbar_gutter = "stable"
|
||||||
|
```
|
||||||
@@ -10,7 +10,7 @@ nav:
|
|||||||
- Events:
|
- Events:
|
||||||
- "events/mount.md"
|
- "events/mount.md"
|
||||||
- "events/resize.md"
|
- "events/resize.md"
|
||||||
- Styles:
|
- Styles:
|
||||||
- "styles/background.md"
|
- "styles/background.md"
|
||||||
- "styles/border.md"
|
- "styles/border.md"
|
||||||
- "styles/box_sizing.md"
|
- "styles/box_sizing.md"
|
||||||
@@ -28,6 +28,7 @@ nav:
|
|||||||
- "styles/padding.md"
|
- "styles/padding.md"
|
||||||
- "styles/scrollbar.md"
|
- "styles/scrollbar.md"
|
||||||
- "styles/scrollbar_size.md"
|
- "styles/scrollbar_size.md"
|
||||||
|
- "styles/scrollbar_gutter.md"
|
||||||
- "styles/text_style.md"
|
- "styles/text_style.md"
|
||||||
- "styles/tint.md"
|
- "styles/tint.md"
|
||||||
- "styles/visibility.md"
|
- "styles/visibility.md"
|
||||||
@@ -60,7 +61,7 @@ markdown_extensions:
|
|||||||
- pymdownx.superfences
|
- pymdownx.superfences
|
||||||
- pymdownx.snippets
|
- pymdownx.snippets
|
||||||
- pymdownx.tabbed:
|
- pymdownx.tabbed:
|
||||||
alternate_style: true
|
alternate_style: true
|
||||||
- pymdownx.snippets
|
- pymdownx.snippets
|
||||||
- markdown.extensions.attr_list
|
- markdown.extensions.attr_list
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user