mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Ensure help text for align appears
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
#uber1 {
|
#uber1 {
|
||||||
layout: vertical;
|
layout: vertical;
|
||||||
background: dark_green;
|
background: dark_green;
|
||||||
overflow: auto auto;
|
overflow: hidden auto;
|
||||||
border: heavy white;
|
border: heavy white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-item {
|
.list-item {
|
||||||
height: 8;
|
height: 8;
|
||||||
align: center middle;
|
align: centear middlex;
|
||||||
background: dark_blue;
|
background: dark_blue;
|
||||||
border: solid red;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ class LayoutProperty:
|
|||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
obj (Styles): The Styles object.
|
obj (Styles): The Styles object.
|
||||||
layout (str | Layout): The layout to use. You can supply a the name of the layout
|
layout (str | Layout): The layout to use. You can supply the name of the layout
|
||||||
or a ``Layout`` object.
|
or a ``Layout`` object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ from .constants import (
|
|||||||
VALID_OVERFLOW,
|
VALID_OVERFLOW,
|
||||||
VALID_VISIBILITY,
|
VALID_VISIBILITY,
|
||||||
)
|
)
|
||||||
from .errors import DeclarationError
|
from .errors import DeclarationError, StyleValueError
|
||||||
from .model import Declaration
|
from .model import Declaration
|
||||||
from .scalar import Scalar, ScalarOffset, Unit, ScalarError, ScalarParseError
|
from .scalar import Scalar, ScalarOffset, Unit, ScalarError, ScalarParseError
|
||||||
from .styles import DockGroup, Styles
|
from .styles import DockGroup, Styles
|
||||||
@@ -657,30 +657,50 @@ class StylesBuilder:
|
|||||||
self.styles._rules["transitions"] = transitions
|
self.styles._rules["transitions"] = transitions
|
||||||
|
|
||||||
def process_align(self, name: str, tokens: list[Token]) -> None:
|
def process_align(self, name: str, tokens: list[Token]) -> None:
|
||||||
|
def align_error(name, token):
|
||||||
|
self.error(name, token, align_help_text())
|
||||||
|
|
||||||
if len(tokens) != 2:
|
if len(tokens) != 2:
|
||||||
self.error(name, tokens[0], align_help_text())
|
self.error(name, tokens[0], align_help_text())
|
||||||
|
|
||||||
token_horizontal = tokens[0]
|
token_horizontal = tokens[0]
|
||||||
token_vertical = tokens[1]
|
token_vertical = tokens[1]
|
||||||
|
|
||||||
if token_horizontal.name != "token":
|
if token_horizontal.name != "token":
|
||||||
self.error(
|
align_error(name, token_horizontal)
|
||||||
name,
|
elif token_horizontal.value not in VALID_ALIGN_HORIZONTAL:
|
||||||
token_horizontal,
|
align_error(name, token_horizontal)
|
||||||
align_help_text(),
|
|
||||||
)
|
|
||||||
if token_vertical.name != "token":
|
if token_vertical.name != "token":
|
||||||
self.error(
|
align_error(name, token_vertical)
|
||||||
name,
|
elif token_horizontal.value not in VALID_ALIGN_VERTICAL:
|
||||||
token_vertical,
|
align_error(name, token_horizontal)
|
||||||
align_help_text(),
|
|
||||||
)
|
|
||||||
|
|
||||||
self.styles._rules["align_horizontal"] = token_horizontal.value
|
self.styles._rules["align_horizontal"] = token_horizontal.value
|
||||||
self.styles._rules["align_vertical"] = token_vertical.value
|
self.styles._rules["align_vertical"] = token_vertical.value
|
||||||
|
|
||||||
def process_align_horizontal(self, name: str, tokens: list[Token]) -> None:
|
def process_align_horizontal(self, name: str, tokens: list[Token]) -> None:
|
||||||
value = self._process_enum(name, tokens, VALID_ALIGN_HORIZONTAL)
|
try:
|
||||||
self.styles._rules["align_horizontal"] = value
|
value = self._process_enum(name, tokens, VALID_ALIGN_HORIZONTAL)
|
||||||
|
self.styles._rules["align_horizontal"] = value
|
||||||
|
except StyleValueError:
|
||||||
|
self.error(
|
||||||
|
name,
|
||||||
|
tokens[0],
|
||||||
|
string_enum_help_text(
|
||||||
|
"align-horizontal", VALID_ALIGN_HORIZONTAL, context="css"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def process_align_vertical(self, name: str, tokens: list[Token]) -> None:
|
def process_align_vertical(self, name: str, tokens: list[Token]) -> None:
|
||||||
value = self._process_enum(name, tokens, VALID_ALIGN_VERTICAL)
|
try:
|
||||||
self.styles._rules["align_vertical"] = value
|
value = self._process_enum(name, tokens, VALID_ALIGN_VERTICAL)
|
||||||
|
self.styles._rules["align_vertical"] = value
|
||||||
|
except StyleValueError:
|
||||||
|
self.error(
|
||||||
|
name,
|
||||||
|
tokens[0],
|
||||||
|
string_enum_help_text(
|
||||||
|
"align-vertical", VALID_ALIGN_VERTICAL, context="css"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user