mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
* Support multiple CSS paths * Update a type to match docstring * Ensure the demo app still works * Use absolute paths in tests to (hopefully) appease Windows * Notes about CSS changes in guide/docstrings, small grammar/typos fixes * Move snapshot apps into snapshot_tests dir, improve messaging in snapshot output, add test for multiple css files interacting with classvar CSS * Ensure consistent snapshot naming cross-platform * Use rpartition instead of partition in import_app * Fix handling of import_app when colon in arg * Support paths containing Windows drive names in import_app * Add note on new relative paths in snap_compare * Update docs/guide/CSS.md Co-authored-by: Will McGugan <willmcgugan@gmail.com> * Fix formatting * Update CHANGELOG to mention CSS_PATH supporting a list Co-authored-by: Will McGugan <willmcgugan@gmail.com>
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
"""Testing multiple CSS files, including app-level CSS
|
|
|
|
-- element #one
|
|
The `background` rule on #one tests a 3-way specificity clash between
|
|
classvar CSS and two separate CSS files. The background ends up red
|
|
because classvar CSS wins.
|
|
The `color` rule tests a clash between loading two external CSS files.
|
|
The color ends up as darkred (from 'second.css'), because that file is loaded
|
|
second and wins.
|
|
|
|
-- element #two
|
|
This element tests that separate rules applied to the same widget are mixed
|
|
correctly. The color is set to cadetblue in 'first.css', and the background is
|
|
darkolivegreen in 'second.css'. Both of these should apply.
|
|
"""
|
|
from textual.app import App, ComposeResult
|
|
from textual.widgets import Static
|
|
|
|
|
|
class MultipleCSSApp(App):
|
|
CSS = """
|
|
#one {
|
|
background: red;
|
|
}
|
|
"""
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Static("#one", id="one")
|
|
yield Static("#two", id="two")
|
|
|
|
|
|
app = MultipleCSSApp(css_path=["first.css", "second.css"])
|
|
if __name__ == '__main__':
|
|
app.run()
|