Skip to content

styles

anomaly_match_ui.styles

ESA-branded styles, color constants, and CSS for the AnomalyMatch UI.

set_ui_scale(scale)

Set the global UI scale factor.

Parameters:

Name Type Description Default
scale float

The scale factor (1.0 = default size).

required
Source code in anomaly_match_ui/styles.py
def set_ui_scale(scale: float) -> None:
    """Set the global UI scale factor.

    Args:
        scale: The scale factor (1.0 = default size).
    """
    global _ui_scale  # noqa: PLW0603
    _ui_scale = scale

get_ui_scale()

Get the current UI scale factor.

Returns:

Type Description
float

The current scale factor.

Source code in anomaly_match_ui/styles.py
def get_ui_scale() -> float:
    """Get the current UI scale factor.

    Returns:
        The current scale factor.
    """
    return _ui_scale

scale_px(base_px)

Scale a pixel value by the current UI scale and return as CSS string.

Parameters:

Name Type Description Default
base_px int

The base pixel value at scale 1.0.

required

Returns:

Type Description
str

CSS pixel string like "14px".

Source code in anomaly_match_ui/styles.py
def scale_px(base_px: int) -> str:
    """Scale a pixel value by the current UI scale and return as CSS string.

    Args:
        base_px: The base pixel value at scale 1.0.

    Returns:
        CSS pixel string like ``"14px"``.
    """
    return f"{int(base_px * _ui_scale)}px"

inline_spinner_html(size_px=14, margin='0')

Return a small inline .am-spinner for status lines and captions.

The .am-spinner class is styled as a large centred block for loading panels; the inline overrides here shrink it and reset its margin.

Parameters:

Name Type Description Default
size_px int

Diameter in pixels.

14
margin str

CSS margin, e.g. "0 6px 0 0" to space it from following text.

'0'

Returns:

Type Description
str

HTML for the spinner.

Source code in anomaly_match_ui/styles.py
def inline_spinner_html(size_px: int = 14, margin: str = "0") -> str:
    """Return a small inline ``.am-spinner`` for status lines and captions.

    The ``.am-spinner`` class is styled as a large centred block for loading
    panels; the inline overrides here shrink it and reset its margin.

    Args:
        size_px: Diameter in pixels.
        margin: CSS margin, e.g. ``"0 6px 0 0"`` to space it from following text.

    Returns:
        HTML for the spinner.
    """
    return (
        '<span class="am-spinner" style="display:inline-block;'
        f" width:{size_px}px; height:{size_px}px; border-width:2px;"
        f' vertical-align:middle; margin:{margin};"></span>'
    )