Skip to content

Commit 9ee9681

Browse files
earshinovmadoar
authored andcommitted
For completion steps, prioritize .done CSS class over .current (#223)
* For completion steps, prioritize .done CSS over .current Normal steps are unaffected See #221 (comment) * Another take: apply the 'completed' CSS class to completion steps only
1 parent 4eac379 commit 9ee9681

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

src/css/wizard-navigation-bar.scss

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ $wz-param-indicator-color: null !global;
149149
$wz-param-indicator-color: $wz-color-optional !global;
150150
@content;
151151
}
152-
&.done .step-indicator,
153-
&.completed .step-indicator {
152+
&.done .step-indicator {
154153
$wz-param-indicator-state: 'default' !global;
155154
$wz-param-indicator-color: $wz-color-done !global;
156155
@content;
@@ -165,6 +164,13 @@ $wz-param-indicator-color: null !global;
165164
$wz-param-indicator-color: $wz-color-editing !global;
166165
@content;
167166
}
167+
// 'completed' class takes priority
168+
// https://github.com/madoar/angular-archwizard/pull/221
169+
&.completed .step-indicator {
170+
$wz-param-indicator-state: 'default' !global;
171+
$wz-param-indicator-color: $wz-color-done !global;
172+
@content;
173+
}
168174

169175
&.navigable a:hover .step-indicator {
170176
$wz-param-indicator-state: 'hover' !global;
@@ -177,24 +183,27 @@ $wz-param-indicator-color: null !global;
177183
$wz-param-indicator-color: $wz-color-optional !global;
178184
@content;
179185
}
180-
&.navigable.done, &.navigable.completed {
181-
a:hover .step-indicator {
182-
$wz-param-indicator-state: 'hover' !global;
183-
$wz-param-indicator-color: $wz-color-done !global;
184-
@content;
185-
}
186+
&.navigable.done a:hover .step-indicator {
187+
$wz-param-indicator-state: 'hover' !global;
188+
$wz-param-indicator-color: $wz-color-done !global;
189+
@content;
186190
}
187191
&.navigable.current a:hover .step-indicator {
188192
$wz-param-indicator-state: 'hover' !global;
189193
$wz-param-indicator-color: $wz-color-current !global;
190194
@content;
191195
}
192-
&.navigable.editing {
193-
a:hover .step-indicator {
194-
$wz-param-indicator-state: 'hover' !global;
195-
$wz-param-indicator-color: $wz-color-editing !global;
196-
@content;
197-
}
196+
&.navigable.editing a:hover .step-indicator {
197+
$wz-param-indicator-state: 'hover' !global;
198+
$wz-param-indicator-color: $wz-color-editing !global;
199+
@content;
200+
}
201+
// 'completed' class takes priority
202+
// https://github.com/madoar/angular-archwizard/pull/221
203+
&.navigable.completed a:hover .step-indicator {
204+
$wz-param-indicator-state: 'hover' !global;
205+
$wz-param-indicator-color: $wz-color-done !global;
206+
@content;
198207
}
199208
}
200209
}

src/lib/components/wizard-navigation-bar.component.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ describe('WizardNavigationBarComponent', () => {
320320
expect(navigableLiEls[0]).toBe(allLiELs[0]);
321321
}));
322322

323-
it('should mark all steps completed after visiting the completion step', fakeAsync(() => {
323+
it('should mark completion steps completed after visiting the completion step', fakeAsync(() => {
324324
const navBarEl = wizardTestFixture.debugElement.query(By.css('aw-wizard-navigation-bar'));
325325

326326
// go to third step, by jumping over the optional step
@@ -333,10 +333,11 @@ describe('WizardNavigationBarComponent', () => {
333333
tick();
334334
wizardTestFixture.detectChanges();
335335

336-
const allLiELs = navBarEl.queryAll(By.css('li'));
337-
const completedLiEls = navBarEl.queryAll(By.css('li.completed'));
338-
339-
expect(completedLiEls.length).toBe(allLiELs.length);
336+
const allLiEls = navBarEl.queryAll(By.css('li'));
337+
expect(allLiEls[0].classes['completed']).toBeFalsy('Only completion step should be marked completed');
338+
expect(allLiEls[1].classes['completed']).toBeFalsy('Only completion step should be marked completed');
339+
expect(allLiEls[2].classes['completed']).toBeFalsy('Only completion step should be marked completed');
340+
expect(allLiEls[3].classes['completed']).toBeTruthy('Completion step should be marked completed');
340341
}));
341342

342343
it('should disable navigation through the navigation bar correctly', fakeAsync(() => {

src/lib/components/wizard-navigation-bar.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, Input} from '@angular/core';
2-
import {NavigationMode} from '../navigation/navigation-mode.interface';
2+
import {WizardCompletionStep} from '../util/wizard-completion-step.interface';
33
import {WizardStep} from '../util/wizard-step.interface';
44
import {WizardComponent} from './wizard.component';
55

@@ -101,13 +101,15 @@ export class WizardNavigationBarComponent {
101101
}
102102

103103
/**
104-
* Checks, whether a [[WizardStep]] can be marked as `completed` in the navigation bar
104+
* Checks, whether a [[WizardStep]] can be marked as `completed` in the navigation bar.
105+
*
106+
* The `completed` class is only applied to completion steps.
105107
*
106108
* @param wizardStep The wizard step to be checked
107109
* @returns True if the step can be marked as `completed`
108110
*/
109111
public isCompleted(wizardStep: WizardStep): boolean {
110-
return this.wizard.completed;
112+
return wizardStep instanceof WizardCompletionStep && this.wizard.completed;
111113
}
112114

113115
/**

0 commit comments

Comments
 (0)