diff --git a/src/components/progressbar/ProgressBar.css b/src/components/progressbar/ProgressBar.css index 4d24d14a4a..f9b1d24a82 100644 --- a/src/components/progressbar/ProgressBar.css +++ b/src/components/progressbar/ProgressBar.css @@ -2,26 +2,105 @@ height: 1.2em; text-align: left; position: relative; + overflow: hidden; } -.ui-progressbar .ui-progressbar-value { +.ui-progressbar-determinate .ui-progressbar-value { height: 100%; width: 0%; position: absolute; + display: none; border: 0 none; } -.ui-progressbar .ui-progressbar-value-animate { +.ui-progressbar-determinate .ui-progressbar-value-animate { -webkit-transition: width 1s ease-in-out; -moz-transition: width 1s ease-in-out; -o-transition: width 1s ease-in-out; transition: width 1s ease-in-out; } -.ui-progressbar .ui-progressbar-label { +.ui-progressbar-determinate .ui-progressbar-label { text-align: center; height: 100%; width: 100%; position: absolute; + display: none; font-weight: bold; +} + +.ui-progressbar-indeterminate .ui-progressbar-value { + border: 0 none; +} + +.ui-progressbar-indeterminate .ui-progressbar-value:before { + content: ''; + position: absolute; + background-color: inherit; + top: 0; + left: 0; + bottom: 0; + will-change: left, right; + -webkit-animation: ui-progressbar-indeterminate-anim 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite; + animation: ui-progressbar-indeterminate-anim 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite; +} + +.ui-progressbar-indeterminate .ui-progressbar-value:after { + content: ''; + position: absolute; + background-color: inherit; + top: 0; + left: 0; + bottom: 0; + will-change: left, right; + -webkit-animation: ui-progressbar-indeterminate-anim-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite; + animation: ui-progressbar-indeterminate-anim-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite; + -webkit-animation-delay: 1.15s; + animation-delay: 1.15s; +} + +@-webkit-keyframes ui-progressbar-indeterminate-anim { + 0% { + left: -35%; + right: 100%; } + 60% { + left: 100%; + right: -90%; } + 100% { + left: 100%; + right: -90%; } +} +@keyframes ui-progressbar-indeterminate-anim { + 0% { + left: -35%; + right: 100%; } + 60% { + left: 100%; + right: -90%; } + 100% { + left: 100%; + right: -90%; } +} + +@-webkit-keyframes ui-progressbar-indeterminate-anim-short { + 0% { + left: -200%; + right: 100%; } + 60% { + left: 107%; + right: -8%; } + 100% { + left: 107%; + right: -8%; } +} +@keyframes ui-progressbar-indeterminate-anim-short { + 0% { + left: -200%; + right: 100%; } + 60% { + left: 107%; + right: -8%; } + 100% { + left: 107%; + right: -8%; } } \ No newline at end of file diff --git a/src/components/progressbar/ProgressBar.d.ts b/src/components/progressbar/ProgressBar.d.ts index 3dae61227f..618b78c35d 100644 --- a/src/components/progressbar/ProgressBar.d.ts +++ b/src/components/progressbar/ProgressBar.d.ts @@ -7,6 +7,7 @@ interface ProgressBarProps { unit?: string; style?: object; className?: string; + mode?: string } export class ProgressBar extends React.Component {} \ No newline at end of file diff --git a/src/components/progressbar/ProgressBar.js b/src/components/progressbar/ProgressBar.js index 3705e0931d..f21e111a84 100644 --- a/src/components/progressbar/ProgressBar.js +++ b/src/components/progressbar/ProgressBar.js @@ -10,7 +10,8 @@ export class ProgressBar extends Component { showValue: true, unit: '%', style: null, - className: null + className: null, + mode: 'determinate' } static propTypes = { @@ -20,17 +21,18 @@ export class ProgressBar extends Component { unit: PropTypes.string, style: PropTypes.object, className: PropTypes.string, + mode: PropTypes.string }; render() { - var className = classNames('ui-progressbar ui-widget ui-widget-content ui-corner-all', this.props.className); + var className = classNames('ui-progressbar ui-widget ui-widget-content ui-corner-all', this.props.className, {'ui-progressbar-determinate': (this.props.mode === 'determinate'), 'ui-progressbar-indeterminate': (this.props.mode === 'indeterminate')}); if(this.props.showValue) { var label =
{this.props.value + this.props.unit}
; } return (
-
+
{label}
); diff --git a/src/showcase/progressbar/ProgressBarDemo.js b/src/showcase/progressbar/ProgressBarDemo.js index 146a8f9931..f88eb68742 100644 --- a/src/showcase/progressbar/ProgressBarDemo.js +++ b/src/showcase/progressbar/ProgressBarDemo.js @@ -49,6 +49,9 @@ export class ProgressBarDemo extends Component {

Static

+ +

Indeterminate

+ @@ -76,14 +79,20 @@ import {ProgressBar} from 'primereact/components/progressbar/ProgressBar';

Getting Started

-

ProgressBar requires a value between 0 and 100 to display the progress.

+

ProgressBar has two modes; "determinate" and "indeterminate". ProgressBar requires a value between 0 and 100 to display the progress.

{` `} +

Indeterminate has no such a requirement and is simple enabled using mode property.

+ + {` + +`} + {` constructor() { @@ -155,6 +164,12 @@ componentDidMount() { null Style class of the element. + + mode + string + determinate + Defines the mode of the progress, valid values are "determinate" and "indeterminate". + @@ -174,6 +189,14 @@ componentDidMount() { ui-progressbar Container element. + + ui-progressbar-determinate + Container element of a determinate progressbar. + + + ui-progressbar-indeterminate + Container element of an indeterminate progressbar. + ui-progressbar-value Element whose width changes according to value. @@ -236,6 +259,9 @@ export class ProgressBarDemo extends Component {

Static

+ +

Indeterminate

+