-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSheet.razor
More file actions
63 lines (59 loc) · 2.48 KB
/
Sheet.razor
File metadata and controls
63 lines (59 loc) · 2.48 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
56
57
58
59
60
61
62
63
@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-background/80 backdrop-blur-sm animate-in fade-in-0" @onclick="Close"></div>
<div class="@SheetVariants.Get(Side, Class)" @onclick:stopPropagation="true" @attributes="AdditionalAttributes">
<div class="flex flex-col space-y-2">
<div class="flex items-center justify-between">
@if (!string.IsNullOrEmpty(Title))
{
<h2 class="text-lg font-semibold text-foreground">@Title</h2>
}
else
{
<span></span>
}
<button type="button" @onclick="Close" class="rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
<span class="sr-only">Close</span>
</button>
</div>
@if (!string.IsNullOrEmpty(Description))
{
<p class="text-sm text-muted-foreground">@Description</p>
}
</div>
<div class="mt-4">@ChildContent</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 SheetSide Side { get; set; } = SheetSide.Right;
[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(); }
}
}