@*
OddsCell — tabular mono rendering of a decimal odds rate, with an inline
direction marker (▲ amber rising, ▼ red falling, em-dash unchanged) when
the value differs from a previous render. Drives the visual indicator
that Phase 6 promises for live-list odds movement.
Rate is the current value. Previous (optional) is the prior value the
caller wants compared against. Caller decides what "previous" means
(last refresh / last snapshot) and tracks it in its own state.
*@
@{
var direction = Direction;
var directionGlyph = direction switch
{
Trend.Up => "▲", // ▲
Trend.Down => "▼", // ▼
_ => "—", // em-dash
};
var directionClass = direction switch
{
Trend.Up => "is-up",
Trend.Down => "is-down",
_ => "is-flat",
};
var ariaTrend = direction switch
{
Trend.Up => "rising",
Trend.Down => "falling",
_ => "unchanged",
};
}
@Formatted
@if (ShowTrend)
{
@directionGlyph
}
@code {
[Parameter] public decimal? Rate { get; set; }
[Parameter] public decimal? Previous { get; set; }
[Parameter] public bool ShowTrend { get; set; } = true;
[Parameter] public string AriaPrefix { get; set; } = "Odds";
[Parameter] public string EmptyPlaceholder { get; set; } = "—";
private string Formatted => Rate is { } r
? r.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
: EmptyPlaceholder;
private Trend Direction
{
get
{
if (Rate is not { } r || Previous is not { } p) return Trend.Flat;
if (r > p) return Trend.Up;
if (r < p) return Trend.Down;
return Trend.Flat;
}
}
private enum Trend { Flat, Up, Down }
}