Skip to content

Commit

Permalink
Add ability to filter by skills
Browse files Browse the repository at this point in the history
  • Loading branch information
codemonkey85 committed Dec 17, 2023
1 parent 4920065 commit a5dbfd6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
35 changes: 28 additions & 7 deletions AboutMe/Wasm/Pages/Resume.razor
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<MudStack Spacing="3"
Class="mb-3">
@foreach (var job in resumeModel.Jobs
.Where(job => !SelectedSkills.Any() || SelectedSkills.All(job.SkillsUsed.Contains))
.OrderByDescending(job => job.PresentlyEmployed)
.ThenByDescending(job => job.EndDate))
{
Expand Down Expand Up @@ -113,14 +114,34 @@
@code {
private RenderFragment SkillsFragment(IEnumerable<Skill> skills) =>
@<MudGrid Class="mb-3"
Spacing="0">
Spacing="0">
@foreach (var skill in skills.OrderBy(skill => skill.Name))
{
<MudItem>
<MudChip title="@skill.Name"
OnClick="@(() => OnSelectSkill(skill))"
Color="@GetSkillColor(skill)">
@skill.Name
</MudChip>
</MudItem>
}
</MudGrid>;
}
@code {
void OnSelectSkill(Skill skill)
{
if (SelectedSkills.Contains(skill))
{
<MudItem>
<MudChip title="@skill.Name">
@skill.Name
</MudChip>
</MudItem>
SelectedSkills.Remove(skill);
}
</MudGrid>;
else
{
SelectedSkills.Add(skill);
}
}

Color GetSkillColor(Skill skill)
{
return SelectedSkills.Contains(skill) ? Color.Primary : Color.Default;
}
}
4 changes: 3 additions & 1 deletion AboutMe/Wasm/Pages/Resume.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private class ResumeModel
public required List<Job> Jobs { get; set; } = [];
}

private class Skill
private struct Skill
{
public required string Name { get; set; }

Expand Down Expand Up @@ -393,4 +393,6 @@ private static class Skills
Description = string.Empty,
};
}

private List<Skill> SelectedSkills { get; set; } = [];
}

0 comments on commit a5dbfd6

Please sign in to comment.