substep: add substep-active class (#741)

This commit is contained in:
Oliver Sanders
2019-09-11 12:42:24 +01:00
committed by Henrik Ingo
parent 2826aecde7
commit 934c2266c4
3 changed files with 35 additions and 0 deletions

View File

@@ -29,6 +29,12 @@ Example:
<p class="substep">Apple</p>
</div>
Classes:
`substep-active` - The most recent substep in the current step
`substep-visible` - The most recent and all previous substeps in the current step
Author
------

View File

@@ -69,8 +69,12 @@
var showSubstep = function( substeps, visible ) {
if ( visible.length < substeps.length ) {
for ( var i = 0; i < substeps.length; i++ ) {
substeps[ i ].classList.remove( "substep-active" );
}
var el = substeps[ visible.length ];
el.classList.add( "substep-visible" );
el.classList.add( "substep-active" );
return el;
}
};
@@ -85,6 +89,16 @@
var hideSubstep = function( visible ) {
if ( visible.length > 0 ) {
var current = -1;
for ( var i = 0; i < visible.length; i++ ) {
if ( visible[ i ].classList.contains( "substep-active" ) ) {
current = i;
}
visible[ i ].classList.remove( "substep-active" );
}
if ( current > 0 ) {
visible[ current - 1 ].classList.add( "substep-active" );
}
var el = visible[ visible.length - 1 ];
el.classList.remove( "substep-visible" );
return el;