From de6a4794343bc0d2dea462178951d235e2813866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Wed, 27 Sep 2023 17:41:39 +0100 Subject: [PATCH] Snapshot test to keep tabs on opacity. This snapshot will be used to make sure that the opacity is being taken into account when rendering widgets. This shows that some of the issues in #3304 and #3413. --- .../component_classes_opacity.py | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/snapshot_tests/snapshot_apps/component_classes_opacity.py diff --git a/tests/snapshot_tests/snapshot_apps/component_classes_opacity.py b/tests/snapshot_tests/snapshot_apps/component_classes_opacity.py new file mode 100644 index 0000000000..a0aaee726c --- /dev/null +++ b/tests/snapshot_tests/snapshot_apps/component_classes_opacity.py @@ -0,0 +1,72 @@ +from textual.app import App, ComposeResult +from textual.widgets import ( + Checkbox, + OptionList, + DataTable, + DirectoryTree, + Footer, + Input, + ProgressBar, + RadioButton, + SelectionList, + Switch, + Tree, +) +from textual.widgets.option_list import Option + + +class ComponentClassesOpacity(App[None]): + BINDINGS = [("n", "notification", "random Notification")] + + CSS = """ + * { + max-height: 3; + } + Checkbox > .toggle--label, + DataTable > .datatable--header, + DirectoryTree > .directory-tree--file, + DirectoryTree > .directory-tree--folder, + Footer > .footer--description, + Footer > .footer--key, + Input > .input--placeholder, + OptionList > .option-list--option-highlighted, + ProgressBar Bar > .bar--indeterminate, + RadioButton > .toggle--label, + SelectionList > .selection-list--button-highlighted, + Switch > .switch--slider, + Toast > .toast--title, + Tree > .tree--label { + text-opacity: 0%; + color: white; + } + """ + + def compose(self) -> ComposeResult: + yield Checkbox("this should be invisible") + dt = DataTable() + dt.add_column("this should be invisible") + yield dt + yield DirectoryTree(".") + yield Footer() + yield Input(placeholder="this should be invisible") + yield OptionList(Option("this should be invisible")) + yield ProgressBar() + yield RadioButton("this should be invisible") + yield SelectionList(("this should be invisible", 0)) + yield Switch() + tree: Tree = Tree("Dune") + tree.root.expand() + characters = tree.root.add("Characters", expand=True) + characters.add_leaf("Paul") + characters.add_leaf("Jessica") + characters.add_leaf("Chani") + yield tree + + def action_notification(self): + self.notify( + title="this should be invisible", message="this should be invisible" + ) + + +if __name__ == "__main__": + ComponentClassesOpacity().run()