Skip to content
This repository was archived by the owner on Aug 7, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/oui-angular/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import "@oui-angular/oui-page-header/src";
import "@oui-angular/oui-tile/src";
import "@oui-angular/oui-guide-menu/src";
import "@oui-angular/oui-header-tabs/src";
import "@oui-angular/oui-progress/src";

angular.module("oui", [
"oui.button",
Expand Down Expand Up @@ -71,5 +72,6 @@ angular.module("oui", [
"oui.page-header",
"oui.tile",
"oui.guide-menu",
"oui.header-tabs"
"oui.header-tabs",
"oui.progress"
]);
1 change: 1 addition & 0 deletions packages/oui-angular/src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ loadTests(require.context("../../oui-page-header/src/", true, /.*((\.spec)|(inde
loadTests(require.context("../../oui-tile/src/", true, /.*((\.spec)|(index))$/));
loadTests(require.context("../../oui-guide-menu/src/", true, /.*((\.spec)|(index))$/));
loadTests(require.context("../../oui-header-tabs/src/", true, /.*((\.spec)|(index))$/));
loadTests(require.context("../../oui-progress/src/", true, /.*((\.spec)|(index))$/));

function loadTests (context) {
context.keys().forEach(context);
Expand Down
134 changes: 134 additions & 0 deletions packages/oui-progress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# oui-progress

<component-status cx-design="complete" ux="rc"></component-status>

## Usage

### Simple

```html:preview
<oui-progress>
<oui-progress-bar type="info" value="$ctrl.progressData.value1"></oui-progress-bar>
</oui-progress>

<oui-progress>
<oui-progress-bar type="success" value="$ctrl.progressData.value2"></oui-progress-bar>
</oui-progress>

<oui-progress>
<oui-progress-bar type="warning" value="$ctrl.progressData.value3"></oui-progress-bar>
</oui-progress>

<oui-progress>
<oui-progress-bar type="error" value="$ctrl.progressData.value4"></oui-progress-bar>
</oui-progress>
```

### With custom labels

```html:preview
<oui-progress>
<oui-progress-bar type="info"
value="$ctrl.progressData.value1"
text="Progress: {{$ctrl.progressData.value1}}%">
</oui-progress-bar>
</oui-progress>
```

### Custom max value

```html:preview
<oui-progress max-value="200">
<oui-progress-bar type="success"
value="150"
text="Installing components: 150/200">
</oui-progress-bar>
</oui-progress>
```

### Stacked

```html:preview
<oui-progress>
<oui-progress-bar type="success" value="30"></oui-progress-bar>
<oui-progress-bar type="error" value="15"></oui-progress-bar>
</oui-progress>
```

### Thresholds

```html:preview
<oui-progress max-value="200">
<oui-progress-bar type="success"
value="139"
text="Installing components: 139/200">
</oui-progress-bar>
<oui-progress-threshold value="25"></oui-progress-threshold>
<oui-progress-threshold value="50"></oui-progress-threshold>
<oui-progress-threshold value="75"></oui-progress-threshold>
<oui-progress-threshold value="100"></oui-progress-threshold>
<oui-progress-threshold value="125"></oui-progress-threshold>
<oui-progress-threshold value="150"></oui-progress-threshold>
<oui-progress-threshold value="175"></oui-progress-threshold>
</oui-progress>

<oui-progress>
<oui-progress-bar type="error" value="60"></oui-progress-bar>
<oui-progress-threshold value="20"></oui-progress-threshold>
<oui-progress-threshold value="50"></oui-progress-threshold>
<oui-progress-threshold value="80"></oui-progress-threshold>
</oui-progress>
```

### Compact mode

```html:preview
<oui-progress compact>
<oui-progress-bar type="info"
value="$ctrl.progressData.value1"
text="{{$ctrl.progressData.value1}}% complete">
</oui-progress-bar>
</oui-progress>

<oui-progress compact>
<oui-progress-bar type="success"
value="$ctrl.progressData.value2">
</oui-progress-bar>
</oui-progress>

<oui-progress compact>
<oui-progress-bar type="warning"
value="$ctrl.progressData.value3">
</oui-progress-bar>
</oui-progress>

<oui-progress compact>
<oui-progress-bar type="error"
value="$ctrl.progressData.value4"
text="{{$ctrl.progressData.value4}}% complete">
</oui-progress-bar>
</oui-progress>
```

## API

### oui-progress

| Attribute | Type | Binding | One-time binding | Values | default | Description
| ---- | ---- | ---- | ---- | ---- | ---- | ----
| compact | Boolean | <? | yes | | false | compact mode flag
| min-value | Number | @? | yes | | 0 | min value of progress component
| max-value | Number | @? | yes | | 100 | max value of progress component

### oui-progress-bar
| Attribute | Type | Binding | One-time binding | Values | default | Description
| ---- | ---- | ---- | ---- | ---- | ---- | ----
| type | String | @ | yes | `info`, `success`, `warning`, `error` | `info` | type of the progress bar
| value | Number | < | no | | | current value of progress bar
| text | String | @? | yes | | value% | text of progress bar. If undefined, the current value is display as a percentage.

### oui-progress-threshold

| Attribute | Type | Binding | One-time binding | Values | default | Description
| ---- | ---- | ---- | ---- | ---- | ---- | ----
| value | Number | < | yes | | | value at which the threshold should appear
15 changes: 15 additions & 0 deletions packages/oui-progress/src/bar/progress-bar.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import controller from "./progress-bar.controller";
import template from "./progress-bar.html";

export default {
template,
controller,
bindings: {
type: "@",
value: "<",
text: "@?"
},
require: {
progressCtrl: "^^ouiProgress"
}
};
55 changes: 55 additions & 0 deletions packages/oui-progress/src/bar/progress-bar.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { addDefaultParameter } from "@oui-angular/common/component-utils";
import get from "lodash/get";
export default class {
constructor ($attrs, $element, $timeout) {
"ngInject";

this.$attrs = $attrs;
this.$element = $element;
this.$timeout = $timeout;
}

$onInit () {
addDefaultParameter(this, "type", "info");

this.compact = this.progressCtrl.compact;
this.minValue = this.progressCtrl.minValue;
this.maxValue = this.progressCtrl.maxValue;
}

$onChanges (changes) {
const value = get(changes, "value.currentValue");

this.$timeout(() => {
this.$element
.attr("ariaValuenow", value);

if (!this.compact) {
this.$element
.css("width", this.progressCtrl.getPercentageValue(value));
}
});
}

$postLink () {
this.$timeout(() => {
this.$element
.addClass("oui-progress__bar")
.addClass(`oui-progress__bar_${this.type}`)
.attr("ariaValuenow", this.value)
.attr("ariaValuemin", this.minValue)
.attr("ariaValuemax", this.maxValue)
.attr("role", "progressbar");

if (this.text) {
this.$element
.attr("ariaValuetext", this.text);
}

if (!this.compact) {
this.$element
.css("width", this.progressCtrl.getPercentageValue(this.value));
}
});
}
}
3 changes: 3 additions & 0 deletions packages/oui-progress/src/bar/progress-bar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<span class="oui-progress__label"
ng-bind="!!$ctrl.text ? $ctrl.text : ($ctrl.value + '%')">
</span>
8 changes: 8 additions & 0 deletions packages/oui-progress/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Progress from "./progress.component.js";
import ProgressBar from "./bar/progress-bar.component.js";
import ProgressThreshold from "./threshold/progress-threshold.component.js";

angular.module("oui.progress", [])
.component("ouiProgress", Progress)
.component("ouiProgressBar", ProgressBar)
.component("ouiProgressThreshold", ProgressThreshold);
Loading