Skip to content

Commit

Permalink
💄: Update Tag colour to match changes
Browse files Browse the repository at this point in the history
- In [version 5](alphagov/govuk-design-system-backlog#62 (comment)) of the GDS front-end packages, they have changed the tag colours. As a result, our "dark blue" tag no longer existed, so all of our tags were using the default colours.
- Changed tag colour match changes.

:zap: Changed GetSectionSubmissionStatuses to return List

- Improves performance by not having to call `.ToList` on an object that is already a List
  • Loading branch information
jimwashbrook committed Feb 20, 2024
1 parent a01f7a3 commit dba7d5b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public GetSubmissionStatusesQuery(IPlanTechDbContext db, IUser userHelper)

}

public IList<SectionStatusDto> GetSectionSubmissionStatuses(IEnumerable<ISectionComponent> sections)
public List<SectionStatusDto> GetSectionSubmissionStatuses(IEnumerable<ISectionComponent> sections)
{
int establishmentId = _userHelper.GetEstablishmentId().Result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Dfe.PlanTech.Domain.Interfaces;

public interface IGetSubmissionStatusesQuery
{
IList<SectionStatusDto> GetSectionSubmissionStatuses(IEnumerable<ISectionComponent> sections);
List<SectionStatusDto> GetSectionSubmissionStatuses(IEnumerable<ISectionComponent> sections);

Task<SectionStatusNew> GetSectionSubmissionStatusAsync(int establishmentId,
ISectionComponent section,
Expand Down
16 changes: 10 additions & 6 deletions src/Dfe.PlanTech.Web/TagHelpers/TaskList/TagColour.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
namespace Dfe.PlanTech.Web.TagHelpers.TaskList;

public enum TagColour
public static class TagColour
{
Default,
Blue,
Grey,
Red,
DarkBlue,
public readonly static string Default = "blue";
public readonly static string Blue = "blue";
public readonly static string Grey = "grey";
public readonly static string LightBlue = "light-blue";
public readonly static string Red = "red";

private readonly static string[] _colours = [Blue, Grey, LightBlue, Red];

public static string GetMatchingColour(string? toMatch) => string.IsNullOrEmpty(toMatch) ? Default : _colours.FirstOrDefault(colour => colour == toMatch, Default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public TaskListTagTagHelper()
TagName = "strong";
}

protected TagColour TagColour => Enum.TryParse(Colour, true, out TagColour colour) ? colour : TagColour.Default;
protected string TagClassColour => TagColour.GetMatchingColour(Colour);

protected override string CreateClassesAttribute()
{
Expand All @@ -40,13 +40,12 @@ private void AppendExtraClasses(StringBuilder stringBuilder)

private void AppendTagColour(StringBuilder stringBuilder)
{
var tagColour = TagColour;
if (tagColour != TagColour.Default)
if (TagClassColour != TagColour.Default)
{
stringBuilder.Append(' ');
stringBuilder.Append(_class);
stringBuilder.Append("--");
stringBuilder.Append(tagColour.ToString().ToLower());
stringBuilder.Append(TagClassColour);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static void SetCategorySectionDtoTagWithCurrentStatus(Category category,

if (sectionStatusCompleted != null)
{
categorySectionDto.TagColour = sectionStatusCompleted == 1 ? TagColour.DarkBlue.ToString() : TagColour.Blue.ToString();
categorySectionDto.TagColour = sectionStatusCompleted == 1 ? TagColour.Blue : TagColour.LightBlue;
categorySectionDto.TagText = sectionStatusCompleted == 1 ? "COMPLETE" : "IN PROGRESS";
}
else
Expand Down Expand Up @@ -102,7 +102,7 @@ public Category RetrieveSectionStatuses(Category category)
{
try
{
category.SectionStatuses = _query.GetSectionSubmissionStatuses(category.Sections).ToList();
category.SectionStatuses = _query.GetSectionSubmissionStatuses(category.Sections);
category.Completed = category.SectionStatuses.Count(x => x.Completed == 1);
category.RetrievalError = false;
return category;
Expand Down

0 comments on commit dba7d5b

Please sign in to comment.