78 lines
2.4 KiB
Plaintext
78 lines
2.4 KiB
Plaintext
@model OnboardingJourneyHeaderViewModel
|
|
@{
|
|
var characterReviewStepCount = Math.Max(1, Model.TotalSteps - 9);
|
|
var steps = Model.TotalSteps <= 10
|
|
? BuildDefaultSteps()
|
|
: BuildDynamicSteps(characterReviewStepCount, Model.TotalSteps);
|
|
var progressWidth = Model.TotalSteps <= 1
|
|
? 100
|
|
: ((Math.Clamp(Model.CurrentStep, 1, Model.TotalSteps) - 1) * 100) / (Model.TotalSteps - 1);
|
|
}
|
|
|
|
<div class="onboarding-progress" aria-label="@Model.AriaLabel">
|
|
<span>Step @Model.CurrentStep of @Model.TotalSteps</span>
|
|
<div class="onboarding-progress-track">
|
|
<span style="width:@progressWidth%"></span>
|
|
</div>
|
|
</div>
|
|
<ol class="onboarding-stepper" style="--onboarding-step-count:@steps.Count" aria-label="Manuscript import journey">
|
|
@foreach (var step in steps)
|
|
{
|
|
<li class="@StepClass(step.Order, Model.CurrentStep)">
|
|
<span>@step.Order</span>
|
|
<strong>@step.Label</strong>
|
|
</li>
|
|
}
|
|
</ol>
|
|
|
|
@functions {
|
|
private sealed record HeaderStep(string Label, int Order);
|
|
|
|
private static IReadOnlyList<HeaderStep> BuildDefaultSteps() =>
|
|
[
|
|
new("Welcome", 1),
|
|
new("Writing Stage", 2),
|
|
new("Writing Software", 3),
|
|
new("Project", 4),
|
|
new("Book", 5),
|
|
new("Connect Word", 6),
|
|
new("Review Chapters", 7),
|
|
new("Review Characters", 8),
|
|
new("Analyse Manuscript", 9),
|
|
new("Complete", 10)
|
|
];
|
|
|
|
private static IReadOnlyList<HeaderStep> BuildDynamicSteps(int characterReviewStepCount, int totalSteps)
|
|
{
|
|
var steps = new List<HeaderStep>
|
|
{
|
|
new("Welcome", 1),
|
|
new("Writing Stage", 2),
|
|
new("Writing Software", 3),
|
|
new("Project", 4),
|
|
new("Book", 5),
|
|
new("Connect Word", 6),
|
|
new("Review Chapters", 7)
|
|
};
|
|
|
|
for (var index = 1; index <= characterReviewStepCount; index++)
|
|
{
|
|
steps.Add(new HeaderStep($"Characters {index}", 7 + index));
|
|
}
|
|
|
|
steps.Add(new HeaderStep("Analyse Manuscript", totalSteps - 1));
|
|
steps.Add(new HeaderStep("Complete", totalSteps));
|
|
return steps;
|
|
}
|
|
|
|
private static string StepClass(int order, int currentStep)
|
|
{
|
|
if (order < currentStep)
|
|
{
|
|
return "is-complete";
|
|
}
|
|
|
|
return order == currentStep ? "is-current" : "is-upcoming";
|
|
}
|
|
}
|