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 { #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;
} }

View File

@@ -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.
""" """

View File

@@ -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"
),
)