# -*- coding: utf-8 -*-

"""
examples.advanced_colors
~~~~~~~~~~~~~~~~~~~~~~~~

Use familiar API of the `termcolor.colored` function to apply any
color, highlight, attribute or their mix to your yaspin spinner.
"""

import time

from yaspin import yaspin
from yaspin.spinners import Spinners
from yaspin.termcolor import colored


def test_highlights():
    test_items = [
        ("On gray color", lambda frame: colored(frame, on_color="on_grey")),
        ("On red color", lambda frame: colored(frame, on_color="on_red")),
        ("On green color", lambda frame: colored(frame, on_color="on_green")),
        (
            "On yellow color",
            lambda frame: colored(frame, on_color="on_yellow"),
        ),
        ("On blue color", lambda frame: colored(frame, on_color="on_blue")),
        (
            "On magenta color",
            lambda frame: colored(frame, on_color="on_magenta"),
        ),
        ("On cyan color", lambda frame: colored(frame, on_color="on_cyan")),
        ("On white color", lambda frame: colored(frame, on_color="on_white")),
    ]
    for text, color_func in test_items:
        with yaspin(Spinners.bouncingBall, text=text, color=color_func):
            time.sleep(2)


def test_attributes():
    test_items = [
        (
            "Bold gray color",
            lambda frame: colored(frame, "grey", attrs=["bold"]),
        ),
        (
            "Dark red color",
            lambda frame: colored(frame, "red", attrs=["dark"]),
        ),
        (
            "Underline green color",
            lambda frame: colored(frame, "green", attrs=["underline"]),
        ),
        (
            "Blink yellow color",
            lambda frame: colored(frame, "yellow", attrs=["blink"]),
        ),
        (
            "Reversed blue color",
            lambda frame: colored(frame, "blue", attrs=["reverse"]),
        ),
        (
            "Concealed magenta color",
            lambda frame: colored(frame, "magenta", attrs=["concealed"]),
        ),
        (
            "Bold underline reverse cyan color",
            lambda frame: colored(
                frame, "cyan", attrs=["bold", "underline", "reverse"]
            ),
        ),
        (
            "Dark blink concealed white color",
            lambda frame: colored(
                frame, "white", attrs=["dark", "blink", "concealed"]
            ),
        ),
    ]
    for text, color_func in test_items:
        with yaspin(Spinners.bouncingBar, text=text, color=color_func):
            time.sleep(2)


def test_mixing():
    test_items = [
        (
            "Underline red on grey color",
            lambda frame: colored(
                frame, "red", "on_grey", attrs=["underline"]
            ),
        ),
        (
            "Reversed green on red color",
            lambda frame: colored(frame, "green", "on_red", attrs=["reverse"]),
        ),
    ]
    for text, color_func in test_items:
        with yaspin(Spinners.pong, text=text, color=color_func):
            time.sleep(2)


def main():
    test_highlights()
    test_attributes()
    test_mixing()


if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-

"""
examples.advanced_colors
~~~~~~~~~~~~~~~~~~~~~~~~

Use familiar API of the `termcolor.colored` function to apply any
color, highlight, attribute or their mix to your yaspin spinner.
"""

import time

from yaspin import yaspin


def white_shark():
    # Set with attributes
    with yaspin().white.bold.shark.on_blue as sp:
        sp.text = "White bold shark in a blue sea 🦈"
        time.sleep(5)


def ping_pong():
    # Set with attributes
    with yaspin(text="🏓").yellow.bold.underline.pong.on_blue:
        time.sleep(5)


def ball():
    # Set with arguments
    with yaspin(
        color="white",
        on_color="on_magenta",
        attrs=["dark", "blink", "concealed"],
    ).bouncingBall as sp:
        sp.text = "Dark blink concealed white ball on magenta color"
        time.sleep(5)


def main():
    white_shark()
    ping_pong()
    ball()


if __name__ == "__main__":
    main()

Update examples/advanced_colors.py