mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
@@ -106,16 +106,18 @@ def test_stylesheet_apply_user_css_over_widget_css():
|
||||
user_css = ".a {color: red; tint: yellow;}"
|
||||
|
||||
class MyWidget(Widget):
|
||||
CSS = ".a {color: blue !important; background: lime;}"
|
||||
DEFAULT_CSS = ".a {color: blue !important; background: lime;}"
|
||||
|
||||
node = MyWidget()
|
||||
node.add_class("a")
|
||||
|
||||
stylesheet = _make_user_stylesheet(user_css)
|
||||
stylesheet.add_source(MyWidget.CSS, "widget.py:MyWidget", is_default_css=True)
|
||||
stylesheet.add_source(
|
||||
MyWidget.DEFAULT_CSS, "widget.py:MyWidget", is_default_css=True
|
||||
)
|
||||
stylesheet.apply(node)
|
||||
|
||||
# The node is red because user CSS overrides Widget.CSS
|
||||
# The node is red because user CSS overrides Widget.DEFAULT_CSS
|
||||
assert node.styles.color == Color(255, 0, 0)
|
||||
# The background colour defined in the Widget still applies, since user CSS doesn't override it
|
||||
assert node.styles.background == Color(0, 255, 0)
|
||||
|
||||
@@ -110,7 +110,7 @@ async def test_composition_of_vertical_container_with_children(
|
||||
expected_placeholders_offset_x: int,
|
||||
):
|
||||
class VerticalContainer(Widget):
|
||||
CSS = (
|
||||
DEFAULT_CSS = (
|
||||
"""
|
||||
VerticalContainer {
|
||||
layout: vertical;
|
||||
@@ -304,7 +304,7 @@ async def test_scrollbar_size_impact_on_the_layout(
|
||||
class LargeWidgetContainer(Widget):
|
||||
# TODO: Once textual#581 ("Default versus User CSS") is solved the following CSS should just use the
|
||||
# "LargeWidgetContainer" selector, without having to use a more specific one to be able to override Widget's CSS:
|
||||
CSS = """
|
||||
DEFAULT_CSS = """
|
||||
#large-widget-container {
|
||||
width: 20;
|
||||
height: 20;
|
||||
|
||||
@@ -48,7 +48,7 @@ async def test_scroll_to_widget(
|
||||
last_screen_expected_placeholder_ids: Sequence[int],
|
||||
):
|
||||
class VerticalContainer(Widget):
|
||||
CSS = """
|
||||
DEFAULT_CSS = """
|
||||
VerticalContainer {
|
||||
layout: vertical;
|
||||
overflow: hidden auto;
|
||||
@@ -60,7 +60,7 @@ async def test_scroll_to_widget(
|
||||
"""
|
||||
|
||||
class MyTestApp(AppTest):
|
||||
CSS = """
|
||||
DEFAULT_CSS = """
|
||||
Placeholder {
|
||||
height: 5; /* minimal height to see the name of a Placeholder */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user