Create a progress bar with optional text overlay.
(container, id, value=0.0, label="")
| 376 | |
| 377 | |
| 378 | def progress(container, id, value=0.0, label=""): |
| 379 | """Create a progress bar with optional text overlay.""" |
| 380 | wrapper = container.append_child("div") |
| 381 | wrapper.set_property("position", "relative") |
| 382 | |
| 383 | prog = wrapper.append_child("progress") |
| 384 | prog.set_id(id) |
| 385 | prog.set_attribute("value", str(value)) |
| 386 | prog.set_attribute("max", "1") |
| 387 | |
| 388 | if label: |
| 389 | text = wrapper.append_child("span") |
| 390 | text.set_id(f"{id}-text") |
| 391 | text.set_class_names("progress__text") |
| 392 | text.set_text(label) |
| 393 | |
| 394 | return wrapper |
| 395 | |
| 396 | |
| 397 | def color_swatch(container, id, r=0, g=0, b=0, data_prop=""): |
no test coverage detected