mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
color docstrings
This commit is contained in:
@@ -22,7 +22,7 @@ for name, triplet in sorted(COLOR_NAME_TO_RGB.items()):
|
||||
r, g, b = triplet
|
||||
table.add_row(
|
||||
f'"{name}"',
|
||||
f"{color.hex}",
|
||||
Text(f"{color.hex}", "bold green"),
|
||||
f"rgb({r}, {g}, {b})",
|
||||
Text(" ", style=f"on rgb({r},{g},{b})")
|
||||
)
|
||||
@@ -273,7 +273,7 @@ class Color(NamedTuple):
|
||||
"""The color in CSS hex form, with 6 digits for RGB, and 8 digits for RGBA.
|
||||
|
||||
Returns:
|
||||
str: A CSS hex-style color, e.g. "#46b3de" or "#3342457f"
|
||||
str: A CSS hex-style color, e.g. `"#46b3de"` or `"#3342457f"`
|
||||
|
||||
"""
|
||||
r, g, b, a = self.clamped
|
||||
@@ -288,7 +288,7 @@ class Color(NamedTuple):
|
||||
"""The color in CSS rgb or rgba form.
|
||||
|
||||
Returns:
|
||||
str: A CSS style color, e.g. "rgb(10,20,30)" or "rgb(50,70,80,0.5)"
|
||||
str: A CSS style color, e.g. `"rgb(10,20,30)"` or `"rgb(50,70,80,0.5)"`
|
||||
|
||||
"""
|
||||
r, g, b, a = self
|
||||
|
||||
@@ -13,9 +13,9 @@ from .color import Color, WHITE
|
||||
NUMBER_OF_SHADES = 3
|
||||
|
||||
# Where no content exists
|
||||
DEFAULT_DARK_BACKGROUND = "#000000"
|
||||
DEFAULT_DARK_BACKGROUND = "#121212"
|
||||
# What text usually goes on top off
|
||||
DEFAULT_DARK_SURFACE = "#121212"
|
||||
DEFAULT_DARK_SURFACE = "#292929"
|
||||
|
||||
DEFAULT_LIGHT_SURFACE = "#f5f5f5"
|
||||
DEFAULT_LIGHT_BACKGROUND = "#efefef"
|
||||
|
||||
@@ -249,14 +249,7 @@ class Region(NamedTuple):
|
||||
"""The height of the region."""
|
||||
|
||||
@classmethod
|
||||
def from_union(
|
||||
cls,
|
||||
regions: Collection[Region],
|
||||
_get_x=itemgetter(0),
|
||||
_get_y=itemgetter(1),
|
||||
_get_right=attrgetter("right"),
|
||||
_get_bottom=attrgetter("bottom"),
|
||||
) -> Region:
|
||||
def from_union(cls, regions: Collection[Region]) -> Region:
|
||||
"""Create a Region from the union of other regions.
|
||||
|
||||
Args:
|
||||
@@ -267,10 +260,10 @@ class Region(NamedTuple):
|
||||
"""
|
||||
if not regions:
|
||||
raise ValueError("At least one region expected")
|
||||
min_x = min(regions, key=_get_x).x
|
||||
max_x = max(regions, key=_get_right).right
|
||||
min_y = min(regions, key=_get_y).y
|
||||
max_y = max(regions, key=_get_bottom).bottom
|
||||
min_x = min(regions, key=itemgetter(0)).x
|
||||
max_x = max(regions, key=attrgetter("right")).right
|
||||
min_y = min(regions, key=itemgetter(1)).y
|
||||
max_y = max(regions, key=attrgetter("bottom")).bottom
|
||||
return cls(min_x, min_y, max_x - min_x, max_y - min_y)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user