Skip to content

Commit 287480c

Browse files
authored
Merge pull request #515 from youda97/progress-indicator-feat
feat(progress-indicator): Add disabled, error and tooltip to steps
2 parents 1a03b01 + 7c09773 commit 287480c

File tree

5 files changed

+88
-34
lines changed

5 files changed

+88
-34
lines changed

src/dialog/dialog-config.interface.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ export interface DialogConfig {
77
/**
88
* Title for the `Dialog` header.
99
*/
10-
title: string;
10+
title?: string;
1111
/**
1212
* Body content for the `Dialog`.
1313
*/
1414
content: string | TemplateRef<any>;
1515
/**
1616
* Parameter for triggering `Dialog` display.
1717
*/
18-
trigger: "click" | "hover" | "mouseenter";
18+
trigger?: "click" | "hover" | "mouseenter";
1919
/**
2020
* Parameter for triggering the `Dialog` close event.
2121
*/
@@ -24,23 +24,23 @@ export interface DialogConfig {
2424
* Parameter defining the placement in which the `Dialog` appears.
2525
* @type {Placement}
2626
*/
27-
placement: string;
27+
placement?: string;
2828
/**
2929
* Used to set the offset of the `Dialog` relative to the content it
3030
* is associated to.
3131
*/
32-
gap: number;
32+
gap?: number;
3333
/**
3434
* Reference to the Parent element that links the `Dialog`.
3535
*/
36-
parentRef: ElementRef;
36+
parentRef?: ElementRef;
3737
/**
3838
* Set to `true` to open the dialog next to the triggering component
3939
*/
40-
appendInline: boolean;
40+
appendInline?: boolean;
4141
/**
4242
* Config object passed to the rendered component. (Optional)
4343
*/
44-
data: Object;
44+
data?: Object;
4545
[propName: string]: any;
4646
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { TemplateRef } from "@angular/core";
2+
import { DialogConfig } from "./../dialog/dialog-config.interface";
3+
4+
export interface Step {
5+
/**
6+
* The label of the `step`
7+
*/
8+
text: string;
9+
/**
10+
* An array of strings to determine the progress of the step
11+
*/
12+
state: Array<string>;
13+
/**
14+
* Defines the tooltip
15+
*/
16+
tooltip?: DialogConfig;
17+
/**
18+
* Determines whether the step is disabled or not
19+
*/
20+
disabled?: boolean;
21+
}

src/progress-indicator/progress-indicator.component.ts

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, Input } from "@angular/core";
22
import { ExperimentalService } from "./../experimental.module";
3+
import { Step } from "./progress-indicator-step.interface";
34

45
/**
56
* [See demo](../../?path=/story/progress-indicator--basic)
@@ -21,21 +22,37 @@ import { ExperimentalService } from "./../experimental.module";
2122
'bx--progress--vertical': (orientation === 'vertical')
2223
}">
2324
<li
24-
class="bx--progress-step bx--progress-step--{{step.state}}"
25-
*ngFor="let step of steps; let i = index">
26-
<ibm-icon-checkmark-outline16 *ngIf="step.state == 'complete'"></ibm-icon-checkmark-outline16>
27-
<svg *ngIf="step.state == 'current'">
28-
<path *ngIf="isExperimental" d="M 7, 7 m -7, 0 a 7,7 0 1,0 14,0 a 7,7 0 1,0 -14,0" ></path>
29-
</svg>
30-
<svg *ngIf="step.state == 'incomplete'">
31-
<path
32-
*ngIf="isExperimental"
33-
d="M8 1C4.1 1 1 4.1 1 8s3.1 7 7 7 7-3.1 7-7-3.1-7-7-7zm0 13c-3.3 0-6-2.7-6-6s2.7-6 6-6 6 2.7 6 6-2.7 6-6 6z">
34-
</path>
35-
</svg>
36-
<ibm-icon-error-outline16 *ngIf="step.state == 'error'"></ibm-icon-error-outline16>
37-
<p class="bx--progress-label">{{step.text}}</p>
38-
<span class="bx--progress-line"></span>
25+
class="bx--progress-step bx--progress-step--{{step.state[0]}}"
26+
*ngFor="let step of steps"
27+
[ngClass]="{'bx--progress-step--disabled' : step.disabled}">
28+
<div class="bx--progress-step-button bx--progress-step-button--unclickable" role="button" tabindex="-1">
29+
<ibm-icon-checkmark-outline16 *ngIf="step.state == 'complete'"></ibm-icon-checkmark-outline16>
30+
<svg *ngIf="step.state == 'current'">
31+
<path *ngIf="isExperimental" d="M 7, 7 m -7, 0 a 7,7 0 1,0 14,0 a 7,7 0 1,0 -14,0" ></path>
32+
</svg>
33+
<svg *ngIf="step.state == 'incomplete'">
34+
<path
35+
*ngIf="isExperimental"
36+
d="M8 1C4.1 1 1 4.1 1 8s3.1 7 7 7 7-3.1 7-7-3.1-7-7-7zm0 13c-3.3 0-6-2.7-6-6s2.7-6 6-6 6 2.7 6 6-2.7 6-6 6z">
37+
</path>
38+
</svg>
39+
<ibm-icon-warning16 *ngIf="step.state.includes('error')" innerClass="bx--progress__warning"></ibm-icon-warning16>
40+
<p
41+
class="bx--progress-label"
42+
*ngIf="step.tooltip"
43+
[ibmTooltip]="step.tooltip.content"
44+
[trigger]="step.tooltip.trigger"
45+
[placement]="step.tooltip.placement"
46+
[title]="step.tooltip.title"
47+
[gap]="step.tooltip.gap"
48+
[appendInline]="step.tooltip.appendInline"
49+
[data]="step.tooltip.data">
50+
{{step.text}}
51+
</p>
52+
<p class="bx--progress-label" *ngIf="!step.tooltip">{{step.text}}</p>
53+
<p *ngIf="step.optionalText" class="bx--progress-optional">{{step.optionalText}}</p>
54+
<span class="bx--progress-line"></span>
55+
</div>
3956
</li>
4057
</ul>
4158
`
@@ -50,12 +67,12 @@ export class ProgressIndicator {
5067
return steps;
5168
}
5269

53-
@Input() steps = [];
70+
@Input() steps: Array<Step>;
5471
@Input() orientation: "horizontal" | "vertical" = "horizontal";
5572
@Input() skeleton = false;
5673

5774
@Input() get current() {
58-
return this.steps.indexOf(step => step.state[0] === "current");
75+
return this.steps.findIndex(step => step.state.includes("current"));
5976
}
6077
set current(current: number) {
6178
if (current === undefined || current < 0) {

src/progress-indicator/progress-indicator.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { NgModule } from "@angular/core";
22
import { CommonModule } from "@angular/common";
33
import { CheckmarkOutline16Module } from "@carbon/icons-angular/lib/checkmark--outline/16";
4-
import { ErrorOutline16Module } from "@carbon/icons-angular/lib/error--outline/16";
4+
import { Warning16Module } from "@carbon/icons-angular/lib/warning/16";
55

66
import { ProgressIndicator } from "./progress-indicator.component";
7+
import { DialogModule } from "./../dialog/dialog.module";
78
import { ExperimentalModule } from "./../experimental.module";
89

910
export { ProgressIndicator } from "./progress-indicator.component";
@@ -17,9 +18,10 @@ export { ProgressIndicator } from "./progress-indicator.component";
1718
],
1819
imports: [
1920
CommonModule,
21+
DialogModule,
2022
ExperimentalModule,
2123
CheckmarkOutline16Module,
22-
ErrorOutline16Module
24+
Warning16Module
2325
]
2426
})
2527
export class ProgressIndicatorModule { }

src/progress-indicator/progress-indicator.stories.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { storiesOf, moduleMetadata } from "@storybook/angular";
77
import { action } from "@storybook/addon-actions";
88
import { withKnobs, number, object } from "@storybook/addon-knobs/angular";
99

10-
import { ProgressIndicatorModule, DocumentationModule } from "../";
10+
import { ProgressIndicatorModule, PlaceholderModule, DocumentationModule } from "../";
1111
import { ProgressIndicator } from "./progress-indicator.component";
1212

1313
@Component({
@@ -33,6 +33,7 @@ storiesOf("Progress Indicator", module)
3333
declarations: [SkeletonStory],
3434
imports: [
3535
ProgressIndicatorModule,
36+
PlaceholderModule,
3637
DocumentationModule
3738
]
3839
})
@@ -42,29 +43,41 @@ storiesOf("Progress Indicator", module)
4243
template: `
4344
<div style="display: flex;">
4445
<ibm-progress-indicator [steps]="steps" [current]="current"></ibm-progress-indicator>
46+
<ibm-placeholder></ibm-placeholder>
4547
</div>
4648
`,
4749
props: {
4850
steps : [
4951
{
5052
text: "First step",
51-
state: ["complete"]
53+
state: ["complete"],
54+
optionalText: "optional"
5255
},
5356
{
5457
text: "Second step",
55-
state: ["current"]
58+
state: ["current"],
59+
tooltip: { content: "Overflow tooltip content.", trigger: "click", placement: "bottom" }
5660
},
5761
{
5862
text: "Third step",
59-
state: ["incomplete"]
63+
state: ["incomplete"],
64+
tooltip: {
65+
content: `Lorem ipsum dolor, sit amet consectetur adipisicing elit.
66+
Animi consequuntur hic ratione aliquid cupiditate, nesciunt saepe iste
67+
blanditiis cumque maxime tenetur veniam est illo deserunt sint quae pariatur.
68+
Laboriosam, consequatur.`,
69+
trigger: "click",
70+
placement: "bottom"
71+
}
6072
},
6173
{
6274
text: "Fourth step",
63-
state: ["incomplete"]
75+
state: ["incomplete", "error"]
6476
},
6577
{
6678
text: "Fifth step",
67-
state: ["incomplete"]
79+
state: ["incomplete"],
80+
disabled: true
6881
}
6982
],
7083
current: number("Current progress", 1)
@@ -90,11 +103,12 @@ storiesOf("Progress Indicator", module)
90103
},
91104
{
92105
text: "Fourth step",
93-
state: ["incomplete"]
106+
state: ["incomplete", "error"]
94107
},
95108
{
96109
text: "Fifth step",
97-
state: ["incomplete"]
110+
state: ["incomplete"],
111+
disabled: true
98112
}
99113
],
100114
current: number("Current progress", 1)

0 commit comments

Comments
 (0)