Coverage for src / lilbee / cli / tui / pill.py: 100%
6 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-05-15 20:55 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-05-15 20:55 +0000
1"""Pill badge: a colored inline label with one space of ``{background}``-fill padding each side.
3Adapted from toad (https://github.com/batrachianai/toad); the padding is part
4of the solid fill rather than toad's reversed half-block caps, which take their
5color from the cell behind the pill and read as a black sliver on a near-black
6terminal.
7"""
9from textual.content import Content
11DOT_SEP = " · " # middle-dot separator for inline dividers
14def pill(text: Content | str, background: str, foreground: str) -> Content:
15 """Format *text* as a colored pill badge: the label on a ``{background}`` fill.
17 Args:
18 text: Pill contents.
19 background: Background color (Textual color string, e.g. ``"$primary"``).
20 foreground: Foreground color (Textual color string, e.g. ``"$text"``).
22 Returns:
23 Styled ``Content`` with one space of padding on each side.
24 """
25 content = Content(text) if isinstance(text, str) else text
26 style = f"{foreground} on {background}"
27 return Content.assemble((" ", style), content.stylize(style), (" ", style))