You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Components/Components/Menu/Menu.razor

50 lines
2.5 KiB

2 years ago
@namespace Connected.Components
@inherits UIComponent
<div @attributes="UserAttributes" Class="@Classname" Style="@Style"
@onmouseenter="@MouseEnter"
@onmouseleave="@MouseLeave"
@oncontextmenu:preventDefault="@(ActivationEvent == MouseEvent.RightClick ? true : false)">
@if (ActivatorContent != null)
{
<CascadingValue Value="@((IActivatable) this)" IsFixed="true">
<div @onclick="ToggleMenu" @ontouchend="@(ActivationEvent == MouseEvent.RightClick ? ToggleMenuTouch : null)" @oncontextmenu="@(ActivationEvent==MouseEvent.RightClick ? ToggleMenu : null)" disabled="@Disabled" class="@ActivatorClassname">
@ActivatorContent
</div>
</CascadingValue>
}
else if (String.IsNullOrEmpty(Icon))
{
<Button StartIcon="@StartIcon"
EndIcon="@EndIcon"
IconColor="@IconColor"
Color="@Color"
Size="@Size"
Variant="@Variant"
Disabled="@Disabled"
DisableRipple="@DisableRipple"
DisableElevation="@DisableElevation"
OnClick="@ToggleMenu"
@ontouchend="@(ActivationEvent == MouseEvent.RightClick ? ToggleMenuTouch : null)"
@oncontextmenu="@(ActivationEvent==MouseEvent.RightClick ? ToggleMenu : null)">
@Label
</Button>
}
else
{
<IconButton Variant="@Variant" Icon="@Icon" Color="@Color" Size="@Size" Disabled="@Disabled" DisableRipple="@DisableRipple" DisableElevation="@DisableElevation" @onclick="@ToggleMenu" @ontouchend="@(ActivationEvent == MouseEvent.RightClick ? ToggleMenuTouch : null)" @oncontextmenu="@(ActivationEvent==MouseEvent.RightClick ? ToggleMenu : null)" />
}
@* The portal has to include the cascading values inside, because it's not able to teletransport the cascade *@
<Popover Open="@_isOpen" Class="@PopoverClass" MaxHeight="@MaxHeight" AnchorOrigin="@AnchorOrigin" TransformOrigin="@TransformOrigin" RelativeWidth="@FullWidth" Style="@PopoverStyle">
<CascadingValue Value="@this">
<List Class="@ListClass" Clickable="true" Dense="@Dense"
@onmouseenter="@MouseEnter"
@onmouseleave="@MouseLeave">
@ChildContent
</List>
</CascadingValue>
</Popover>
<Overlay Visible="@(_isOpen && ActivationEvent!=MouseEvent.MouseOver)" OnClick="@ToggleMenu" LockScroll="LockScroll" />
</div>