Skip to content

Commit

Permalink
+ list favorite sentences
Browse files Browse the repository at this point in the history
  • Loading branch information
NicklausBrain committed Dec 1, 2024
1 parent 8442e3d commit 52554d0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 39 deletions.
14 changes: 4 additions & 10 deletions My1kWordsEe/Components/Layout/GameComposite.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{
public string Title { get; set; }

Check warning on line 17 in My1kWordsEe/Components/Layout/GameComposite.razor

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'Title' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}

class GameCompositeModel
{
public Slide[] Slides { get; set; } = new Slide[] { };
Expand All @@ -24,19 +25,19 @@

public Slide CurrentSlide { get; set; }

Check warning on line 26 in My1kWordsEe/Components/Layout/GameComposite.razor

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'CurrentSlide' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}

GameCompositeModel Game = new();

private void OnNext() { }// Game.NextSlide();
private void OnNext() { } // Game.NextSlide();
private void OnPrevious() { } //Game.PrevSlide();
private void OnSelectSlide(ushort index) { } // Game.GoToSlide(index);
private Task OnSubmit()
{

return Task.CompletedTask;
} //=> { }; Game.CurrentSlide.Submit(CheckEnTranslationCommand);
}
}


Expand All @@ -49,13 +50,6 @@
})
</script>

<style>
.img-max-w-256 {
max-width: 256px;
width: 100%;
}
</style>

<h3>GameComposite</h3>

<div class="text-left">
Expand Down
15 changes: 4 additions & 11 deletions My1kWordsEe/Components/Layout/SampleV2.razor
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
public required SampleSentence Sample { get; init; }

[Parameter]
public required Func<SampleSentence, Task> AddToFavorites { get; init; }
public Func<SampleSentence, Task>? AddToFavorites { get; init; }

[Parameter]
public required Func<SampleSentence, Task> RemoveFromFavorites { get; init; }
public Func<SampleSentence, Task>? RemoveFromFavorites { get; init; }

[Parameter]
public bool IsFavorite { get; init; }
Expand Down Expand Up @@ -94,13 +94,6 @@
};
</script>

<style>
.img-max-w-256 {
max-width: 256px;
width: 100%;
}
</style>

<Card>
<CardBody>
<table class="table">
Expand All @@ -120,13 +113,13 @@
@if (IsLoggedIn)
{
<li class="list-group-item border-0">
@if (IsFavorite)
@if (IsFavorite && RemoveFromFavorites != null)
{
<Button Color="ButtonColor.Primary" Size="ButtonSize.Small" @onclick="() => RemoveFromFavorites(Sample)">
<i role="button" class="bi bi-star-fill"></i>
</Button>
}
else
else if (AddToFavorites != null)
{
<Button Color="ButtonColor.Primary" Size="ButtonSize.Small" @onclick="() => AddToFavorites(Sample)">
<i role="button" class="bi bi-star"></i>
Expand Down
19 changes: 17 additions & 2 deletions My1kWordsEe/Components/Pages/FavoritesPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,29 @@
}
else
{
<h3>No favorites yet!</h3>
<p class="mt-3">No favorite words yet</p>
}
</div>
</Content>
</Tab>
<Tab Title="Sentences">
<Content>
<p class="mt-3">No sentences yet</p>
<div class="row">
@if (favorites.Words.Any())
{
@foreach (var sentencePair in favorites.Sentences)
{
var sentence = sentencePair.Value;
<div class="col col-12 col-sm-6 p-1">
<SampleV2 Sample="sentence"></SampleV2>
</div>
}
}
else
{
<p class="mt-3">No favorite sentences yet</p>
}
</div>
</Content>
</Tab>
</Tabs>
Expand Down
8 changes: 0 additions & 8 deletions My1kWordsEe/Components/Pages/Games/ListenToEeGamePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@
};
</script>

@* todo: extract style *@
<style>
.img-max-w-256 {
max-width: 256px;
width: 100%;
}
</style>

<div class="text-left">
<div class="row">
<div class="col-7">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@
};
</script>

@* todo: extract style *@
<style>
.img-max-w-256 {
max-width: 256px;
width: 100%;
}
</style>

<div class="text-left">
<div class="row">
<div class="col-7">
Expand Down
5 changes: 5 additions & 0 deletions My1kWordsEe/wwwroot/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ h1:focus {
box-shadow: 0 10px 20px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
}

.img-max-w-256 {
max-width: 256px;
width: 100%;
}

.favorite-active {
color: rebeccapurple
}

0 comments on commit 52554d0

Please sign in to comment.