From c1b611bac97b1666b72d20bcc4789d8c668c54ff Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 16 Aug 2023 13:10:26 +0100 Subject: [PATCH] Grid auto (#3107) * test * snapshot * changelog --- CHANGELOG.md | 2 +- .../__snapshots__/test_snapshots.ambr | 160 ++++++++++++++++++ .../snapshot_tests/snapshot_apps/auto_grid.py | 32 ++++ 3 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 tests/snapshot_tests/snapshot_apps/auto_grid.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d9280334c..4911c22c1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed -- grid-columns and grid-rows now accept an `auto` token to detect the optimal size. +- grid-columns and grid-rows now accept an `auto` token to detect the optimal size https://github.com/Textualize/textual/pull/3107 ## [0.33.0] - 2023-08-15 diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr index 1802220c43..7a00c471b5 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr +++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr @@ -324,6 +324,166 @@ ''' # --- +# name: test_auto_grid + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GridApp + + + + + + + + + + + + + + + + + + ────────────────────────────────────────────────────────────────────────────── + foo▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + + ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + Longer label▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + + ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + ────────────────────────────────────────────────────────────────────────────── + + + + + + + + + + + + + ''' +# --- # name: test_auto_table ''' diff --git a/tests/snapshot_tests/snapshot_apps/auto_grid.py b/tests/snapshot_tests/snapshot_apps/auto_grid.py new file mode 100644 index 0000000000..acabdaff62 --- /dev/null +++ b/tests/snapshot_tests/snapshot_apps/auto_grid.py @@ -0,0 +1,32 @@ +from textual.app import App, ComposeResult +from textual.widgets import Label, Input +from textual.containers import Container + + +class GridApp(App): + CSS = """ + Screen { + align: center middle; + } + Container { + layout: grid; + grid-size: 2; + grid-columns: auto 1fr; + grid-rows: auto; + height:auto; + border: solid green; + } + + """ + + def compose(self) -> ComposeResult: + with Container(): + yield Label("foo") + yield Input() + yield Label("Longer label") + yield Input() + + +if __name__ == "__main__": + app = GridApp() + app.run()