-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1640 from Textualize/fix-1406
Correct the dimension relative units in grid-rows/columns were assigned to
- Loading branch information
Showing
5 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Regression tests for #1406 https://github.com/Textualize/textual/issues/1406 | ||
The scalars in grid-rows and grid-columns were not aware of the dimension | ||
they should be relative to. | ||
""" | ||
|
||
from textual.css.parse import parse_declarations | ||
from textual.css.scalar import Unit | ||
from textual.css.styles import Styles | ||
|
||
|
||
def test_grid_rows_columns_relative_units_are_correct(): | ||
"""Ensure correct relative dimensions for programmatic assignments.""" | ||
|
||
styles = Styles() | ||
|
||
styles.grid_columns = "1fr 5%" | ||
fr, percent = styles.grid_columns | ||
assert fr.percent_unit == Unit.WIDTH | ||
assert percent.percent_unit == Unit.WIDTH | ||
|
||
styles.grid_rows = "1fr 5%" | ||
fr, percent = styles.grid_rows | ||
assert fr.percent_unit == Unit.HEIGHT | ||
assert percent.percent_unit == Unit.HEIGHT | ||
|
||
|
||
def test_styles_builder_uses_correct_relative_units_grid_rows_columns(): | ||
"""Ensure correct relative dimensions for CSS parsed from files.""" | ||
|
||
CSS = "grid-rows: 1fr 5%; grid-columns: 1fr 5%;" | ||
|
||
styles = parse_declarations(CSS, "test") | ||
|
||
fr, percent = styles.grid_columns | ||
assert fr.percent_unit == Unit.WIDTH | ||
assert percent.percent_unit == Unit.WIDTH | ||
|
||
fr, percent = styles.grid_rows | ||
assert fr.percent_unit == Unit.HEIGHT | ||
assert percent.percent_unit == Unit.HEIGHT |