Adds custom input razor component

This commit is contained in:
BinaryAlley committed 2024-09-04 17:04:09 +03:00
1 parent 010e532394
commit f704a0325a
7 files changed
+251 -169

No files matched your search

@@ -1,8 +1,9 @@
<button type="submit" class="abort-button f-16 w-100px @CssClass" @onclick="OnClick" disabled="@IsDisabled">@ChildContent</button>
<button type="submit" class="@(IsConfirmButton ? "confirm" : "abort")-button f-16 w-100px @CssClass" @onclick="OnClick" disabled="@IsDisabled">@ChildContent</button>
@code {
[Parameter] public RenderFragment? ChildContent { get; set; }
[Parameter] public EventCallback OnClick { get; set; }
[Parameter] public bool IsDisabled { get; set; }
[Parameter] public bool IsConfirmButton { get; set; } = true;
[Parameter] public string? CssClass { get; set; }
}
@@ -0,0 +1,161 @@
.abort-button {
text-decoration: none;
border-radius: 4px;
border: solid 1px;
border-color: #006666 #004030 #003020 #006666;
background: linear-gradient(to bottom, #90AEA6 0%, #336659 50%, #004030 50%, #004030 100%);
color: #999999;
position: relative;
overflow: hidden;
transition: all 0.3s;
cursor: pointer;
outline: none;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.5);
z-index: 1;
}
.abort-button:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 50%;
background: radial-gradient(circle at center, #00FF00, transparent);
background-size: 120% 100%;
transform: translateY(100%);
background-position: center;
transition: transform 0.3s, opacity 0.8s;
pointer-events: none;
opacity: 0;
filter: blur(8px);
}
.abort-button:hover {
color: #fff;
}
.abort-button:hover:before {
transform: translateY(50%);
opacity: 1;
}
.abort-button:active {
background: #CC009F58;
font-style: italic;
}
.abort-button:disabled {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
}
.abort-button:disabled:hover:before {
transform: translateY(100%);
opacity: 0;
}
.abort-button:disabled:active {
font-style: normal;
}
.abort-button[disabled] {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
pointer-events: none;
text-decoration: none;
}
.abort-button[disabled]:hover:before {
transform: translateY(100%);
opacity: 0;
}
.abort-button[disabled]:active {
font-style: normal;
}
.confirm-button {
text-decoration: none;
border-radius: 4px;
border: solid 1px;
border-color: #363636 #000 #000 #363636;
background: linear-gradient(to bottom, #AAAAAA 0%, #363636 50%, #000 50%, #000 100%);
color: #AAAAAA;
position: relative;
overflow: hidden;
transition: all 0.3s;
cursor: pointer;
outline: none;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.5);
z-index: 1;
}
.confirm-button:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 50%;
background: radial-gradient(circle at center, #00FF8B, transparent);
background-size: 120% 100%;
transform: translateY(100%);
background-position: center;
transition: transform 0.3s, opacity 0.8s;
pointer-events: none;
opacity: 0;
filter: blur(8px);
}
.confirm-button:hover {
color: #fff;
}
.confirm-button:hover:before {
transform: translateY(50%);
opacity: 1;
}
.confirm-button:active {
background: #CC000000;
font-style: italic;
}
.confirm-button:disabled {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
}
.confirm-button:disabled:hover:before {
transform: translateY(100%);
opacity: 0;
}
.confirm-button:disabled:active {
font-style: normal;
}
confirm-button[disabled] {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
pointer-events: none;
text-decoration: none;
}
.confirm-button[disabled]:hover:before {
transform: translateY(100%);
opacity: 0;
}
.confirm-button[disabled]:active {
font-style: normal;
}
@@ -1,80 +0,0 @@
.abort-button {
text-decoration: none;
border-radius: 4px;
border: solid 1px;
border-color: #006666 #004030 #003020 #006666;
background: linear-gradient(to bottom, #90AEA6 0%, #336659 50%, #004030 50%, #004030 100%);
color: #999999;
position: relative;
overflow: hidden;
transition: all 0.3s;
cursor: pointer;
outline: none;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.5);
z-index: 1;
}
.abort-button:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 50%;
background: radial-gradient(circle at center, #00FF00, transparent);
background-size: 120% 100%;
transform: translateY(100%);
background-position: center;
transition: transform 0.3s, opacity 0.8s;
pointer-events: none;
opacity: 0;
filter: blur(8px);
}
.abort-button:hover:before {
transform: translateY(50%);
opacity: 1;
}
.abort-button:active {
background: #CC009F58;
font-style: italic;
}
.abort-button:hover {
color: #fff;
}
.abort-button:disabled {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
}
.abort-button:disabled:hover:before {
transform: translateY(100%);
opacity: 0;
}
.abort-button:disabled:active {
font-style: normal;
}
.abort-button[disabled] {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
pointer-events: none;
text-decoration: none;
}
.abort-button[disabled]:hover:before {
transform: translateY(100%);
opacity: 0;
}
.abort-button[disabled]:active {
font-style: normal;
}
@@ -1,8 +0,0 @@
<button type="submit" class="confirm-button f-16 w-100px @CssClass" @onclick="OnClick" disabled="@IsDisabled">@ChildContent</button>
@code {
[Parameter] public RenderFragment? ChildContent { get; set; }
[Parameter] public EventCallback OnClick { get; set; }
[Parameter] public bool IsDisabled { get; set; }
[Parameter] public string? CssClass { get; set; }
}
@@ -1,80 +0,0 @@
.confirm-button {
text-decoration: none;
border-radius: 4px;
border: solid 1px;
border-color: #363636 #000 #000 #363636;
background: linear-gradient(to bottom, #AAAAAA 0%, #363636 50%, #000 50%, #000 100%);
color: #AAAAAA;
position: relative;
overflow: hidden;
transition: all 0.3s;
cursor: pointer;
outline: none;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.5);
z-index: 1;
}
.confirm-button:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 50%;
background: radial-gradient(circle at center, #00FF8B, transparent);
background-size: 120% 100%;
transform: translateY(100%);
background-position: center;
transition: transform 0.3s, opacity 0.8s;
pointer-events: none;
opacity: 0;
filter: blur(8px);
}
.confirm-button:hover {
color: #fff;
}
.confirm-button:hover:before {
transform: translateY(50%);
opacity: 1;
}
.confirm-button:active {
background: #CC000000;
font-style: italic;
}
.confirm-button:disabled {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
}
.confirm-button:disabled:hover:before {
transform: translateY(100%);
opacity: 0;
}
.confirm-button:disabled:active {
font-style: normal;
}
confirm-button[disabled] {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
pointer-events: none;
text-decoration: none;
}
.confirm-button[disabled]:hover:before {
transform: translateY(100%);
opacity: 0;
}
.confirm-button[disabled]:active {
font-style: normal;
}
@@ -0,0 +1,33 @@
<input type="@Type"
class="enlightenment-input w-100 @CssClass"
name="@Name"
autocomplete="@(AutoComplete ? "on" : "off")"
value="@Value"
@oninput="OnInputHandlerAsync"
placeholder="@Placeholder"
disabled="@IsDisabled"
readonly="@IsReadOnly"
data-has-error="@HasError" />
@code {
[Parameter] public string Type { get; set; } = "text";
[Parameter] public string? CssClass { get; set; }
[Parameter] public string? Name { get; set; }
[Parameter] public bool AutoComplete { get; set; } = true;
[Parameter] public string? Value { get; set; }
[Parameter] public EventCallback<string> ValueChanged { get; set; }
[Parameter] public string? Placeholder { get; set; }
[Parameter] public bool IsDisabled { get; set; }
[Parameter] public bool IsReadOnly { get; set; }
[Parameter] public bool HasError { get; set; }
/// <summary>
/// Handles the input event.
/// </summary>
/// <param name="e">The event arguments.</param>
private async Task OnInputHandlerAsync(ChangeEventArgs e)
{
Value = e.Value?.ToString();
await ValueChanged.InvokeAsync(Value);
}
}
@@ -0,0 +1,55 @@
.enlightenment-input {
font-size: 14px;
padding: 5px;
border: 1px solid;
border-color: var(--border-unlit) var(--border-lit) var(--border-lit) var(--border-unlit);
border-radius: 3px;
background: linear-gradient(0deg, #90c247, #509c00);
transition: background 0.3s, color 0.3s;
color: #000;
outline: none;
position: relative;
box-sizing: border-box;
}
.enlightenment-input:hover {
background: var(--window-button-over-color);
}
.enlightenment-input:not(:focus) {
background: linear-gradient(0deg, #6b7579, #576b65);
color: #000;
}
.enlightenment-input:focus {
font-style: italic;
color: #333;
background: linear-gradient(0deg, #6AAFF8, #82E9F7);
box-shadow: inset 4px 6px 8px rgba(0,0,0,0.6);
border-color: var(--border-unlit) var(--border-lit) var(--border-lit) var(--border-unlit);
outline: none;
}
.enlightenment-input::placeholder {
color: #999;
}
.enlightenment-input:disabled {
color: #999;
background: var(--window-back-color);
}
.enlightenment-input[readonly] {
color: #999;
background: var(--window-back-color);
}
.enlightenment-input[data-has-error="true"] {
border-color: #f00;
color: #FFF;
background: #700;
}
textarea {
resize: none;
}