< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 27
Coverable lines: 27
Total lines: 95
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/Utility-Blazor/Utility-Blazor/src/Utility/Components/SiteSettingsPanel.razor

#LineLine coverage
 1@using Icons = Microsoft.FluentUI.AspNetCore.Components.Icons;
 2@using Emoji = Microsoft.FluentUI.AspNetCore.Components.Emoji
 3
 4@implements IDialogContentComponent
 5@inject Blazored.LocalStorage.ILocalStorageService localStorage
 6
 7<div>
 08    <FluentDesignTheme @ref=_theme
 09                       @bind-Mode="@Mode"
 010                       @bind-OfficeColor="@OfficeColor"
 011                       Direction="@Direction"
 012                       StorageName="theme" />
 013
 14    <FluentStack Orientation="Orientation.Vertical" VerticalGap="0">
 15        <FluentSelect Label="Theme"
 16                      Width="100%"
 17                      Style="margin-bottom: 30px;"
 18                      Items="@AllModes"
 19                      @bind-SelectedOption="@Mode" />
 20
 21        <FluentSelect Label="Colour"
 22                      Style="margin-bottom: 30px;"
 23                      Width="100%"
 24                      Items="@(OfficeColorUtilities.AllColors.Cast<OfficeColor?>())"
 25                      Height="200px"
 26                      @bind-SelectedOption="@OfficeColor">
 27            <OptionTemplate>
 28                <FluentStack>
 29                    <FluentIcon Value="@(new Icons.Filled.Size20.RectangleLandscape())"
 30                                Color="Color.Custom"
 31                                CustomColor="@GetCustomColor(@context)" />
 32                    <FluentLabel>@context</FluentLabel>
 33                </FluentStack>
 34            </OptionTemplate>
 35        </FluentSelect>
 36
 37        <FluentLabel>Reset</FluentLabel>
 38        <FluentButton OnClick="ResetSavedTab" Title="Reset">Reset</FluentButton>
 39    </FluentStack>
 40</div>
 41
 42@code {
 43    async void ResetSavedTab()
 044    {
 045        await localStorage.RemoveItemAsync(Constants.LOCAL_STORAGE_TAB);
 046    }
 47}

/home/runner/work/Utility-Blazor/Utility-Blazor/src/Utility/Components/SiteSettingsPanel.razor.cs

#LineLine coverage
 1using Microsoft.AspNetCore.Components;
 2using Microsoft.Extensions.Logging;
 3using Microsoft.FluentUI.AspNetCore.Components;
 4using Microsoft.FluentUI.AspNetCore.Components.Extensions;
 5using Utility.Infrastructure;
 6
 7namespace Utility.Components;
 8
 9public partial class SiteSettingsPanel
 10{
 11    private FluentDesignTheme? _theme;
 12
 13    [Inject]
 014    public required ILogger<SiteSettingsPanel> Logger { get; set; }
 15
 16    [Inject]
 017    public required CacheStorageAccessor CacheStorageAccessor { get; set; }
 18
 19    [Inject]
 020    public required GlobalState GlobalState { get; set; }
 21
 022    public DesignThemeModes Mode { get; set; }
 23
 024    public OfficeColor? OfficeColor { get; set; }
 25
 026    public LocalizationDirection? Direction { get; set; }
 27
 028    private static IEnumerable<DesignThemeModes> AllModes => Enum.GetValues<DesignThemeModes>();
 29
 30    private static IEnumerable<OfficeColor?> AllOfficeColors
 31    {
 32        get
 033        {
 034            return Enum.GetValues<OfficeColor>().Select(i => (OfficeColor?)i);
 035        }
 36    }
 37
 38    private static string? GetCustomColor(OfficeColor? color)
 039    {
 040        return color switch
 041        {
 042            null => OfficeColorUtilities.GetRandom(true).ToAttributeValue(),
 043            Microsoft.FluentUI.AspNetCore.Components.OfficeColor.Default => "#036ac4",
 044            _ => color.ToAttributeValue(),
 045        };
 46
 047    }
 48}