mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add help text for dock property
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
}
|
||||
|
||||
.list-item {
|
||||
dock: ac2 2;
|
||||
height: 8;
|
||||
min-width: 80;
|
||||
background: dark_blue;
|
||||
|
||||
@@ -352,3 +352,32 @@ def docks_property_help_text(
|
||||
).get_by_context(context)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def dock_property_help_text(
|
||||
property_name: str, context: StylingContext | None
|
||||
) -> HelpText:
|
||||
property_name = _contextualize_property_name(property_name, context)
|
||||
return HelpText(
|
||||
summary=f"Invalid value for [i]{property_name}[/] property",
|
||||
bullets=[
|
||||
Bullet("The value must be one of the defined docks"),
|
||||
*ContextSpecificBullets(
|
||||
inline=[],
|
||||
css=[
|
||||
Bullet(
|
||||
"Define a dock using the [i]docks[/] property",
|
||||
examples=[
|
||||
Example("docks: [u]lhs[/]=left/2;"),
|
||||
],
|
||||
),
|
||||
Bullet(
|
||||
"Then attach a widget to a defined dock using the [i]dock[/] property",
|
||||
examples=[
|
||||
Example("dock: [scope.key][u]lhs[/][/];"),
|
||||
],
|
||||
),
|
||||
],
|
||||
).get_by_context(context),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -15,6 +15,7 @@ from ._help_text import (
|
||||
border_property_help_text,
|
||||
layout_property_help_text,
|
||||
docks_property_help_text,
|
||||
dock_property_help_text,
|
||||
)
|
||||
from .constants import (
|
||||
VALID_ALIGN_HORIZONTAL,
|
||||
@@ -553,7 +554,7 @@ class StylesBuilder:
|
||||
self.error(
|
||||
name,
|
||||
tokens[1],
|
||||
f"unexpected tokens in dock declaration",
|
||||
dock_property_help_text(name, context="css"),
|
||||
)
|
||||
self.styles._rules["dock"] = tokens[0].value if tokens else ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user