mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
added color reference and docs
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user