Initial commit

This commit is contained in:
2022-03-28 18:44:08 -04:00
commit e43d9a90e7
267 changed files with 17049 additions and 0 deletions
@@ -0,0 +1,73 @@
<div class="formContainer">
<div class="formTextContainer">
<div class="formLabel">
@Label:
</div>
<input readonly="@ReadOnly"
class="formCheckboxInput"
type="checkbox"
id="@labelId"
checked="@Value
"@onchange="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() {
labelId = Label.ToLower().Replace(" ", "_");
}
}
@@ -0,0 +1,55 @@
<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; }
[Parameter]
public string Info { get; set; }
[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,29 @@
@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 />");
}
}
+154
View File
@@ -0,0 +1,154 @@
@using Services
@using Services.Immortal
@using Model.Immortal.MemoryTester
@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) == 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; }
[Parameter]
public bool IsSubmitted { get; set; }
private string guess { get; set; } = "";
private string labelId = "";
protected override void 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)
});
}
}
+12
View File
@@ -0,0 +1,12 @@
<div style="font-size:0.8rem; font-style:italic;">
<i>
@ChildContent
</i>
</div>
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
}
+10
View File
@@ -0,0 +1,10 @@
<div style="font-weight:800">
@ChildContent:
</div>
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
}
+10
View File
@@ -0,0 +1,10 @@
<div style="display: flex; gap: 16px; width: 100%; flex-direction: column;">
@ChildContent
</div>
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
}
+59
View File
@@ -0,0 +1,59 @@
<div class="formNumberContainer">
@if (FormLabelComponent != null) {
<FormLabelComponent>@FormLabelComponent</FormLabelComponent>
}
<div>
<input readonly="@ReadOnly"
class="numberInput"
type="number"
min="@Min"
max="@Max"
value="@Value"
@onchange="OnChange"/>
</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 RenderFragment? FormInfoComponent { get; set; }
[Parameter]
public EventCallback<ChangeEventArgs> OnChange { get; set; }
[Parameter]
public bool? ReadOnly { get; set; }
[Parameter]
public int? Value { get; set; }
[Parameter]
public int? Min { get; set; }
[Parameter]
public int? Max { get; set; }
}
+30
View File
@@ -0,0 +1,30 @@
<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,90 @@
<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() {
labelId = Label.ToLower().Replace(" ", "_");
}
}
+75
View File
@@ -0,0 +1,75 @@
<div class="formContainer">
@if (Label != "") {
<div class="formLabel">
@Label
</div>
}
<div>
<input readonly="@ReadOnly"
class="formTextInput"
placeholder="@Placeholder"
type="text"
value="@Value"
id="@labelId"
@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 Label { get; set; } = "";
[Parameter]
public string Info { get; set; } = "";
[Parameter]
public string Placeholder { get; set; } = "";
[Parameter]
public EventCallback<ChangeEventArgs> OnChange { get; set; }
[Parameter]
public bool ReadOnly { get; set; }
[Parameter]
public string Value { get; set; } = "";
private string labelId = "";
protected override void OnInitialized() {
labelId = Label.ToLower().Replace(" ", "_");
}
}