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

PR: Add vertical align #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
22 changes: 22 additions & 0 deletions colosseum/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,29 @@ def value(self, context):
# 10.8 Leading and half-leading
######################################################################
# line_height

# vertical_align
BASELINE = 'baseline'
SUB = 'sub'
SUPER = 'super'
TOP = 'top'
TEXT_TOP = 'text-top'
MIDDLE = 'middle'
BOTTOM = 'bottom'
TEXT_BOTTOM = 'text-bottom'

VERTICAL_ALIGN_CHOICES = Choices(
BASELINE,
SUB,
SUPER,
TOP,
TEXT_TOP,
MIDDLE,
BOTTOM,
TEXT_BOTTOM,
validators=[is_percentage, is_length],
explicit_defaulting_constants=[INHERIT],
)

######################################################################
# 11.1.1 Overflow
Expand Down
44 changes: 23 additions & 21 deletions colosseum/declaration.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
from . import engine as css_engine
from . import parser
from . import engine as css_engine, parser
from .constants import ( # noqa
ALIGN_CONTENT_CHOICES, ALIGN_ITEMS_CHOICES, ALIGN_SELF_CHOICES, AUTO,
BACKGROUND_COLOR_CHOICES, BORDER_COLLAPSE_CHOICES, BORDER_COLOR_CHOICES,
BORDER_SPACING_CHOICES, BORDER_STYLE_CHOICES, BORDER_WIDTH_CHOICES,
BOX_OFFSET_CHOICES, CAPTION_SIDE_CHOICES, CLEAR_CHOICES, CLIP_CHOICES,
COLOR_CHOICES, DIRECTION_CHOICES, DISPLAY_CHOICES, EMPTY_CELLS_CHOICES,
FLEX_BASIS_CHOICES, FLEX_DIRECTION_CHOICES, FLEX_GROW_CHOICES,
FLEX_SHRINK_CHOICES, FLEX_START, FLEX_WRAP_CHOICES, FLOAT_CHOICES,
GRID_AUTO_CHOICES, GRID_AUTO_FLOW_CHOICES, GRID_GAP_CHOICES,
GRID_PLACEMENT_CHOICES, GRID_TEMPLATE_AREA_CHOICES, GRID_TEMPLATE_CHOICES,
INITIAL, INLINE, INVERT, JUSTIFY_CONTENT_CHOICES, LETTER_SPACING_CHOICES,
LTR, MARGIN_CHOICES, MAX_SIZE_CHOICES, MEDIUM, MIN_SIZE_CHOICES, NORMAL,
NOWRAP, ORDER_CHOICES, ORPHANS_CHOICES, OUTLINE_COLOR_CHOICES,
OUTLINE_STYLE_CHOICES, OUTLINE_WIDTH_CHOICES, OVERFLOW_CHOICES,
PADDING_CHOICES, PAGE_BREAK_AFTER_CHOICES, PAGE_BREAK_BEFORE_CHOICES,
PAGE_BREAK_INSIDE_CHOICES, POSITION_CHOICES, QUOTES_CHOICES, ROW,
SEPARATE, SHOW, SIZE_CHOICES, STATIC, STRETCH, TABLE_LAYOUT_CHOICES,
BACKGROUND_COLOR_CHOICES, BASELINE, BORDER_COLLAPSE_CHOICES,
BORDER_COLOR_CHOICES, BORDER_SPACING_CHOICES, BORDER_STYLE_CHOICES,
BORDER_WIDTH_CHOICES, BOX_OFFSET_CHOICES, CAPTION_SIDE_CHOICES,
CLEAR_CHOICES, CLIP_CHOICES, COLOR_CHOICES, DIRECTION_CHOICES,
DISPLAY_CHOICES, EMPTY_CELLS_CHOICES, FLEX_BASIS_CHOICES,
FLEX_DIRECTION_CHOICES, FLEX_GROW_CHOICES, FLEX_SHRINK_CHOICES, FLEX_START,
FLEX_WRAP_CHOICES, FLOAT_CHOICES, GRID_AUTO_CHOICES,
GRID_AUTO_FLOW_CHOICES, GRID_GAP_CHOICES, GRID_PLACEMENT_CHOICES,
GRID_TEMPLATE_AREA_CHOICES, GRID_TEMPLATE_CHOICES, INITIAL, INLINE, INVERT,
JUSTIFY_CONTENT_CHOICES, LETTER_SPACING_CHOICES, LTR, MARGIN_CHOICES,
MAX_SIZE_CHOICES, MEDIUM, MIN_SIZE_CHOICES, NORMAL, NOWRAP, ORDER_CHOICES,
ORPHANS_CHOICES, OUTLINE_COLOR_CHOICES, OUTLINE_STYLE_CHOICES,
OUTLINE_WIDTH_CHOICES, OVERFLOW_CHOICES, PADDING_CHOICES,
PAGE_BREAK_AFTER_CHOICES, PAGE_BREAK_BEFORE_CHOICES,
PAGE_BREAK_INSIDE_CHOICES, POSITION_CHOICES, QUOTES_CHOICES, ROW, SEPARATE,
SHOW, SIZE_CHOICES, STATIC, STRETCH, TABLE_LAYOUT_CHOICES,
TEXT_ALIGN_CHOICES, TEXT_DECORATION_CHOICES, TEXT_INDENT_CHOICES,
TEXT_TRANSFORM_CHOICES, TOP, TRANSPARENT, UNICODE_BIDI_CHOICES,
VISIBILITY_CHOICES, VISIBLE, WHITE_SPACE_CHOICES, WIDOWS_CHOICES,
WORD_SPACING_CHOICES, Z_INDEX_CHOICES, OtherProperty,
VERTICAL_ALIGN_CHOICES, VISIBILITY_CHOICES, VISIBLE, WHITE_SPACE_CHOICES,
WIDOWS_CHOICES, WORD_SPACING_CHOICES, Z_INDEX_CHOICES, OtherProperty,
Copy link
Member

Choose a reason for hiding this comment

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

Given the frequency with which this block is causing merge conflicts, we may want to move to either an import * (with a well defined __all__ and a NOQA to silence the warning)

TextAlignInitialValue, default,
)
from .exceptions import ValidationError
from .wrappers import Border, BorderBottom, BorderLeft, BorderRight, BorderTop, Outline
from .wrappers import (
Border, BorderBottom, BorderLeft, BorderRight, BorderTop, Outline,
)

_CSS_PROPERTIES = set()

Expand Down Expand Up @@ -305,7 +307,7 @@ def __init__(self, **style):

# 10.8 Leading and half-leading
# line_height
# vertical_align
vertical_align = validated_property('vertical_align', choices=VERTICAL_ALIGN_CHOICES, initial=BASELINE)

# 11. Visual effects #################################################
# 11.1.1 Overflow
Expand Down