added color reference and docs

This commit is contained in:
Will McGugan
2022-09-10 22:00:51 +01:00
parent b1fa3c0a2a
commit b6341ddb50
10 changed files with 161 additions and 126 deletions

View File

@@ -2,7 +2,7 @@ import pytest
from rich.color import Color as RichColor
from rich.text import Text
from textual.color import Color, ColorPair, Lab, lab_to_rgb, rgb_to_lab
from textual.color import Color, Lab, lab_to_rgb, rgb_to_lab
def test_rich_color():
@@ -31,22 +31,6 @@ def test_css():
assert Color(10, 20, 30, 0.5).css == "rgba(10,20,30,0.5)"
def test_colorpair_style():
"""Test conversion of colorpair to style."""
# Black on white
assert (
str(ColorPair(Color.parse("#000000"), Color.parse("#ffffff")).style)
== "#000000 on #ffffff"
)
# 50% black on white
assert (
str(ColorPair(Color.parse("rgba(0,0,0,0.5)"), Color.parse("#ffffff")).style)
== "#7f7f7f on #ffffff"
)
def test_rgb():
assert Color(10, 20, 30, 0.55).rgb == (10, 20, 30)
@@ -221,8 +205,3 @@ def test_rgb_lab_rgb_roundtrip():
assert c_.r == pytest.approx(r, abs=1)
assert c_.g == pytest.approx(g, abs=1)
assert c_.b == pytest.approx(b, abs=1)
def test_color_pair_style():
pair = ColorPair(Color(220, 220, 220), Color(10, 20, 30))
assert str(pair.style) == "#dcdcdc on #0a141e"