@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorAphrontBarUIExample extends PhabricatorUIExample {
4
5 public function getName() {
6 return pht('Bars');
7 }
8
9 public function getDescription() {
10 return pht('Like fractions, but more horizontal.');
11 }
12
13 public function renderExample() {
14 $out = array();
15 $out[] = $this->renderRainbow();
16 return $out;
17 }
18
19 private function wrap($title, $thing) {
20 $thing = phutil_tag_div('ml grouped', $thing);
21 return id(new PHUIObjectBoxView())
22 ->setHeaderText($title)
23 ->appendChild($thing);
24 }
25
26 private function renderRainbow() {
27 $colors = array(
28 'red',
29 'orange',
30 'yellow',
31 'green',
32 'blue',
33 'indigo',
34 'violet',
35 );
36
37 $labels = array(
38 pht('Empty'),
39 pht('Red'),
40 pht('Orange'),
41 pht('Yellow'),
42 pht('Green'),
43 pht('Blue'),
44 pht('Indigo'),
45 pht('Violet'),
46 );
47
48 $bars = array();
49
50 for ($jj = -1; $jj < count($colors); $jj++) {
51 $bar = id(new PHUISegmentBarView())
52 ->setLabel($labels[$jj + 1]);
53 for ($ii = 0; $ii <= $jj; $ii++) {
54 $bar->newSegment()
55 ->setWidth(1 / 7)
56 ->setColor($colors[$ii]);
57 }
58 $bars[] = $bar;
59 }
60
61 $bars = phutil_implode_html(
62 phutil_tag('br'),
63 $bars);
64
65 return $this->wrap(pht('Rainbow Bars'), $bars);
66 }
67
68}