Source code for exlab_wizard.ui.components.banner_stack

"""Banner stack component (Frontend Spec §2.2.3).

Renders the active banners for a container. Stacking is capped at 2; a
3rd active banner collapses into a *"...and N more issues"* link.

Reads from :mod:`exlab_wizard.ui.notifications` instead of taking the
banner list as a constructor argument so any caller of
:func:`show_banner` automatically updates the stack on next render.
"""

from __future__ import annotations

from typing import Any

from exlab_wizard.logging import get_logger
from exlab_wizard.ui import notifications
from exlab_wizard.ui.notifications import BannerId, ContainerId, Severity

_log = get_logger(__name__)


_BANNER_STACK_MAX = 2






def _color_for_severity(severity: Severity) -> str:
    """Map a :class:`Severity` to its CSS variable token."""

    if severity is Severity.WARNING:
        return "--color-warning"
    if severity is Severity.DANGER:
        return "--color-danger"
    if severity is Severity.SUCCESS:
        return "--color-success"
    return "--color-info"






# Re-export commonly-used identifiers so wizards can compose without
# importing the notifications module directly when only the banner stack
# is needed.
__all__ = (
    "BannerId",
    "ContainerId",
    "Severity",
    "banner_stack",
    "banner_stack_props",
)