-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawer.razor
More file actions
55 lines (51 loc) · 2.32 KB
/
Drawer.razor
File metadata and controls
55 lines (51 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@namespace BlazorInteractiveServer.Components.UI
@using BlazorInteractiveServer.Components
@if (Compositional)
{
<CascadingValue Value="this" IsFixed="true">
@ChildContent
</CascadingValue>
}
else if (Open)
{
<div class="fixed inset-0 z-50 bg-black/80 animate-in fade-in-0" @onclick="Close"></div>
<div class="@DrawerVariants.Get(Side, Class)" @onclick:stopPropagation="true" @attributes="AdditionalAttributes">
<div class="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"></div>
<div class="grid gap-1.5 p-4 text-center sm:text-left">
@if (!string.IsNullOrEmpty(Title))
{
<h2 class="text-lg font-semibold leading-none tracking-tight">@Title</h2>
}
@if (!string.IsNullOrEmpty(Description))
{
<p class="text-sm text-muted-foreground">@Description</p>
}
</div>
<div class="p-4">@ChildContent</div>
<div class="mt-auto flex flex-col gap-2 p-4">
<button type="button" @onclick="Close" class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2 w-full">Close</button>
</div>
</div>
}
@code {
[Parameter] public bool Open { get; set; }
[Parameter] public EventCallback<bool> OpenChanged { get; set; }
[Parameter] public string? Title { get; set; }
[Parameter] public string? Description { get; set; }
[Parameter] public DrawerSide Side { get; set; } = DrawerSide.Bottom;
[Parameter] public RenderFragment? ChildContent { get; set; }
[Parameter] public string? Class { get; set; }
[Parameter] public bool Compositional { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary<string, object>? AdditionalAttributes { get; set; }
private async Task Close()
{
Open = false;
await OpenChanged.InvokeAsync(Open);
StateHasChanged();
}
public async Task SetOpen(bool value)
{
if (Open != value) { Open = value; await OpenChanged.InvokeAsync(Open); StateHasChanged(); }
}
}