diff --git a/OpenBirchWebsite/Pages/Components/ConsoleText.razor b/OpenBirchWebsite/Pages/Components/ConsoleText.razor new file mode 100644 index 0000000..21e860e --- /dev/null +++ b/OpenBirchWebsite/Pages/Components/ConsoleText.razor @@ -0,0 +1,37 @@ +@implements IDisposable + +@inject OpenBirchConsole console + +
+ @for (int i = 0; i < console.history.Count; i++) + { + int temp = i; + ConsoleLine line = console.history[temp]; + @if (line.source == ConsoleSource.User) + { + > @(' ' + line.text) + } + else + { + @line.text +
+ } + } +
+ +@code { + protected override void OnInitialized() + { + OpenBirchConsole.OnLinesChanged += updateComp; + } + + public void Dispose() + { + OpenBirchConsole.OnLinesChanged -= updateComp; + } + + void updateComp(List _) + { + InvokeAsync(StateHasChanged); + } +} \ No newline at end of file diff --git a/OpenBirchWebsite/Pages/Components/ConsoleText.razor.css b/OpenBirchWebsite/Pages/Components/ConsoleText.razor.css new file mode 100644 index 0000000..a7e6a46 --- /dev/null +++ b/OpenBirchWebsite/Pages/Components/ConsoleText.razor.css @@ -0,0 +1,7 @@ +.user-text{ + +} + +.openbirch-text * { + color: #31748f !important; +} \ No newline at end of file diff --git a/OpenBirchWebsite/Pages/Home.razor b/OpenBirchWebsite/Pages/Home.razor index 286d088..27d207c 100644 --- a/OpenBirchWebsite/Pages/Home.razor +++ b/OpenBirchWebsite/Pages/Home.razor @@ -5,27 +5,44 @@ Home -
- Welcome to
OpenBirch!!!
-
-
- -
- @for (int i = 0; i < console.history.Count; i++) - { - int temp = i; - @((console.history[temp].source == ConsoleSource.User) ? ">" : "#") @console.history[temp].text - } + +
+ +
+ + +
+ Welcome to
OpenBirch!!!
+ +
+
+ +
+
+ +
-
-
+ + + + + + + + + What is this? + Maths + + + + @code { - public string inputField = " "; + public string inputField = ""; public bool hasInteracted = false; // Has the user interacted with the input field? - private Task AutoTypingTask; + private Task? AutoTypingTask; readonly string[] exampleInputs = { "2+2", @@ -54,13 +71,17 @@ protected override async Task OnInitializedAsync() { - AutoTypingTask = StartAutoTyping(); + if (!GlobalVariables.HasAutoTypingEd) + AutoTypingTask = StartAutoTyping(); + + GlobalVariables.HasAutoTypingEd = true; } private async void OnInputClicked() { hasInteracted = true; - await AutoTypingTask; + if (AutoTypingTask != null) + await AutoTypingTask; nav.NavigateTo("openbirch"); } diff --git a/OpenBirchWebsite/Pages/Home.razor.css b/OpenBirchWebsite/Pages/Home.razor.css index 1fd9f9c..1c653d0 100644 --- a/OpenBirchWebsite/Pages/Home.razor.css +++ b/OpenBirchWebsite/Pages/Home.razor.css @@ -3,6 +3,7 @@ grid-template-columns: 1fr 1fr; /*border: red 1mm solid;*/ gap: 2rem; + place-items: center; } .console-container { @@ -10,7 +11,13 @@ grid-template-columns: 1fr 2fr 1fr 1fr; } + .input-field { max-width: 400px; min-width: 300px; +} + +.reverse-scroll-start { + display: flex; + flex-direction: column-reverse; } \ No newline at end of file diff --git a/OpenBirchWebsite/Pages/OpenBirch.razor b/OpenBirchWebsite/Pages/OpenBirch.razor index 58889fb..8a89169 100644 --- a/OpenBirchWebsite/Pages/OpenBirch.razor +++ b/OpenBirchWebsite/Pages/OpenBirch.razor @@ -5,18 +5,7 @@
-
- @for (int i = 0; i < console.history.Count; i++) - { - int temp = i; - ConsoleLine line = console.history[temp]; - @((line.source == ConsoleSource.User) ? ">" : "") @line.text - @if (line.source == ConsoleSource.OpenBirch) - { -
- } - } -
+
diff --git a/OpenBirchWebsite/Services/GlobalVariables.cs b/OpenBirchWebsite/Services/GlobalVariables.cs new file mode 100644 index 0000000..ac6de4b --- /dev/null +++ b/OpenBirchWebsite/Services/GlobalVariables.cs @@ -0,0 +1,8 @@ +namespace OpenBirchWebsite.Services +{ + // Cry about it + public static class GlobalVariables + { + public static bool HasAutoTypingEd = false; + } +} diff --git a/OpenBirchWebsite/Services/OpenBirchConsole.cs b/OpenBirchWebsite/Services/OpenBirchConsole.cs index df0d4e1..92e84d2 100644 --- a/OpenBirchWebsite/Services/OpenBirchConsole.cs +++ b/OpenBirchWebsite/Services/OpenBirchConsole.cs @@ -7,6 +7,8 @@ namespace OpenBirchWebsite.Services public List history = new(); private readonly IJSRuntime js = js; + public static event Action> OnLinesChanged; + public Task pushCommand(string command) { history.Add(new ConsoleLine() { source = ConsoleSource.User, text = command }); @@ -17,6 +19,7 @@ namespace OpenBirchWebsite.Services { string result = await js.InvokeAsync("runEval", command); history.Add(new ConsoleLine() { source = ConsoleSource.OpenBirch, text = result }); + OnLinesChanged?.Invoke(history); } public void Dispose() diff --git a/OpenBirchWebsite/_Imports.razor b/OpenBirchWebsite/_Imports.razor index 395a072..e3f6f50 100644 --- a/OpenBirchWebsite/_Imports.razor +++ b/OpenBirchWebsite/_Imports.razor @@ -9,4 +9,5 @@ @using OpenBirchWebsite @using OpenBirchWebsite.Layout @using MudBlazor -@using OpenBirchWebsite.Services \ No newline at end of file +@using OpenBirchWebsite.Services +@using OpenBirchWebsite.Pages.Components \ No newline at end of file diff --git a/OpenBirchWebsite/wwwroot/images/1s7n1rg9otbd1.webp b/OpenBirchWebsite/wwwroot/images/1s7n1rg9otbd1.webp new file mode 100644 index 0000000..a2ce5d4 Binary files /dev/null and b/OpenBirchWebsite/wwwroot/images/1s7n1rg9otbd1.webp differ diff --git a/OpenBirchWebsite/wwwroot/images/literally-scam-v0-ssol5c3n5ibd1.webp b/OpenBirchWebsite/wwwroot/images/literally-scam-v0-ssol5c3n5ibd1.webp new file mode 100644 index 0000000..091d833 Binary files /dev/null and b/OpenBirchWebsite/wwwroot/images/literally-scam-v0-ssol5c3n5ibd1.webp differ diff --git a/OpenBirchWebsite/wwwroot/videos/DifferentialEquation.gif b/OpenBirchWebsite/wwwroot/videos/DifferentialEquation.gif new file mode 100644 index 0000000..f608940 Binary files /dev/null and b/OpenBirchWebsite/wwwroot/videos/DifferentialEquation.gif differ diff --git a/OpenBirchWebsite/wwwroot/videos/DifferentialEquation.mp4 b/OpenBirchWebsite/wwwroot/videos/DifferentialEquation.mp4 new file mode 100644 index 0000000..6d4ca0b Binary files /dev/null and b/OpenBirchWebsite/wwwroot/videos/DifferentialEquation.mp4 differ