UI/Components/Menu/MenuPlayerList.razor

A Blazor-style Razor UI component for the player list in a menu. It renders a list of player rows with name, ready/host indicators, an icon for the host, and a status badge, and exposes a Players property used as the source.

NetworkingNative Interop
@namespace Sunless.Libraries.UI
@using System.Collections.Generic
@using Sandbox
@using Sandbox.UI
@inherits Panel
@attribute [StyleSheet]

<root class="menu-player-list">
	@if ( Players is { Count: > 0 } )
	{
		foreach ( var p in Players )
		{
			<div class="player-row @(p.Ready ? "ready" : "") @(p.Host ? "host" : "")">
				<div class="indicator"></div>
				<div class="player-name">@p.Name</div>
				@if ( p.Host )
				{
					<Icon Name="star" Size=@(IconSize.Small) ExtraClass="host-icon" />
				}
				<div class="grow"></div>
				<div class="status-badge @(p.Ready ? "ready" : "waiting")">@(p.Ready ? "Ready" : "Waiting")</div>
			</div>
		}
	}
</root>

@code
{
	public IReadOnlyList<MenuPlayerListWidget.Player> Players { get; set; }

	protected override int BuildHash() => HashCode.Combine( Players?.Count ?? 0 );
}