mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
css output fix
This commit is contained in:
@@ -17,7 +17,6 @@ class BasicApp(App):
|
||||
footer=Widget(),
|
||||
sidebar=Widget(),
|
||||
)
|
||||
self.panic(self.stylesheet.css)
|
||||
|
||||
|
||||
BasicApp.run(css_file="basic.css", watch_css=True, log="textual.log")
|
||||
|
||||
@@ -333,14 +333,20 @@ class StyleProperty:
|
||||
rules.pop("text_background")
|
||||
rules.pop("text_style")
|
||||
elif isinstance(style, Style):
|
||||
rules_set("text_color", style.color)
|
||||
rules_set("text_background", style.bgcolor)
|
||||
rules_set("text_style", style.without_color)
|
||||
if style.color:
|
||||
rules_set("text_color", style.color)
|
||||
if style.bgcolor:
|
||||
rules_set("text_background", style.bgcolor)
|
||||
if style.without_color:
|
||||
rules_set("text_style", style.without_color)
|
||||
elif isinstance(style, str):
|
||||
new_style = Style.parse(style)
|
||||
rules_set("text_color", new_style.color)
|
||||
rules_set("text_background", new_style.bgcolor)
|
||||
rules_set("text_style", new_style.without_color)
|
||||
if new_style.color:
|
||||
rules_set("text_color", new_style.color or Color.default())
|
||||
if new_style.bgcolor:
|
||||
rules_set("text_background", new_style.bgcolor or Color.default())
|
||||
if new_style.without_color:
|
||||
rules_set("text_style", new_style.without_color)
|
||||
|
||||
|
||||
class SpacingProperty:
|
||||
|
||||
@@ -307,7 +307,7 @@ class StylesBuilder:
|
||||
self.styles.important.update(
|
||||
{"text_style", "text_background", "text_color"}
|
||||
)
|
||||
self.styles._rules["text"] = style
|
||||
self.styles.text = style
|
||||
|
||||
def process_text_color(
|
||||
self, name: str, tokens: list[Token], important: bool
|
||||
|
||||
@@ -352,6 +352,9 @@ class Styles:
|
||||
rules = self.get_rules()
|
||||
get_rule = rules.get
|
||||
has_rule = rules.__contains__
|
||||
from rich import print
|
||||
|
||||
print(rules)
|
||||
|
||||
if has_rule("display"):
|
||||
append_declaration("display", rules["display"])
|
||||
@@ -397,9 +400,9 @@ class Styles:
|
||||
append_declaration("text", str(self.text))
|
||||
else:
|
||||
if has_rule("text_color"):
|
||||
append_declaration("text-color", str(get_rule("text_color")))
|
||||
append_declaration("text-color", get_rule("text_color").name)
|
||||
if has_rule("text_bgcolor"):
|
||||
append_declaration("text-bgcolor", str(get_rule("text_bgcolor")))
|
||||
append_declaration("text-bgcolor", str(get_rule("text_bgcolor").name))
|
||||
if has_rule("text_style"):
|
||||
append_declaration("text-style", str(get_rule("text_style")))
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ class DOMNode(MessagePump):
|
||||
self._css_styles: Styles = Styles(self)
|
||||
self._inline_styles: Styles = Styles.parse(self.STYLES, repr(self), node=self)
|
||||
self.styles = StylesView(self, self._css_styles, self._inline_styles)
|
||||
super().__init__()
|
||||
self.default_styles = Styles.parse(self.DEFAULT_STYLES, repr(self))
|
||||
self._default_rules = self.default_styles.extract_rules((0, 0, 0))
|
||||
super().__init__()
|
||||
|
||||
def __rich_repr__(self) -> rich.repr.Result:
|
||||
yield "name", self._name, None
|
||||
|
||||
@@ -15,6 +15,7 @@ from .widget import Widget
|
||||
|
||||
@rich.repr.auto
|
||||
class View(Widget):
|
||||
|
||||
DEFAULT_STYLES = """
|
||||
layout: dock;
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user