Ensure help text for align appears

This commit is contained in:
Darren Burns
2022-04-26 15:41:33 +01:00
parent e2dafb523c
commit 39412c11a9
3 changed files with 38 additions and 19 deletions

View File

@@ -1,13 +1,12 @@
#uber1 {
layout: vertical;
background: dark_green;
overflow: auto auto;
overflow: hidden auto;
border: heavy white;
}
.list-item {
height: 8;
align: center middle;
align: centear middlex;
background: dark_blue;
border: solid red;
}

View File

@@ -515,7 +515,7 @@ class LayoutProperty:
"""
Args:
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.
"""

View File

@@ -29,7 +29,7 @@ from .constants import (
VALID_OVERFLOW,
VALID_VISIBILITY,
)
from .errors import DeclarationError
from .errors import DeclarationError, StyleValueError
from .model import Declaration
from .scalar import Scalar, ScalarOffset, Unit, ScalarError, ScalarParseError
from .styles import DockGroup, Styles
@@ -657,30 +657,50 @@ class StylesBuilder:
self.styles._rules["transitions"] = transitions
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:
self.error(name, tokens[0], align_help_text())
token_horizontal = tokens[0]
token_vertical = tokens[1]
if token_horizontal.name != "token":
self.error(
name,
token_horizontal,
align_help_text(),
)
align_error(name, token_horizontal)
elif token_horizontal.value not in VALID_ALIGN_HORIZONTAL:
align_error(name, token_horizontal)
if token_vertical.name != "token":
self.error(
name,
token_vertical,
align_help_text(),
)
align_error(name, token_vertical)
elif token_horizontal.value not in VALID_ALIGN_VERTICAL:
align_error(name, token_horizontal)
self.styles._rules["align_horizontal"] = token_horizontal.value
self.styles._rules["align_vertical"] = token_vertical.value
def process_align_horizontal(self, name: str, tokens: list[Token]) -> None:
try:
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:
try:
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"
),
)