IColorPalette
The IColorPalette interface allows you do define your own color palettes which can be used in all color pickers throughout the system.
Interface declaration
public interface IColorPalette { string Name { get; } string Description { get; } int OrderIndex { get; } IEnumerable<string> Colors(Guid websiteId); }
Example
This implementation of IColorPalette is part of the Lisa.Modules.ChartJS module and defines a set of default colors which are used for chart data.
[Description("A set of default colors to use with the chart components")] [DisplayName("Default chart colors")] public class DefaultChartColorPalette : IColorPalette { public string Name => "Default chart colors"; public string Description => "A set of default colors to use with the chart components"; public int OrderIndex => 100; public IEnumerable<string> Colors(Guid websiteId) { return new List<string>() { "#F94144", "#F3722C", "#F8961E", "#F9844A", "#F9C74F", "#90BE6D", "#43AA8B", "#4D908E", "#577590", "#277DA1" }; } }
Registration
This is how the implementation is registered into the DI container in Veva, this should be done in your module config file (The class which implements IModule).
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) { services.AddNamed<IColorPalette, DefaultChartColorPalette>("DefaultChartColorPalette"); }