jenkins-bot has submitted this change and it was merged.
Change subject: Add PHP version of ProgressBarWidget
..
Add PHP version of ProgressBarWidget
Change-Id: Ib434a5c09699c9196be3d477578099267dceec90
---
M build/modules.yaml
M demos/pages/widgets.php
A php/widgets/ProgressBarWidget.php
M src/styles/core.less
M src/styles/widgets.less
5 files changed, 90 insertions(+), 2 deletions(-)
Approvals:
Bartosz DziewoĆski: Looks good to me, but someone else must approve
Jforrester: Looks good to me, approved
Esanders: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/build/modules.yaml b/build/modules.yaml
index 41bf19e..b6fbb54 100644
--- a/build/modules.yaml
+++ b/build/modules.yaml
@@ -64,6 +64,8 @@
# ComboBoxInputWidget
"src/mixins/FloatableElement.js",
"src/widgets/FloatingMenuSelectWidget.js",
+ # ProgressBarWidget
+ "src/widgets/ProgressBarWidget.js",
# The basic widgets and layouts, continued.
"src/widgets/InputWidget.js",
@@ -115,7 +117,6 @@
"src/widgets/CapsuleMultiselectWidget.js",
"src/widgets/SelectFileWidget.js",
- "src/widgets/ProgressBarWidget.js",
"src/widgets/SearchWidget.js",
"src/widgets/NumberInputWidget.js"
],
diff --git a/demos/pages/widgets.php b/demos/pages/widgets.php
index 1950cca..cc23ca1 100644
--- a/demos/pages/widgets.php
+++ b/demos/pages/widgets.php
@@ -981,6 +981,24 @@
'align' => 'top'
]
),
+ new OOUI\FieldLayout(
+ new OOUI\ProgressBarWidget( [
+ 'progress' => 33
+ ] ),
+ [
+ 'label' => 'Progress bar',
+ 'align' => 'top'
+ ]
+ ),
+ new OOUI\FieldLayout(
+ new OOUI\ProgressBarWidget( [
+ 'progress' => false
+ ] ),
+ [
+ 'label' => 'Progress bar (indeterminate)',
+ 'align' => 'top'
+ ]
+ ),
]
] ) );
diff --git a/php/widgets/ProgressBarWidget.php
b/php/widgets/ProgressBarWidget.php
new file mode 100644
index 000..c31ce45
--- /dev/null
+++ b/php/widgets/ProgressBarWidget.php
@@ -0,0 +1,69 @@
+bar = new Tag( 'div' );
+ $this->bar->addClasses( [ 'oo-ui-progressBarWidget-bar' ] );
+
+ $this->setProgress( array_key_exists( 'progress', $config ) ?
$config['progress'] : false );
+
+ $this
+ ->setAttributes( [
+ 'role' => 'progressbar',
+ 'aria-valuemin' => 0,
+ 'aria-valuemax' => 100,
+ ] )
+ ->addClasses( [ 'oo-ui-progressBarWidget' ] )
+ ->appendContent( $this->bar );
+ }
+
+ /**
+* @return bool|int
+*/
+ public function getProgress() {
+ return $this->progress;
+ }
+
+ /**
+* @param bool|int $progress
+*/
+ public function setProgress( $progress ) {
+ $this->progress = $progress;
+
+ if ( $progress !== false ) {
+ $this->bar->setAttributes( [ 'style' => 'width: ' .
$this->progress . '%;' ] );
+ $this->setAttributes( [ 'aria-valuenow' =>
$this->progress ] );
+ } else {
+ $this->removeAttributes( [ 'aria-valuenow' ] );
+ }
+ $this->toggleClasses( [ 'oo-ui-progressBarWidget-indeterminate'
], $progress === false );
+ }
+
+ public function getConfig( &$config ) {
+ if ( $this->progress !== null ) {
+ $config['progress'] = $this->progress;
+ }
+ return parent::getConfig( $config );
+ }
+}
diff --git a/src/styles/core.less b/src/styles/core.less
index d17c3bd..21f86dd 100644
--- a/src/styles/core.less
+++ b/src/styles/core.less
@@ -57,3 +57,4 @@
@import 'widgets/MultioptionWidget.less';
@import 'widgets/CheckboxMultiselectWidget.less';
@import 'widgets/CheckboxMultioptionWidget.less';
+@import 'widgets/ProgressBarWidget.less';
diff --git a/src/styles/widgets.less b/src/styles/widgets.less
index c640331..9275bd6 100644
--- a/src/styles/widgets.less
+++ b/src/styles/widgets.less
@@ -20,7 +20,6 @@
@import 'widgets/ToggleWidget.less';
@import