-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document CSS Styles #629
Merged
Merged
Document CSS Styles #629
Changes from 13 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7ba36c1
docs
willmcgugan 7040d00
more docs
willmcgugan 99ccbc5
moar docs
willmcgugan 0fe4b97
more docs
willmcgugan 3f0f9ee
tint style
willmcgugan 8b5b410
added tint and offset
willmcgugan 7dc8dab
Merge branch 'layer-dock' into docs
willmcgugan a174557
added borders utility
willmcgugan 62db35f
add borders command
willmcgugan ae9862c
borders tweak
willmcgugan fa4b971
more docs
willmcgugan 971ef9e
more border
willmcgugan 5ff9b5e
Merge branch 'css' into docs
willmcgugan ca1ec68
text style docs
willmcgugan a9c475c
words and tables
willmcgugan 676c8ae
words and tables
willmcgugan 3960366
words
willmcgugan cbd0a6e
Update docs/examples/styles/background.py
willmcgugan b388a13
Update docs/examples/styles/border.py
willmcgugan 7e985b6
Update docs/examples/styles/box_sizing.py
willmcgugan b4aa7ec
Update docs/examples/styles/display.py
willmcgugan 38047e4
Update docs/examples/styles/offset.py
willmcgugan 6602cd7
Update docs/styles/visibility.md
willmcgugan 33dc6ac
Update docs/styles/color.md
willmcgugan 331cbc6
Update docs/examples/styles/visibility.py
willmcgugan fa61ca0
Update docs/introduction.md
willmcgugan 3976698
Update docs/introduction.md
willmcgugan 078fc24
Update docs/styles/background.md
willmcgugan cb0537e
Update docs/styles/background.md
willmcgugan 7fd3fe5
Update docs/styles/border.md
willmcgugan ce5e36e
Update docs/styles/box_sizing.md
willmcgugan 8697312
Update docs/examples/styles/color.py
willmcgugan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
These are the examples from the documentation, used to generate screenshots. | ||
|
||
You can run them with the textual CLI. | ||
|
||
For example: | ||
|
||
``` | ||
textual run text_style.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from textual.app import App | ||
from textual.widgets import Static | ||
|
||
|
||
class BackgroundApp(App): | ||
CSS = """ | ||
Static { | ||
height:1fr; | ||
content-align: center middle; | ||
color: white; | ||
} | ||
#static1 { | ||
background: red; | ||
} | ||
#static2 { | ||
background: rgb(0, 255, 0); | ||
} | ||
#static3 { | ||
background: hsl(240, 100%, 50%); | ||
} | ||
""" | ||
|
||
def compose(self): | ||
yield Static("Hello, World!", id="static1") | ||
yield Static("Hello, World!", id="static2") | ||
yield Static("Hello, World!", id="static3") | ||
willmcgugan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
app = BackgroundApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from textual.app import App | ||
from textual.widgets import Static | ||
|
||
|
||
class BorderApp(App): | ||
CSS = """ | ||
Screen { | ||
background: white; | ||
} | ||
Screen > Static { | ||
height: 5; | ||
content-align: center middle; | ||
color: white; | ||
margin: 1; | ||
box-sizing: border-box; | ||
} | ||
#static1 { | ||
background: red 20%; | ||
color: red; | ||
border: solid red; | ||
} | ||
#static2 { | ||
background: green 20%; | ||
color: green; | ||
border: dashed green; | ||
} | ||
#static3 { | ||
background: blue 20%; | ||
color: blue; | ||
border: tall blue; | ||
} | ||
""" | ||
|
||
def compose(self): | ||
yield Static("Hello, World!", id="static1") | ||
yield Static("Hello, World!", id="static2") | ||
yield Static("Hello, World!", id="static3") | ||
willmcgugan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
app = BorderApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from textual.app import App | ||
from textual.widgets import Static | ||
|
||
|
||
class BoxSizingApp(App): | ||
CSS = """ | ||
Screen { | ||
background: white; | ||
color: black; | ||
} | ||
Static { | ||
background: blue 20%; | ||
height: 5; | ||
margin: 2; | ||
padding: 1; | ||
border: wide black; | ||
} | ||
#static1 { | ||
box-sizing: border-box; | ||
} | ||
#static2 { | ||
box-sizing: content-box; | ||
} | ||
|
||
""" | ||
|
||
def compose(self): | ||
yield Static("Hello, World!", id="static1") | ||
yield Static("Hello, World!", id="static2") | ||
willmcgugan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
app = BoxSizingApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from textual.app import App | ||
from textual.widgets import Static | ||
|
||
|
||
class ColorApp(App): | ||
CSS = """ | ||
Static { | ||
height:1fr; | ||
content-align: center middle; | ||
} | ||
#static1 { | ||
color: red; | ||
} | ||
#static2 { | ||
color: rgb(0, 255, 0); | ||
} | ||
#static3 { | ||
color: hsl(240, 100%, 50%) | ||
} | ||
""" | ||
|
||
def compose(self): | ||
yield Static("Hello, World!", id="static1") | ||
yield Static("Hello, World!", id="static2") | ||
yield Static("Hello, World!", id="static3") | ||
willmcgugan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
app = ColorApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from textual.app import App | ||
from textual.widgets import Static | ||
|
||
|
||
class DisplayApp(App): | ||
CSS = """ | ||
Screen { | ||
background: green; | ||
} | ||
Static { | ||
height: 5; | ||
background: white; | ||
color: blue; | ||
border: heavy blue; | ||
} | ||
Static.remove { | ||
display: none; | ||
} | ||
""" | ||
|
||
def compose(self): | ||
yield Static("Widget 1") | ||
yield Static("widget 2", classes="remove") | ||
yield Static("widget 3") | ||
willmcgugan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
app = DisplayApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from textual.app import App | ||
from textual.widget import Widget | ||
|
||
|
||
class HeightApp(App): | ||
CSS = """ | ||
Screen > Widget { | ||
background: green; | ||
height: 50%; | ||
color: white; | ||
} | ||
""" | ||
|
||
def compose(self): | ||
yield Widget() | ||
|
||
|
||
app = HeightApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from textual.app import App | ||
from textual.widgets import Static | ||
|
||
TEXT = """I must not fear. | ||
Fear is the mind-killer. | ||
Fear is the little-death that brings total obliteration. | ||
I will face my fear. | ||
I will permit it to pass over me and through me. | ||
And when it has gone past, I will turn the inner eye to see its path. | ||
Where the fear has gone there will be nothing. Only I will remain.""" | ||
|
||
|
||
class MarginApp(App): | ||
CSS = """ | ||
|
||
Screen { | ||
background: white; | ||
color: black; | ||
} | ||
|
||
Static { | ||
margin: 4 8; | ||
background: blue 20%; | ||
border: blue wide; | ||
} | ||
|
||
""" | ||
|
||
def compose(self): | ||
yield Static(TEXT) | ||
|
||
|
||
app = MarginApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from textual.app import App | ||
from textual.widgets import Static | ||
|
||
|
||
class OffsetApp(App): | ||
CSS = """ | ||
Screen { | ||
background: white; | ||
color: black; | ||
layout: horizontal; | ||
} | ||
Static { | ||
width: 20; | ||
height: 10; | ||
content-align: center middle; | ||
} | ||
|
||
.paul { | ||
offset: 8 2; | ||
background: red 20%; | ||
border: outer red; | ||
color: red; | ||
} | ||
|
||
.duncan { | ||
offset: 4 10; | ||
background: green 20%; | ||
border: outer green; | ||
color: green; | ||
} | ||
|
||
.chani { | ||
offset: 0 5; | ||
background: blue 20%; | ||
border: outer blue; | ||
color: blue; | ||
} | ||
""" | ||
|
||
def compose(self): | ||
yield Static("Paul", classes="paul") | ||
yield Static("Duncan", classes="duncan") | ||
yield Static("Chani", classes="chani") | ||
willmcgugan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
app = OffsetApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from textual.app import App | ||
from textual.widgets import Static | ||
|
||
|
||
TEXT = """I must not fear. | ||
Fear is the mind-killer. | ||
Fear is the little-death that brings total obliteration. | ||
I will face my fear. | ||
I will permit it to pass over me and through me. | ||
And when it has gone past, I will turn the inner eye to see its path. | ||
Where the fear has gone there will be nothing. Only I will remain.""" | ||
|
||
|
||
class OutlineApp(App): | ||
CSS = """ | ||
Screen { | ||
background: white; | ||
color: black; | ||
} | ||
Static { | ||
margin: 4 8; | ||
background: green 20%; | ||
outline: wide green; | ||
} | ||
""" | ||
|
||
def compose(self): | ||
yield Static(TEXT) | ||
|
||
|
||
app = OutlineApp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from textual.app import App | ||
from textual.widgets import Static | ||
from textual.layout import Horizontal, Vertical | ||
|
||
TEXT = """I must not fear. | ||
Fear is the mind-killer. | ||
Fear is the little-death that brings total obliteration. | ||
I will face my fear. | ||
I will permit it to pass over me and through me. | ||
And when it has gone past, I will turn the inner eye to see its path. | ||
Where the fear has gone there will be nothing. Only I will remain.""" | ||
|
||
|
||
class OverflowApp(App): | ||
CSS = """ | ||
Screen { | ||
background: $background; | ||
color: black; | ||
} | ||
|
||
Vertical { | ||
width: 1fr; | ||
} | ||
|
||
Static { | ||
margin: 1 2; | ||
background: blue 20%; | ||
border: blue wide; | ||
height: auto; | ||
} | ||
|
||
#right { | ||
overflow-y: hidden; | ||
} | ||
""" | ||
|
||
def compose(self): | ||
yield Horizontal( | ||
Vertical(Static(TEXT), Static(TEXT), Static(TEXT), id="left"), | ||
Vertical(Static(TEXT), Static(TEXT), Static(TEXT), id="right"), | ||
) | ||
|
||
|
||
app = OverflowApp() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.