Skip to content

Commit

Permalink
Use struct instead of class
Browse files Browse the repository at this point in the history
  • Loading branch information
codemonkey85 committed Feb 20, 2024
1 parent dc7af80 commit e3937ab
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 112 deletions.
6 changes: 5 additions & 1 deletion AboutMe/Wasm/Components/SocialLink.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
namespace AboutMe.Wasm.Components;

public class SocialLink
public struct SocialLink
{
public SocialLink()
{
}

public string? Name { get; set; }

public string? Url { get; set; }
Expand Down
7 changes: 2 additions & 5 deletions AboutMe/Wasm/Components/SocialLinkComponent.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
@if (SocialLink is not null)
{
@SocialLinkFragment(SocialLink)
}
@SocialLinkFragment(SocialLink)

@code {
[Parameter, EditorRequired]
public SocialLink? SocialLink { get; set; }
public SocialLink SocialLink { get; set; }

private static RenderFragment SocialLinkFragment(SocialLink contactUrl) =>
@<MudCard>
Expand Down
6 changes: 3 additions & 3 deletions AboutMe/Wasm/Pages/Projects.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public partial class Projects
}, // Minecraft Command Builder
];

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

Expand All @@ -72,10 +72,10 @@ private class Project

public string? GitHubUrl { get; set; }

public List<ProductImage> Screenshots { get; set; } = [];
public List<ProductImage> Screenshots { get; set; }
}

private class ProductImage
private struct ProductImage
{
public required string Url { get; set; }

Expand Down
187 changes: 92 additions & 95 deletions AboutMe/Wasm/Pages/Resume.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,111 +8,108 @@
My Résumé
</MudText>

@if (resumeModel is not null)
{
<MudText Typo="@Typo.h5">
@resumeModel.Name
</MudText>
<MudText Typo="@Typo.h5">
@resumeModel.Name
</MudText>

<MudText Typo="@Typo.body1">
@resumeModel.Summary
</MudText>
<MudText Typo="@Typo.body1">
@resumeModel.Summary
</MudText>

<MudLink Href="@($"mailto:{resumeModel.Email}?subject=Resume")">
@resumeModel.Email
</MudLink>
<MudLink Href="@($"mailto:{resumeModel.Email}?subject=Resume")">
@resumeModel.Email
</MudLink>

<MudText Typo="@Typo.body1">
<MudButton Href="https://github.com/codemonkey85/"
Target="_blank"
Variant="@Variant.Filled"
Color="@Color.Primary"
EndIcon="@Icons.Custom.Brands.GitHub">
Follow me on GitHub
</MudButton>
</MudText>
<MudText Typo="@Typo.body1">
<MudButton Href="https://github.com/codemonkey85/"
Target="_blank"
Variant="@Variant.Filled"
Color="@Color.Primary"
EndIcon="@Icons.Custom.Brands.GitHub">
Follow me on GitHub
</MudButton>
</MudText>

<MudDivider DividerType="@DividerType.FullWidth"
Class="my-2" />
<MudDivider DividerType="@DividerType.FullWidth"
Class="my-2" />

@if (resumeModel.Skills is { Count: > 0 })
{
<MudStack Row="@true">
<MudText Typo="@Typo.h5"
Class="mb-3">
Skills
</MudText>
@if (SelectedSkills.Any())
{
<MudIconButton OnClick="@ClearSelectedSkills"
Variant="@Variant.Filled"
Color="@Color.Default"
Size="@Size.Small"
Icon="@Icons.Material.Filled.Clear"
Title="Clear Selection" />
}
</MudStack>
@SkillsFragment(resumeModel.Skills)
}

@if (resumeModel.Jobs is { Count: > 0 })
{
@if (resumeModel.Skills is { Count: > 0 })
{
<MudStack Row="@true">
<MudText Typo="@Typo.h5"
Class="mb-3">
Experience
Skills
</MudText>
<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))
{
<MudCard>
<MudCardHeader>
<MudStack Spacing="0">
<MudText Typo="@Typo.h5">
@job.Title
</MudText>
<MudText Typo="@Typo.subtitle1">
@job.Company
</MudText>
<MudText Typo="@Typo.body2">
@($"{job.StartDate:MMM yyyy} - {(job.EndDate is null ? "Present" : $"{job.EndDate:MMM yyyy}")}")
</MudText>
</MudStack>
</MudCardHeader>
<MudCardContent>
@if (job.Summary is { Length: > 0 })
{
<MudText Typo="@Typo.body1"
Class="mb-3">
@job.Summary
</MudText>
}
@if (job.SkillsUsed is { Count: > 0 })
{
@SkillsFragment(job.SkillsUsed)
}
@if (job.Duties is { Count: > 0 })
{
<ul>
@foreach (var duty in job.Duties)
@if (SelectedSkills.Any())
{
<MudIconButton OnClick="@ClearSelectedSkills"
Variant="@Variant.Filled"
Color="@Color.Default"
Size="@Size.Small"
Icon="@Icons.Material.Filled.Clear"
Title="Clear Selection" />
}
</MudStack>
@SkillsFragment(resumeModel.Skills)
}

@if (resumeModel.Jobs is { Count: > 0 })
{
<MudText Typo="@Typo.h5"
Class="mb-3">
Experience
</MudText>
<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))
{
<MudCard>
<MudCardHeader>
<MudStack Spacing="0">
<MudText Typo="@Typo.h5">
@job.Title
</MudText>
<MudText Typo="@Typo.subtitle1">
@job.Company
</MudText>
<MudText Typo="@Typo.body2">
@($"{job.StartDate:MMM yyyy} - {(job.EndDate is null ? "Present" : $"{job.EndDate:MMM yyyy}")}")
</MudText>
</MudStack>
</MudCardHeader>
<MudCardContent>
@if (job.Summary is { Length: > 0 })
{
<MudText Typo="@Typo.body1"
Class="mb-3">
@job.Summary
</MudText>
}
@if (job.SkillsUsed is { Count: > 0 })
{
@SkillsFragment(job.SkillsUsed)
}
@if (job.Duties is { Count: > 0 })
{
<ul>
@foreach (var duty in job.Duties)
{
if (duty.Description is { Length: > 0 })
{
if (duty.Description is { Length: > 0 })
{
<li>
@duty.Description
</li>
}
<li>
@duty.Description
</li>
}
</ul>
}
</MudCardContent>
</MudCard>
}
</MudStack>
}
}
</ul>
}
</MudCardContent>
</MudCard>
}
</MudStack>
}

