File
Extends
Implements
Index
Properties
|
|
Inputs
|
|
HostBindings
|
|
Accessors
|
|
Constructor
constructor(_elementRef: ElementRef, _focusMonitor: FocusMonitor)
|
|
Parameters :
Name |
Type |
Optional |
_elementRef |
ElementRef<HTMLElement>
|
No
|
_focusMonitor |
FocusMonitor
|
No
|
|
hideDot
|
Type : boolean
|
Default value : false
|
|
hideLabel
|
Type : boolean
|
Default value : false
|
|
horizontal
|
Type : boolean
|
Default value : false
|
|
isForbidden
|
Type : boolean
|
Default value : false
|
|
state
|
Type : any
|
Default value : StepState.PENDING
|
|
HostBindings
attr.role
|
Type : string
|
Default value : 'tab'
|
|
attr.tabindex
|
Type : string
|
Default value : '-1'
|
|
class.is-interactive
|
Type : boolean
|
|
Public
_elementRef
|
Type : ElementRef<HTMLElement>
|
|
role
|
Type : string
|
Default value : 'tab'
|
Decorators :
@HostBinding('attr.role')
|
|
tabindex
|
Type : string
|
Default value : '-1'
|
Decorators :
@HostBinding('attr.tabindex')
|
|
Accessors
isComplete
|
getisComplete()
|
|
isInteractive
|
getisInteractive()
|
|
import { FocusMonitor } from '@angular/cdk/a11y';
import { CdkStepHeader } from '@angular/cdk/stepper';
import { Component, ElementRef, HostBinding, Input, OnChanges, OnDestroy } from '@angular/core';
import { StepState } from './navigation-step-state';
@Component({
selector: 'frame-navigation-step',
templateUrl: 'navigation-step.component.html',
styleUrls: [`./navigation-step.component.scss`],
standalone: false
})
export class NavigationStepComponent extends CdkStepHeader implements OnDestroy, OnChanges {
@HostBinding('attr.tabindex')
tabindex = '-1';
@HostBinding('attr.role') role = 'tab';
@HostBinding('class.is-horizontal')
@Input()
horizontal = false;
@Input() label?: string;
@Input() state = StepState.PENDING;
@HostBinding('class.no-dot')
@Input()
hideDot = false;
@HostBinding('class.is-unclickable')
@Input()
isForbidden = false;
@Input() hideLabel = false;
constructor(
public override _elementRef: ElementRef<HTMLElement>,
private _focusMonitor: FocusMonitor
) {
super(_elementRef);
this._focusMonitor.monitor(this._elementRef);
}
ngOnChanges() {
this.tabindex = this.state === StepState.CURRENT ? '0' : '-1';
}
ngOnDestroy() {
this._focusMonitor.stopMonitoring(this._elementRef);
}
@HostBinding('class.is-current')
get isCurrent() {
return this.state === StepState.CURRENT;
}
@HostBinding('class.is-complete')
get isComplete() {
return this.state === StepState.COMPLETE;
}
@HostBinding('class.is-interactive')
get isInteractive() {
return this.state === StepState.COMPLETE;
}
@HostBinding('class.is-unknown')
get isUnknown() {
return this.state === StepState.UNKNOWN;
}
@HostBinding('class.is-pending')
get isPending() {
return this.state === StepState.PENDING;
}
}
<div class="dot">
<div class="inner-dot"></div>
<nx-icon class="checkmark" name="check"></nx-icon>
</div>
<span class="sr-only" *ngIf="isComplete">Completed: </span>
<span class="sr-only" *ngIf="isCurrent">Current: </span>
<span class="label" *ngIf="label && !hideLabel">{{ label }}</span>
$dot-size: 8px;
$dot-border-size: 2px;
:host {
display: flex;
position: relative;
align-items: center;
font-size: var(--multi-stepper-step-font-size);
min-height: 20px;
}
:host(.is-horizontal) {
flex: 1;
flex-direction: column;
justify-content: center;
}
:host:focus {
outline: none;
}
:host(.cdk-keyboard-focused) {
.dot {
box-shadow: 0 0 0 2px var(--multi-stepper-dot-checkmark-color),
0 0 0 6px var(--multi-stepper-dot-touched-color);
}
}
.label {
margin-left: 16px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
:host(.is-horizontal) .label {
margin-left: 0;
white-space: initial;
text-align: center;
}
:host(.is-interactive) .dot,
:host(.is-interactive) .label {
cursor: pointer;
}
.dot {
flex-shrink: 0;
border-radius: 50%;
width: 2 * $dot-size;
height: 2 * $dot-size;
border: $dot-border-size solid var(--multi-stepper-dot-touched-color);
position: relative;
font-size: 16px;
}
:host(.no-dot) .dot {
display: none;
}
:host(.is-horizontal) .dot {
margin-bottom: $dot-size;
}
.icon {
font-size: 16px;
}
.inner-dot {
width: $dot-size;
height: $dot-size;
border-radius: 50%;
background-color: var(--multi-stepper-dot-touched-color);
transform: translate($dot-border-size, $dot-border-size);
position: absolute;
display: none;
}
.checkmark {
position: absolute;
transform: translate(-$dot-border-size, -$dot-border-size);
display: none;
}
:host(.is-complete) {
.dot {
background-color: var(--multi-stepper-dot-touched-color);
color: var(--multi-stepper-dot-checkmark-color);
}
.checkmark {
display: block;
}
}
:host(.is-current) {
.dot {
color: var(--multi-stepper-dot-checkmark-color);
}
.inner-dot {
display: block;
}
cursor: pointer;
}
:host(.is-current:not(.is-horizontal)) {
.label {
font-weight: 700;
}
}
:host(.is-unknown) {
.dot {
border-color: var(--multi-stepper-dot-disabled-color);
}
cursor: not-allowed;
}
:host(.is-pending) {
color: var(--multi-stepper-step-disabled-color);
.dot {
border: $dot-border-size solid var(--multi-stepper-dot-disabled-color);
}
cursor: not-allowed;
}
:host(.is-unclickable) {
.dot,
.label {
cursor: not-allowed;
}
cursor: not-allowed;
}
:host(:not(.no-dot):not(.is-horizontal)) {
margin-bottom: 2 * $dot-size + 2 * $dot-border-size;
&:not(:last-child)::before {
content: '';
position: absolute;
top: 3 * $dot-size - $dot-border-size;
left: $dot-size - $dot-border-size;
border-left: calc($dot-size / 2) dotted var(--multi-stepper-line-color);
height: 2 * $dot-size;
}
&.is-complete::before {
border-left-style: solid;
border-left-color: var(--multi-stepper-dot-touched-color);
height: 3 * $dot-size;
margin: (-2 * $dot-border-size) 0;
}
}
:host(:not(.no-dot).is-horizontal) {
&:not(:last-child)::before {
content: '';
position: absolute;
top: $dot-size - $dot-border-size;
left: (3 * $dot-size);
border-top: calc($dot-size / 2) dotted var(--multi-stepper-line-color);
height: 0;
width: calc(100% - #{3 * $dot-size});
transform: translateX(50%);
}
&.is-complete::before {
border-top-style: solid;
border-top-color: var(--multi-stepper-dot-touched-color);
left: (2 * $dot-size);
width: calc(100% - #{2 * $dot-size});
}
}
.sr-only {
width: 1px;
height: 1px;
margin: -1px;
overflow: hidden;
}
Legend
Html element with directive