Initial Commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<div class="formContainer">
|
||||
<div class="formTextContainer">
|
||||
<div class="formLabel">
|
||||
@Label:
|
||||
</div>
|
||||
<input readonly="@ReadOnly"
|
||||
class="formCheckboxInput"
|
||||
type="checkbox"
|
||||
id="@labelId"
|
||||
checked="@Value"
|
||||
@onchange="OnChange"
|
||||
@oninput="OnChange"/>
|
||||
</div>
|
||||
@if (Info != "")
|
||||
{
|
||||
<div class="formInfo">
|
||||
@Info
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<style>
|
||||
.formContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.formTextContainer {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.formLabel {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.formInfo {
|
||||
font-size: 0.8rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.formCheckboxInput {
|
||||
background-color: var(--primary);
|
||||
color: var(--primary);
|
||||
border: 2px solid var(--primary-border);
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public string Label { get; set; } = "";
|
||||
|
||||
[Parameter] public string Info { get; set; } = "";
|
||||
|
||||
[Parameter] public EventCallback<ChangeEventArgs> OnChange { get; set; }
|
||||
|
||||
[Parameter] public bool ReadOnly { get; set; }
|
||||
|
||||
[Parameter] public bool Value { get; set; }
|
||||
|
||||
private string labelId = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
labelId = Label.ToLower().Replace(" ", "_");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<div class="displayContainer">
|
||||
@if (Label != "")
|
||||
{
|
||||
<div class="formLabel">
|
||||
@Label
|
||||
</div>
|
||||
}
|
||||
<div class="displayContent">
|
||||
@Display
|
||||
</div>
|
||||
@if (Info != "")
|
||||
{
|
||||
<div class="formInfo">
|
||||
@Info
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.displayContainer {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.displayContent {
|
||||
background-color: var(--accent);
|
||||
width: 100%;
|
||||
border: 1px solid var(--primary-border);
|
||||
border-radius: 1px;
|
||||
padding: 8px;
|
||||
min-height: 42px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
//TODO Clean up
|
||||
[Parameter] public string Label { get; set; } = default!;
|
||||
|
||||
[Parameter] public string Info { get; set; } = default!;
|
||||
|
||||
[Parameter] public RenderFragment? Display { get; set; }
|
||||
|
||||
[Parameter] public EventCallback<ChangeEventArgs> OnChange { get; set; }
|
||||
|
||||
[Parameter] public bool? ReadOnly { get; set; }
|
||||
|
||||
[Parameter] public string? Value { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
@using System.Web
|
||||
<div class="escapeCodeContainer">
|
||||
<textarea style="background-color: #2C2E33; width: 100%; border:3px solid #A8ADB9; border-radius:1px; padding: 8px;"
|
||||
rows="8"
|
||||
@onchange="OnChange"/>
|
||||
|
||||
<textarea style="background-color: #2C2E33; width: 100%; border:3px solid #A8ADB9; border-radius:1px; padding: 8px;"
|
||||
rows="8"
|
||||
@bind="Output"/>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.escapeCodeContainer {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
string Output = "";
|
||||
|
||||
public void OnChange(ChangeEventArgs changeEventArgs)
|
||||
{
|
||||
var encoded = HttpUtility.HtmlEncode(changeEventArgs.Value!.ToString());
|
||||
Output = encoded?.Replace("@", "@@")!;
|
||||
Output = Output.Replace("\n", "<br />");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
@using Model.MemoryTester
|
||||
@using Services.Immortal
|
||||
@implements IDisposable
|
||||
|
||||
@inject IMemoryTesterService MemoryTesterService
|
||||
|
||||
<div class="formGuessContainer">
|
||||
@if (MemoryQuestion.Name != "")
|
||||
{
|
||||
<div class="formLabel">
|
||||
@MemoryQuestion.Name
|
||||
</div>
|
||||
}
|
||||
<div>
|
||||
<input readonly="@MemoryQuestion.IsRevealed"
|
||||
class="formTextInput @(MemoryQuestion.IsRevealed ? "revealed" : IsSubmitted == false ? "guess" : int.Parse(guess ?? string.Empty) == MemoryQuestion.Answer ? "correct" : "wrong")"
|
||||
placeholder="guess..."
|
||||
type="number"
|
||||
value="@guess"
|
||||
id="@labelId"
|
||||
@onchange="OnGuessChanged"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.formGuessContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.formLabel {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.formInfo {
|
||||
font-size: 0.8rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.formTextInput {
|
||||
background-color: #2C2E33;
|
||||
border: 3px solid #A8ADB9;
|
||||
border-radius: 1px;
|
||||
padding: 8px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.guess {
|
||||
background-color: var(--primary);
|
||||
border: 4px solid var(--primary-border);
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
::placeholder {
|
||||
color: white;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.formTextInput.correct {
|
||||
border: 3px solid green;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.formTextInput.wrong {
|
||||
border: 3px solid red;
|
||||
border-radius: 2px;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public string Label { get; set; } = "";
|
||||
|
||||
[Parameter] public string Info { get; set; } = "";
|
||||
|
||||
[Parameter] public EventCallback<AnswerEventArgs> OnChange { get; set; }
|
||||
|
||||
[Parameter] public MemoryQuestionModel MemoryQuestion { get; set; } = default!;
|
||||
|
||||
[Parameter] public bool IsSubmitted { get; set; }
|
||||
|
||||
|
||||
private string? guess = "";
|
||||
|
||||
|
||||
private string labelId = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
labelId = Label.ToLower().Replace(" ", "_") + MemoryQuestion.Id;
|
||||
|
||||
MemoryTesterService.Subscribe(OnMemoryEvent);
|
||||
|
||||
if (MemoryQuestion.IsRevealed)
|
||||
{
|
||||
guess = MemoryQuestion.Answer.ToString();
|
||||
}
|
||||
|
||||
OnRefresh();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
MemoryTesterService.Unsubscribe(OnMemoryEvent);
|
||||
}
|
||||
|
||||
void OnMemoryEvent(MemoryTesterEvent memoryTesterEvent)
|
||||
{
|
||||
if (memoryTesterEvent == MemoryTesterEvent.OnVerify)
|
||||
{
|
||||
OnVerify();
|
||||
}
|
||||
|
||||
if (memoryTesterEvent == MemoryTesterEvent.OnRefresh)
|
||||
{
|
||||
OnRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
if (MemoryQuestion.IsRevealed)
|
||||
{
|
||||
guess = MemoryQuestion.Answer.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
void OnVerify()
|
||||
{
|
||||
IsSubmitted = true;
|
||||
}
|
||||
|
||||
void OnRefresh()
|
||||
{
|
||||
guess = "";
|
||||
|
||||
if (MemoryQuestion.IsRevealed)
|
||||
{
|
||||
guess = MemoryQuestion.Answer.ToString();
|
||||
}
|
||||
|
||||
|
||||
IsSubmitted = false;
|
||||
}
|
||||
|
||||
void OnGuessChanged(ChangeEventArgs changeEventArgs)
|
||||
{
|
||||
guess = changeEventArgs.Value!.ToString()!;
|
||||
|
||||
OnChange.InvokeAsync(new AnswerEventArgs
|
||||
{
|
||||
Name = MemoryQuestion.Name,
|
||||
IsCorrect = int.Parse(guess) == MemoryQuestion.Answer,
|
||||
Guess = int.Parse(guess)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<div style="font-size:0.8rem; font-style:italic;">
|
||||
<i>
|
||||
@ChildContent
|
||||
</i>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public RenderFragment? ChildContent { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<div style="font-weight:800">
|
||||
@ChildContent:
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public RenderFragment? ChildContent { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<div style="display: flex; gap: 16px; width: 100%; flex-direction: column;">
|
||||
@ChildContent
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public RenderFragment? ChildContent { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<div class="formNumberContainer">
|
||||
@if (FormLabelComponent != null)
|
||||
{
|
||||
<FormLabelComponent>@FormLabelComponent</FormLabelComponent>
|
||||
}
|
||||
<div>
|
||||
<input readonly="@ReadOnly"
|
||||
id="@Id"
|
||||
class="numberInput"
|
||||
type="number"
|
||||
min="@Min"
|
||||
max="@Max"
|
||||
value="@Value"
|
||||
@onchange="OnInputChanged"/>
|
||||
</div>
|
||||
@if (FormInfoComponent != null)
|
||||
{
|
||||
<FormInfoComponent>@FormInfoComponent</FormInfoComponent>
|
||||
}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.formNumberContainer {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.numberInput {
|
||||
width: 100%;
|
||||
background-color: var(--primary);
|
||||
border: 4px solid var(--primary-border);
|
||||
border-radius: 1px;
|
||||
padding: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public RenderFragment? FormLabelComponent { get; set; }
|
||||
|
||||
[Parameter] public string Id { get; set; } = default!;
|
||||
|
||||
[Parameter] public RenderFragment? FormInfoComponent { get; set; }
|
||||
|
||||
[Parameter] public EventCallback<ChangeEventArgs> OnChange { get; set; }
|
||||
|
||||
void OnInputChanged(ChangeEventArgs changeEventArgs)
|
||||
{
|
||||
var valueWas = Value;
|
||||
var newValue = int.Parse(changeEventArgs.Value!.ToString()!);
|
||||
|
||||
if (newValue > Max)
|
||||
{
|
||||
newValue = Max;
|
||||
}
|
||||
|
||||
if (newValue < Min)
|
||||
{
|
||||
newValue = Min;
|
||||
}
|
||||
|
||||
if (valueWas != newValue)
|
||||
{
|
||||
Value = newValue;
|
||||
changeEventArgs.Value = newValue;
|
||||
OnChange.InvokeAsync(changeEventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter] public bool ReadOnly { get; set; }
|
||||
|
||||
[Parameter] public int Value { get; set; }
|
||||
|
||||
[Parameter] public int Min { get; set; }
|
||||
|
||||
[Parameter] public int Max { get; set; } = 2048;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<div style="display: flex; width: 100%; flex-direction: column; gap:6px;">
|
||||
@if (FormLabelComponent != null)
|
||||
{
|
||||
<FormLabelComponent>@FormLabelComponent</FormLabelComponent>
|
||||
}
|
||||
<select style="background-color: #2C2E33; width: 100%; border:3px solid #A8ADB9; border-radius:1px; padding: 8px;"
|
||||
@onchange="OnChange">
|
||||
@ChildContent
|
||||
</select>
|
||||
|
||||
@if (FormInfoComponent != null)
|
||||
{
|
||||
<FormInfoComponent>@FormInfoComponent</FormInfoComponent>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public RenderFragment? FormLabelComponent { get; set; }
|
||||
|
||||
[Parameter] public RenderFragment? FormInfoComponent { get; set; }
|
||||
|
||||
[Parameter] public RenderFragment? ChildContent { get; set; }
|
||||
|
||||
[Parameter] public EventCallback<ChangeEventArgs> OnChange { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<div class="form-text-container">
|
||||
@if (Label != "")
|
||||
{
|
||||
<div class="form-label">
|
||||
@Label
|
||||
</div>
|
||||
}
|
||||
<div>
|
||||
<textarea readonly="@ReadOnly"
|
||||
class="textAreaInput"
|
||||
type="text"
|
||||
rows="@Rows"
|
||||
value="@Value"
|
||||
@onchange="OnChange"/>
|
||||
</div>
|
||||
@if (Info != "")
|
||||
{
|
||||
<div class="form-info">
|
||||
@Info
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.form-text-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.textAreaInput {
|
||||
width: 100%;
|
||||
border-radius: 1px;
|
||||
padding: 8px;
|
||||
background-color: var(--primary);
|
||||
border: 4px solid var(--primary-border);
|
||||
}
|
||||
|
||||
.form-text-container .form-label {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.form-text-container .form-info {
|
||||
font-size: 0.8rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.form-text-container .form-text-input {
|
||||
background-color: #2C2E33;
|
||||
border: 3px solid #A8ADB9;
|
||||
border-radius: 1px;
|
||||
padding: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public RenderFragment? FormLabelComponent { get; set; }
|
||||
|
||||
[Parameter] public RenderFragment? FormInfoComponent { get; set; }
|
||||
|
||||
[Parameter] public EventCallback<ChangeEventArgs> OnChange { get; set; }
|
||||
|
||||
[Parameter] public bool? ReadOnly { get; set; }
|
||||
|
||||
[Parameter] public string? Value { get; set; }
|
||||
|
||||
[Parameter] public int Rows { get; set; } = 4;
|
||||
|
||||
[Parameter] public string Label { get; set; } = "";
|
||||
|
||||
[Parameter] public string Info { get; set; } = "";
|
||||
|
||||
[Parameter] public string Placeholder { get; set; } = "";
|
||||
|
||||
private string labelId = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
labelId = Label.ToLower().Replace(" ", "_");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<div class="formContainer">
|
||||
@if (Label != "")
|
||||
{
|
||||
<div class="formLabel">
|
||||
@Label
|
||||
</div>
|
||||
}
|
||||
<div>
|
||||
<input readonly="@ReadOnly"
|
||||
class="formTextInput"
|
||||
placeholder="@Placeholder"
|
||||
type="text"
|
||||
value="@Value"
|
||||
id="@Id"
|
||||
@onfocus="OnFocus"
|
||||
@oninput="OnInput"
|
||||
@onchange="OnChange"/>
|
||||
</div>
|
||||
@if (Info != "")
|
||||
{
|
||||
<div class="formInfo">
|
||||
@Info
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<style>
|
||||
.formContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.formLabel {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.formInfo {
|
||||
font-size: 0.8rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.formTextInput {
|
||||
border-radius: 1px;
|
||||
padding: 8px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
background-color: var(--primary);
|
||||
border: 4px solid var(--primary-border);
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public string Id { get; set; } = "";
|
||||
|
||||
[Parameter] public string Label { get; set; } = "";
|
||||
|
||||
[Parameter] public string Info { get; set; } = "";
|
||||
|
||||
[Parameter] public string Placeholder { get; set; } = "";
|
||||
|
||||
[Parameter] public EventCallback<ChangeEventArgs> OnInput { get; set; }
|
||||
|
||||
|
||||
[Parameter] public EventCallback<ChangeEventArgs> OnChange { get; set; }
|
||||
|
||||
[Parameter] public EventCallback OnFocus { get; set; }
|
||||
|
||||
|
||||
[Parameter] public bool ReadOnly { get; set; }
|
||||
|
||||
[Parameter] public string Value { get; set; } = "";
|
||||
|
||||
private string labelId = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
labelId = Label.ToLower().Replace(" ", "_");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<div class="formContainer">
|
||||
<div class="formTextContainer">
|
||||
<div class="formLabel">
|
||||
@Label:
|
||||
</div>
|
||||
<label class="switch">
|
||||
<input readonly="@ReadOnly"
|
||||
type="checkbox"
|
||||
id="@labelId"
|
||||
class="@ClassStyle"
|
||||
checked="@Value"
|
||||
@oninput="OnChange"/>
|
||||
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
@if (Info != "")
|
||||
{
|
||||
<div class="formInfo">
|
||||
@Info
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<style>
|
||||
.formContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.formTextContainer {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.formLabel {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.formInfo {
|
||||
font-size: 0.8rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.switch {
|
||||
position: relative;
|
||||
width: 60px;
|
||||
height: 34px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
top: 4px;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: var(--paper-border);
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 26px;
|
||||
width: 26px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.checked + .slider {
|
||||
background-color: #7838df;
|
||||
}
|
||||
|
||||
.checked + .slider:before {
|
||||
-webkit-transform: translateX(26px);
|
||||
-ms-transform: translateX(26px);
|
||||
transform: translateX(26px);
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter] public string Label { get; set; } = "";
|
||||
|
||||
[Parameter] public string Info { get; set; } = "";
|
||||
|
||||
[Parameter] public EventCallback<ChangeEventArgs> OnChange { get; set; }
|
||||
|
||||
[Parameter] public bool ReadOnly { get; set; }
|
||||
|
||||
[Parameter] public bool Value { get; set; }
|
||||
|
||||
private string labelId = "";
|
||||
|
||||
private string ClassStyle => Value ? "checked" : "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
labelId = Label.ToLower().Replace(" ", "_");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user