<style>
Expand Down
16 changes: 8 additions & 8 deletions AboutMe/Wasm/Pages/Resume.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private Color GetSkillColor(Skill skill) =>

private void ClearSelectedSkills() => SelectedSkills.Clear();

private readonly ResumeModel? resumeModel = new()
private readonly ResumeModel resumeModel = new()
{
Name = "Michael Bond",
Email = "[email protected]",
Expand Down Expand Up @@ -297,17 +297,17 @@ private Color GetSkillColor(Skill skill) =>
],
};

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

public required string Email { get; set; }

public required string Summary { get; set; }

public required List<Skill> Skills { get; set; } = [];
public required List<Skill> Skills { get; set; }

public required List<Job> Jobs { get; set; } = [];
public required List<Job> Jobs { get; set; }
}

private struct Skill
Expand All @@ -317,7 +317,7 @@ private struct Skill
public string? Description { get; set; }
}

private class Job
private struct Job
{
public string? Email { get; set; }

Expand All @@ -335,14 +335,14 @@ private class Job

public DateTime? EndDate { get; set; }

public List<Skill> SkillsUsed { get; set; } = [];
public List<Skill> SkillsUsed { get; set; }

public required List<Duty> Duties { get; set; } = [];
public required List<Duty> Duties { get; set; }

public bool PresentlyEmployed { get; set; }
}

private class Duty
private struct Duty
{
public required string Description { get; set; }
}
Expand Down

0 comments on commit e3937ab

Please sign in to comment.