Fix examples.

This commit is contained in:
Rodrigo Girão Serrão
2023-01-09 16:11:45 +00:00
parent 2827edcd49
commit a1b9d4b2c5
13 changed files with 65 additions and 47 deletions

View File

@@ -1,14 +1,18 @@
Static { Label {
width: 100%;
height: 1fr; height: 1fr;
content-align: center middle; content-align: center middle;
color: white; color: white;
} }
#static1 { #static1 {
background: red; background: red;
} }
#static2 { #static2 {
background: rgb(0, 255, 0); background: rgb(0, 255, 0);
} }
#static3 { #static3 {
background: hsl(240, 100%, 50%); background: hsl(240, 100%, 50%);
} }

View File

@@ -1,12 +1,12 @@
from textual.app import App from textual.app import App
from textual.widgets import Static from textual.widgets import Label
class BackgroundApp(App): class BackgroundApp(App):
def compose(self): def compose(self):
yield Static("Widget 1", id="static1") yield Label("Widget 1", id="static1")
yield Static("Widget 2", id="static2") yield Label("Widget 2", id="static2")
yield Static("Widget 3", id="static3") yield Label("Widget 3", id="static3")
app = BackgroundApp(css_path="background.css") app = BackgroundApp(css_path="background.css")

View File

@@ -1,6 +1,25 @@
#label1 {
background: red 20%;
color: red;
border: solid red;
}
#label2 {
background: green 20%;
color: green;
border: dashed green;
}
#label3 {
background: blue 20%;
color: blue;
border: tall blue;
}
Screen { Screen {
background: white; background: white;
} }
Screen > Label { Screen > Label {
width: 100%; width: 100%;
height: 5; height: 5;
@@ -8,19 +27,4 @@ Screen > Label {
color: white; color: white;
margin: 1; margin: 1;
box-sizing: border-box; box-sizing: border-box;
}
#label1 {
background: red 20%;
color: red;
border: solid red;
}
#label2 {
background: green 20%;
color: green;
border: dashed green;
}
#label3 {
background: blue 20%;
color: blue;
border: tall blue;
} }

View File

@@ -1,7 +1,16 @@
#static1 {
box-sizing: border-box;
}
#static2 {
box-sizing: content-box;
}
Screen { Screen {
background: white; background: white;
color: black; color: black;
} }
App Static { App Static {
background: blue 20%; background: blue 20%;
height: 5; height: 5;
@@ -9,9 +18,3 @@ App Static {
padding: 1; padding: 1;
border: wide black; border: wide black;
} }
#static1 {
box-sizing: border-box;
}
#static2 {
box-sizing: content-box;
}

View File

@@ -1,14 +1,17 @@
Label { Label {
height:1fr; height: 1fr;
content-align: center middle; content-align: center middle;
width: 100%; width: 100%;
} }
#label1 { #label1 {
color: red; color: red;
} }
#label2 { #label2 {
color: rgb(0, 255, 0); color: rgb(0, 255, 0);
} }
#label3 { #label3 {
color: hsl(240, 100%, 50%) color: hsl(240, 100%, 50%);
} }

View File

@@ -1,12 +1,14 @@
Screen { Screen {
background: green; background: green;
} }
Static {
height: 5; Static {
background: white; height: 5;
color: blue; background: white;
border: heavy blue; color: blue;
border: heavy blue;
} }
Static.remove { Static.remove {
display: none; display: none;
} }

View File

@@ -1,6 +1,6 @@
Grid { Grid {
grid-size: 2 4; grid-size: 2 4;
grid-gutter: 1 2 /* (1)! */ grid-gutter: 1 2; /* (1)! */
} }
Label { Label {

View File

@@ -1,4 +1,4 @@
Screen > Widget { Screen > Widget {
background: green; background: green;
height: 50%; height: 50%;
color: white; color: white;

View File

@@ -8,8 +8,8 @@ Vertical {
} }
Static { Static {
margin: 1 2; margin: 1 2;
background: green 80%; background: green 80%;
border: green wide; border: green wide;
color: white 90%; color: white 90%;
height: auto; height: auto;

View File

@@ -4,6 +4,6 @@ Screen {
} }
Label { Label {
padding: 4 8; padding: 4 8;
background: blue 20%; background: blue 20%;
} }

View File

@@ -1,8 +1,8 @@
Label { Label {
height: 3; height: 3;
width: 100%; width: 100%;
text-style: bold; text-style: bold;
background: white; background: white;
color: black; color: black;
content-align: center middle; content-align: center middle;
} }

View File

@@ -8,7 +8,7 @@ class TintApp(App):
color = Color.parse("green") color = Color.parse("green")
for tint_alpha in range(0, 101, 10): for tint_alpha in range(0, 101, 10):
widget = Label(f"tint: green {tint_alpha}%;") widget = Label(f"tint: green {tint_alpha}%;")
widget.styles.tint = color.with_alpha(tint_alpha / 100) widget.styles.tint = color.with_alpha(tint_alpha / 100) # (1)!
yield widget yield widget

View File

@@ -1,6 +1,7 @@
Screen { Screen {
background: green; background: green;
} }
Label { Label {
height: 5; height: 5;
width: 100%; width: 100%;
@@ -8,6 +9,7 @@ Label {
color: blue; color: blue;
border: heavy blue; border: heavy blue;
} }
Label.invisible { Label.invisible {
visibility: hidden; visibility: hidden;
} }