Skip to content

Instantly share code, notes, and snippets.

@conficient
Created July 30, 2020 17:23
Show Gist options
  • Save conficient/80caf853f12d9d02866b0cb0f2b754fc to your computer and use it in GitHub Desktop.
Save conficient/80caf853f12d9d02866b0cb0f2b754fc to your computer and use it in GitHub Desktop.
Blazor - GreyOutZone - adapted from FlightFinder but with embedded styles so works stand-alone
@* creates a container component that greys-out the content when the `IsGreyedOut` parameter is set to true *@
<div style="@(IsGreyedOut ? greyout : null)">
<div style="@cover"></div>
@ChildContent
</div>
@code {
const string greyout = "position: absolute; width: 100%; min-height: 100%;";
const string cover = "background: rgba(150, 150, 150, 0.5); position: absolute; width: 100%; height: 100%; z-index: 1;";
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public bool IsGreyedOut { get; set; }
}
@* adapted from https://github.com/aspnet/samples/blob/master/samples/aspnetcore/blazor/FlightFinder/FlightFinder.Client/Components/GreyOutZone.razor *@
@* uses inline-styles so can be dropped in with no need to amend your CSS
feel free to using CSS class names (as per original example)
*@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment