Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Overlay] Add Interactive and InteractiveExceptId parameters #2580

Merged
merged 13 commits into from
Aug 30, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -2765,6 +2765,9 @@
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentDatePicker.ClassValue">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentDatePicker.PopupId">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentDatePicker.Appearance">
<summary>
Gets or sets the design of this input.
Expand Down Expand Up @@ -7332,20 +7335,37 @@
<member name="T:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.LibraryConfiguration">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.JSRuntime">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay._jsModule">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.ClassValue">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.StyleValue">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.StyleContentValue">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.Id">
<summary>
Gets or sets the unique identifier of the overlay.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.Visible">
<summary>
Gets or sets a value indicating whether the overlay is visible.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.VisibleChanged">
<summary>
Callback for when overlay visisbility changes.
Callback for when overlay visibility changes.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.OnClose">
Expand Down Expand Up @@ -7380,13 +7400,43 @@
Gets or sets a value indicating whether the overlay is shown full screen or bound to the containing element.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.Interactive">
<summary>
Gets or sets a value indicating whether the overlay is interactive, except for the element with the specified <see cref="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.InteractiveExceptId"/>.
In other words, the elements below the overlay remain usable (mouse-over, click) and the overlay will closed when clicked.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.InteractiveExceptId">
<summary>
Gets or sets the HTML identifier of the element that is not interactive when the overlay is shown.
This property is ignored if <see cref="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.Interactive"/> is false.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.Dismissable">
<summary>
Gets of sets a value indicating if the overlay can be dismissed by clicking on it.
Default is true.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.BackgroundColor">
<summary>
Gets or sets the background color.
Needs to be formatted as an HTML hex color string (#rrggbb or #rgb).
Default is '#ffffff'.
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.DisposeAsync">
<summary>
Disposes the overlay.
</summary>
<returns></returns>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.InvokeOverlayInitializeAsync">
<summary />
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.InvokeOverlayDisposeAsync">
<summary />
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentOverlay.CheckRGBString">
<remarks>
Pattern:<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<FluentButton Appearance="Appearance.Accent" @onclick="() => visible = !visible">Show Overlay</FluentButton>

<FluentOverlay @bind-Visible=@visible
Opacity="0.4"
Opacity="0.4"
BackgroundColor="#e8f48c"
FullScreen="true"
OnClose="HandleOnClose"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

<FluentStack>
<FluentSwitch @bind-Value="@interactive" Label="Interactive" />
<FluentSwitch @bind-Value="@interactiveExceptId" Label="Exception Zone (my-zone)" Disabled="@(!interactive)" />
<FluentSwitch @bind-Value="@fullScreen" Label="Full screen" />
</FluentStack>

<FluentButton Appearance="Appearance.Accent"
Style="margin: 24px 0px;"
@onclick="() => visible = !visible">
Show Overlay
</FluentButton>

<FluentStack VerticalAlignment="VerticalAlignment.Center">
<FluentButton OnClick="@(e => counter++)">Increment</FluentButton>
<FluentLabel>Counter: @counter</FluentLabel>
</FluentStack>

<FluentOverlay @bind-Visible=@visible
Opacity="0.4"
BackgroundColor="#e8f48c"
FullScreen="@fullScreen"
Interactive="@interactive"
InteractiveExceptId="@(interactiveExceptId ? "my-zone" : null)"
OnClose="HandleOnClose"
PreventScroll=true>
@if (interactive)
{
<div id="my-zone">
<p>Non-interactive zone</p>
<FluentProgressRing />
</div>
}
else
{
<FluentProgressRing />
}
</FluentOverlay>

<style>
#my-zone {
background-color: white;
width: 200px;
height: 160px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>

@code {
bool visible = false;
bool interactive = true;
bool interactiveExceptId = true;
bool fullScreen = true;
int counter = 0;

protected void HandleOnClose()
{
DemoLogger.WriteLine("Overlay closed");
}
}
12 changes: 10 additions & 2 deletions examples/Demo/Shared/Pages/Overlay/OverlayPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<h2 id="example">Examples</h2>

<DemoSection Title="Default" Component="typeof(OverlayDefault)" >
<DemoSection Title="Default" Component="typeof(OverlayDefault)">
<Description>Overlay with a default white background</Description>
</DemoSection>

Expand All @@ -27,7 +27,15 @@
</DemoSection>

<DemoSection Title="Full screen" Component="typeof(OverlayFullScreen)">
<Description>Overlay which takes up the whole screen</Description>
<Description>Overlay which takes up the whole screen.</Description>
</DemoSection>

<DemoSection Title="Interactive" Component="typeof(OverlayInteractive)">
<Description>
By using the <code>Interactive</code> and <code>InteractiveExceptId</code> properties, only the targeted element will not close the <b>FluentOverlay</b> panel.
The user can click anywhere else to close the <b>FluentOverlay</b>.<br />
In this example, the <b>FluentOverlay</b> will only close when the user clicks outside the white zone and the user can increment the counter before to close the Overlay.<br />
</Description>
</DemoSection>

<h2 id="documentation">Documentation</h2>
Expand Down
2 changes: 1 addition & 1 deletion examples/Demo/Shared/Pages/RawEventHandlers.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div>
<h1>Menu component</h1>
<FluentMenu>
<FluentMenuItem @onclick="() => PerformClick(_menuComponentItems)" role="menuitem">Menu item 1</FluentMenuItem>
<FluentMenuItem @onclick="() => PerformClick(_menuComponentItems)">Menu item 1</FluentMenuItem>
</FluentMenu>

@foreach (var item in _menuComponentItems)
Expand Down
3 changes: 2 additions & 1 deletion src/Core/Components/DateTime/FluentDatePicker.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

@if (Opened)
{
<FluentOverlay @bind-Visible="@Opened" Dismissable="true" FullScreen="true" />
<FluentOverlay @bind-Visible="@Opened" Dismissable="true" FullScreen="true" Interactive="true" InteractiveExceptId="@PopupId" />
<FluentAnchoredRegion Anchor="@Id"
Id="@PopupId"
HorizontalDefaultPosition="@(System.Globalization.CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft ? HorizontalPosition.Left : HorizontalPosition.Right)"
HorizontalInset="true"
VerticalDefaultPosition="@VerticalPosition.Unset"
Expand Down
3 changes: 3 additions & 0 deletions src/Core/Components/DateTime/FluentDatePicker.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ protected override string? ClassValue
}
}

/// <summary />
private string PopupId => $"{Id}-popup";

/// <summary>
/// Gets or sets the design of this input.
/// </summary>
Expand Down
9 changes: 5 additions & 4 deletions src/Core/Components/Overlay/FluentOverlay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
{
<div class="@ClassValue"
style="@StyleValue"
@onclick="@OnCloseHandlerAsync"
@oncontextmenu="@OnCloseHandlerAsync"
@oncontextmenu:preventDefault>
<div style="@( $"display: flex; align-items:{Alignment.ToAttributeValue()}; justify-content: {Justification.ToAttributeValue()}; width: 100%; height: 100%")">
id="@Id"
@onclick="@OnCloseHandlerAsync"
@oncontextmenu="@OnCloseHandlerAsync"
@oncontextmenu:preventDefault="true">
<div style="@StyleContentValue">
@ChildContent
</div>
</div>
Expand Down
Loading
Loading