Coverage for src/secchi/ui/widgets/badge.py: 0%

14 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-08-04 22:15 +0000

1"""Small chip widgets — language / license / package-type / homepage-link.""" 

2 

3from __future__ import annotations 

4 

5from textual.widgets import Static 

6 

7from secchi.ui import palette 

8 

9 

10class Badge(Static): 

11 """A compact bordered chip. `variant='link'` renders a clickable URL.""" 

12 

13 def __init__( 

14 self, 

15 text: str, 

16 *, 

17 variant: str = "default", 

18 url: str = "", 

19 color: str = "", 

20 ) -> None: 

21 if variant == "link" and url: 

22 content = f"[{palette.CYAN}]{text}[/]" 

23 elif color: 

24 content = f"[{color}]{text}[/{color}]" 

25 else: 

26 content = text 

27 super().__init__(content) 

28 self.add_class("badge") 

29 if variant == "link": 

30 self.add_class("badge--link")