1
0
Fork 0
mirror of https://github.com/miawinter98/just-short-it.git synced 2024-11-22 08:19:54 +00:00
just-short-it/Components/MessageComponent.razor

45 lines
1.9 KiB
Plaintext
Raw Normal View History

@if (Message is not null) {
<div class="alert @GetAlertTypeClass() rounded-sm p-2" aria-role="alert">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z" />
</svg>
<span>
@Message
</span>
<div class="flex items-center gap-2">
@if (LinkToCopy is not null) {
<button class="btn btn-sm"
onclick='navigator.clipboard.writeText("@LinkToCopy")'>
Copy
</button>
}
<button class="btn btn-square btn-sm btn-ghost" onclick="this.parentElement.parentElement.remove()">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-5 h-5">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd"/>
</svg>
</button>
</div>
</div>
}
@code {
[Parameter]
public string? Message { get; set; }
[Parameter]
public AlertType Type { get; set; } = AlertType.Information;
[Parameter]
public string? LinkToCopy { get; set; }
private string GetAlertTypeClass() => Type switch{
AlertType.Information => "alert-info",
AlertType.Success => "alert-success",
AlertType.Warning => "alert-warning",
AlertType.Error => "alert-error",
_ => throw new ArgumentOutOfRangeException()
};
public enum AlertType {
Information, Success, Warning, Error
}
}