Code/Demos/AnimationShowcase/Components/Legend.cs
using Goo;
using Sandbox.UI;
using static Sandbox.DemoTokens;
namespace Sandbox.AnimationShowcase;
public static class Legend
{
const float Width = 240f;
public static Container Build( params (string name, string detail, Color color)[] entries )
{
var col = new Container
{
Width = Width,
FlexDirection = FlexDirection.Column,
Gap = Space2,
PointerEvents = PointerEvents.None,
};
foreach ( var (name, detail, color) in entries )
col.Children.Add( Item( name, detail, color ) );
return col;
}
static Container Item( string name, string detail, Color color ) => new Container
{
FlexDirection = FlexDirection.Row,
Gap = Space2,
AlignItems = Align.Center,
Children =
{
new Container
{
Width = 10f,
Height = 10f,
BorderRadius = 5f,
BackgroundColor = color,
},
new Text( name ) { FontColor = color, FontSize = FontBodySm },
new Text( detail ) { FontColor = FgTertiary, FontSize = FontCaption },
},
};
}