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(),
|
footer=Widget(),
|
||||||
sidebar=Widget(),
|
sidebar=Widget(),
|
||||||
)
|
)
|
||||||
self.panic(self.stylesheet.css)
|
|
||||||
|
|
||||||
|
|
||||||
BasicApp.run(css_file="basic.css", watch_css=True, log="textual.log")
|
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_background")
|
||||||
rules.pop("text_style")
|
rules.pop("text_style")
|
||||||
elif isinstance(style, Style):
|
elif isinstance(style, Style):
|
||||||
rules_set("text_color", style.color)
|
if style.color:
|
||||||
rules_set("text_background", style.bgcolor)
|
rules_set("text_color", style.color)
|
||||||
rules_set("text_style", style.without_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):
|
elif isinstance(style, str):
|
||||||
new_style = Style.parse(style)
|
new_style = Style.parse(style)
|
||||||
rules_set("text_color", new_style.color)
|
if new_style.color:
|
||||||
rules_set("text_background", new_style.bgcolor)
|
rules_set("text_color", new_style.color or Color.default())
|
||||||
rules_set("text_style", new_style.without_color)
|
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:
|
class SpacingProperty:
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class StylesBuilder:
|
|||||||
self.styles.important.update(
|
self.styles.important.update(
|
||||||
{"text_style", "text_background", "text_color"}
|
{"text_style", "text_background", "text_color"}
|
||||||
)
|
)
|
||||||
self.styles._rules["text"] = style
|
self.styles.text = style
|
||||||
|
|
||||||
def process_text_color(
|
def process_text_color(
|
||||||
self, name: str, tokens: list[Token], important: bool
|
self, name: str, tokens: list[Token], important: bool
|
||||||
|
|||||||
@@ -352,6 +352,9 @@ class Styles:
|
|||||||
rules = self.get_rules()
|
rules = self.get_rules()
|
||||||
get_rule = rules.get
|
get_rule = rules.get
|
||||||
has_rule = rules.__contains__
|
has_rule = rules.__contains__
|
||||||
|
from rich import print
|
||||||
|
|
||||||
|
print(rules)
|
||||||
|
|
||||||
if has_rule("display"):
|
if has_rule("display"):
|
||||||
append_declaration("display", rules["display"])
|
append_declaration("display", rules["display"])
|
||||||
@@ -397,9 +400,9 @@ class Styles:
|
|||||||
append_declaration("text", str(self.text))
|
append_declaration("text", str(self.text))
|
||||||
else:
|
else:
|
||||||
if has_rule("text_color"):
|
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"):
|
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"):
|
if has_rule("text_style"):
|
||||||
append_declaration("text-style", str(get_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._css_styles: Styles = Styles(self)
|
||||||
self._inline_styles: Styles = Styles.parse(self.STYLES, repr(self), node=self)
|
self._inline_styles: Styles = Styles.parse(self.STYLES, repr(self), node=self)
|
||||||
self.styles = StylesView(self, self._css_styles, self._inline_styles)
|
self.styles = StylesView(self, self._css_styles, self._inline_styles)
|
||||||
super().__init__()
|
|
||||||
self.default_styles = Styles.parse(self.DEFAULT_STYLES, repr(self))
|
self.default_styles = Styles.parse(self.DEFAULT_STYLES, repr(self))
|
||||||
self._default_rules = self.default_styles.extract_rules((0, 0, 0))
|
self._default_rules = self.default_styles.extract_rules((0, 0, 0))
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
def __rich_repr__(self) -> rich.repr.Result:
|
def __rich_repr__(self) -> rich.repr.Result:
|
||||||
yield "name", self._name, None
|
yield "name", self._name, None
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from .widget import Widget
|
|||||||
|
|
||||||
@rich.repr.auto
|
@rich.repr.auto
|
||||||
class View(Widget):
|
class View(Widget):
|
||||||
|
|
||||||
DEFAULT_STYLES = """
|
DEFAULT_STYLES = """
|
||||||
layout: dock;
|
layout: dock;
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user