Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs scrollbar gutter #695

Merged
merged 4 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: ['--unsafe']
willmcgugan marked this conversation as resolved.
Show resolved Hide resolved
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
Expand Down
28 changes: 28 additions & 0 deletions docs/examples/styles/scrollbar_gutter.py
Original file line number Diff line number Diff line change
@@ -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()
48 changes: 48 additions & 0 deletions docs/styles/scrollbar_gutter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Scrollbar gutter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a Syntax section. See the docs-intro branch for examples...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Syntax section, with a child Values section.

The Values section is probably where we'd link off to "types" e.g. color, scalar, etc.

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the Values section. Will add a task to review existing styles.


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 a vertical scrollbar. |
| `stable` | Space is reserved for a 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"}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely love this plugin

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kind of magical!

```

## CSS

```sass
/* Reserve space for vertical scrollbar */
scrollbar-gutter: stable;
```

## Python

```python
self.styles.scrollbar_gutter = "stable"
```
5 changes: 3 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nav:
- Events:
- "events/mount.md"
- "events/resize.md"
- Styles:
- Styles:
- "styles/background.md"
- "styles/border.md"
- "styles/box_sizing.md"
Expand All @@ -28,6 +28,7 @@ nav:
- "styles/padding.md"
- "styles/scrollbar.md"
- "styles/scrollbar_size.md"
- "styles/scrollbar_gutter.md"
- "styles/text_style.md"
- "styles/tint.md"
- "styles/visibility.md"
Expand Down Expand Up @@ -60,7 +61,7 @@ markdown_extensions:
- pymdownx.superfences
- pymdownx.snippets
- pymdownx.tabbed:
alternate_style: true
alternate_style: true
- pymdownx.snippets
- markdown.extensions.attr_list

Expand Down