1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-26 21:49:08 +01:00
phorge-phorge/src/view/phui/PHUISegmentBarView.php
epriestley 86c2f9df2e First cut of progress bars (PHUISegmentBarView)
Summary:
Ref T10288.

I couldn't figure out how to reasonably get the interior right borders to round like the mock, but I think this is otherwise mostly faithful. Feel free to fix stuff.

Test Plan: {F1100415}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10288

Differential Revision: https://secure.phabricator.com/D15219
2016-02-08 15:28:09 -08:00

65 lines
1.2 KiB
PHP

<?php
final class PHUISegmentBarView extends AphrontTagView {
private $label;
private $segments = array();
public function setLabel($label) {
$this->label = $label;
return $this;
}
public function newSegment() {
$segment = new PHUISegmentBarSegmentView();
$this->segments[] = $segment;
return $segment;
}
protected function canAppendChild() {
return false;
}
protected function getTagAttributes() {
return array(
'class' => 'phui-segment-bar-view',
);
}
protected function getTagContent() {
require_celerity_resource('phui-segment-bar-view-css');
$label = $this->label;
if (strlen($label)) {
$label = phutil_tag(
'div',
array(
'class' => 'phui-segment-bar-label',
),
$label);
}
$segments = $this->segments;
$position = 0;
foreach ($segments as $segment) {
$segment->setPosition($position);
$position += $segment->getWidth();
}
$segments = array_reverse($segments);
$segments = phutil_tag(
'div',
array(
'class' => 'phui-segment-bar-segments',
),
$segments);
return array(
$label,
$segments,
);
}
}