@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

PHUIBadgeMiniView

Summary: Mini teeny little badges. With Timeline integration.

Test Plan:
Made some, UIExamples.

{F603564}

{F603565}

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13620

+218 -19
+5 -5
resources/celerity/map.php
··· 7 7 */ 8 8 return array( 9 9 'names' => array( 10 - 'core.pkg.css' => '71fa60fc', 10 + 'core.pkg.css' => '1716a671', 11 11 'core.pkg.js' => 'a590b451', 12 12 'darkconsole.pkg.js' => 'e7393ebb', 13 13 'differential.pkg.css' => '9451634c', ··· 126 126 'rsrc/css/phui/calendar/phui-calendar.css' => 'ccabe893', 127 127 'rsrc/css/phui/phui-action-list.css' => 'c5eba19d', 128 128 'rsrc/css/phui/phui-action-panel.css' => '3ee9afd5', 129 - 'rsrc/css/phui/phui-badge.css' => 'd6603d7f', 129 + 'rsrc/css/phui/phui-badge.css' => '9be0c352', 130 130 'rsrc/css/phui/phui-box.css' => 'a5bb366d', 131 131 'rsrc/css/phui/phui-button.css' => 'cf529a01', 132 132 'rsrc/css/phui/phui-crumbs-view.css' => 'd842f867', ··· 151 151 'rsrc/css/phui/phui-status.css' => '888cedb8', 152 152 'rsrc/css/phui/phui-tag-view.css' => '402691cc', 153 153 'rsrc/css/phui/phui-text.css' => 'cf019f54', 154 - 'rsrc/css/phui/phui-timeline-view.css' => '47b18876', 154 + 'rsrc/css/phui/phui-timeline-view.css' => 'fc23e7b7', 155 155 'rsrc/css/phui/phui-workboard-view.css' => '935b19d6', 156 156 'rsrc/css/phui/phui-workpanel-view.css' => '00558537', 157 157 'rsrc/css/sprite-login.css' => '1365fee0', ··· 775 775 'phrequent-css' => 'ffc185ad', 776 776 'phriction-document-css' => 'd1861e06', 777 777 'phui-action-panel-css' => '3ee9afd5', 778 - 'phui-badge-view-css' => 'd6603d7f', 778 + 'phui-badge-view-css' => '9be0c352', 779 779 'phui-box-css' => 'a5bb366d', 780 780 'phui-button-css' => 'cf529a01', 781 781 'phui-calendar-css' => 'ccabe893', ··· 807 807 'phui-tag-view-css' => '402691cc', 808 808 'phui-text-css' => 'cf019f54', 809 809 'phui-theme-css' => '6b451f24', 810 - 'phui-timeline-view-css' => '47b18876', 810 + 'phui-timeline-view-css' => 'fc23e7b7', 811 811 'phui-workboard-view-css' => '935b19d6', 812 812 'phui-workpanel-view-css' => '00558537', 813 813 'phuix-action-list-view' => 'b5c256b8',
+2
src/__phutil_library_map__.php
··· 1288 1288 'PHUIActionPanelView' => 'view/phui/PHUIActionPanelView.php', 1289 1289 'PHUIBadgeBoxView' => 'view/phui/PHUIBadgeBoxView.php', 1290 1290 'PHUIBadgeExample' => 'applications/uiexample/examples/PHUIBadgeExample.php', 1291 + 'PHUIBadgeMiniView' => 'view/phui/PHUIBadgeMiniView.php', 1291 1292 'PHUIBadgeView' => 'view/phui/PHUIBadgeView.php', 1292 1293 'PHUIBoxExample' => 'applications/uiexample/examples/PHUIBoxExample.php', 1293 1294 'PHUIBoxView' => 'view/phui/PHUIBoxView.php', ··· 4937 4938 'PHUIActionPanelView' => 'AphrontTagView', 4938 4939 'PHUIBadgeBoxView' => 'AphrontTagView', 4939 4940 'PHUIBadgeExample' => 'PhabricatorUIExample', 4941 + 'PHUIBadgeMiniView' => 'AphrontTagView', 4940 4942 'PHUIBadgeView' => 'AphrontTagView', 4941 4943 'PHUIBoxExample' => 'PhabricatorUIExample', 4942 4944 'PHUIBoxView' => 'AphrontTagView',
+38 -1
src/applications/uiexample/examples/PHUIBadgeExample.php
··· 113 113 ->addByline(pht('Dec 31, 1969')) 114 114 ->addByline('1 Awarded (0.4%)'); 115 115 116 + $badges3 = array(); 117 + $badges3[] = id(new PHUIBadgeMiniView()) 118 + ->setIcon('fa-book') 119 + ->setHeader(pht('Documenter')); 120 + 121 + $badges3[] = id(new PHUIBadgeMiniView()) 122 + ->setIcon('fa-star') 123 + ->setHeader(pht('Contributor')); 124 + 125 + $badges3[] = id(new PHUIBadgeMiniView()) 126 + ->setIcon('fa-bug') 127 + ->setHeader(pht('Bugmeister')); 128 + 129 + $badges3[] = id(new PHUIBadgeMiniView()) 130 + ->setIcon('fa-heart') 131 + ->setHeader(pht('Funder')) 132 + ->setQuality(PHUIBadgeView::UNCOMMON); 133 + 134 + $badges3[] = id(new PHUIBadgeMiniView()) 135 + ->setIcon('fa-user') 136 + ->setHeader(pht('Administrator')) 137 + ->setQuality(PHUIBadgeView::RARE); 138 + 139 + $badges3[] = id(new PHUIBadgeMiniView()) 140 + ->setIcon('fa-camera-retro') 141 + ->setHeader(pht('Designer')) 142 + ->setQuality(PHUIBadgeView::EPIC); 143 + 116 144 $flex1 = new PHUIBadgeBoxView(); 117 145 $flex1->addItems($badges1); 118 146 ··· 127 155 ->setHeaderText(pht('Acheivements')) 128 156 ->appendChild($flex2); 129 157 130 - return array($box1, $box2); 158 + $flex3 = new PHUIBadgeBoxView(); 159 + $flex3->addItems($badges3); 160 + $flex3->setCollapsed(true); 161 + $flex3->addClass('ml'); 162 + 163 + $box3 = id(new PHUIObjectBoxView()) 164 + ->setHeaderText(pht('PHUIBadgeMiniView')) 165 + ->appendChild($flex3); 166 + 167 + return array($box1, $box2, $box3); 131 168 } 132 169 }
+15 -12
src/applications/uiexample/examples/PHUITimelineExample.php
··· 21 21 ->withPHIDs(array($user->getPHID())) 22 22 ->executeOne(); 23 23 24 + $designer = id(new PHUIBadgeMiniView()) 25 + ->setIcon('fa-camera-retro') 26 + ->setHeader(pht('Designer')) 27 + ->setQuality(PHUIBadgeView::EPIC); 28 + 29 + $admin = id(new PHUIBadgeMiniView()) 30 + ->setIcon('fa-user') 31 + ->setHeader(pht('Administrator')) 32 + ->setQuality(PHUIBadgeView::RARE); 33 + 24 34 $events = array(); 25 35 26 36 $events[] = id(new PHUITimelineEventView()) 27 37 ->setUserHandle($handle) 28 38 ->setTitle(pht('A major event.')) 29 - ->appendChild(pht('This is a major timeline event.')); 39 + ->appendChild(pht('This is a major timeline event.')) 40 + ->addBadge($designer) 41 + ->addBadge($admin); 30 42 31 43 $events[] = id(new PHUITimelineEventView()) 32 44 ->setUserHandle($handle) ··· 44 56 ->setTitle(pht('Another minor event.')); 45 57 46 58 $events[] = id(new PHUITimelineEventView()) 47 - ->setIcon('fa-trophy') 48 - ->setToken('medal-1') 49 - ->setUserHandle($handle); 50 - 51 - $events[] = id(new PHUITimelineEventView()) 52 - ->setIcon('fa-quote-left') 53 - ->setToken('medal-1', true) 54 - ->setUserHandle($handle); 55 - 56 - $events[] = id(new PHUITimelineEventView()) 57 59 ->setUserHandle($handle) 58 60 ->setTitle(pht('Major Red Event')) 59 61 ->setIcon('fa-heart-o') 60 62 ->appendChild(pht('This event is red!')) 61 - ->setColor(PhabricatorTransactions::COLOR_RED); 63 + ->setColor(PhabricatorTransactions::COLOR_RED) 64 + ->addBadge($designer); 62 65 63 66 $events[] = id(new PHUITimelineEventView()) 64 67 ->setUserHandle($handle)
+9
src/view/phui/PHUIBadgeBoxView.php
··· 3 3 final class PHUIBadgeBoxView extends AphrontTagView { 4 4 5 5 private $items = array(); 6 + private $collapsed; 6 7 7 8 public function addItem($item) { 8 9 $this->items[] = $item; 10 + return $this; 11 + } 12 + 13 + public function setCollapsed($collapsed) { 14 + $this->collapsed = $collapsed; 9 15 return $this; 10 16 } 11 17 ··· 26 32 $classes = array(); 27 33 $classes[] = 'phui-badge-flex-view'; 28 34 $classes[] = 'grouped'; 35 + if ($this->collapsed) { 36 + $classes[] = 'flex-view-collapsed'; 37 + } 29 38 30 39 return array( 31 40 'class' => implode(' ', $classes),
+65
src/view/phui/PHUIBadgeMiniView.php
··· 1 + <?php 2 + 3 + final class PHUIBadgeMiniView extends AphrontTagView { 4 + 5 + private $href; 6 + private $icon; 7 + private $quality; 8 + private $header; 9 + 10 + public function setIcon($icon) { 11 + $this->icon = $icon; 12 + return $this; 13 + } 14 + 15 + public function setHref($href) { 16 + $this->href = $href; 17 + return $this; 18 + } 19 + 20 + public function setQuality($quality) { 21 + $this->quality = $quality; 22 + return $this; 23 + } 24 + 25 + public function setHeader($header) { 26 + $this->header = $header; 27 + return $this; 28 + } 29 + 30 + protected function getTagName() { 31 + if ($this->href) { 32 + return 'a'; 33 + } else { 34 + return 'span'; 35 + } 36 + } 37 + 38 + protected function getTagAttributes() { 39 + require_celerity_resource('phui-badge-view-css'); 40 + Javelin::initBehavior('phabricator-tooltips'); 41 + 42 + $classes = array(); 43 + $classes[] = 'phui-badge-mini'; 44 + if ($this->quality) { 45 + $classes[] = 'phui-badge-mini-'.$this->quality; 46 + } 47 + 48 + return array( 49 + 'class' => implode(' ', $classes), 50 + 'sigil' => 'has-tooltip', 51 + 'href' => $this->href, 52 + 'meta' => array( 53 + 'tip' => $this->header, 54 + ), 55 + ); 56 + } 57 + 58 + protected function getTagContent() { 59 + 60 + return id(new PHUIIconView()) 61 + ->setIconFont($this->icon); 62 + 63 + } 64 + 65 + }
+19 -1
src/view/phui/PHUITimelineEventView.php
··· 26 26 private $quoteRef; 27 27 private $reallyMajorEvent; 28 28 private $hideCommentOptions = false; 29 + private $badges = array(); 29 30 30 31 public function setQuoteRef($quote_ref) { 31 32 $this->quoteRef = $quote_ref; ··· 147 148 148 149 public function addClass($class) { 149 150 $this->classes[] = $class; 151 + return $this; 152 + } 153 + 154 + public function addBadge(PHUIBadgeMiniView $badge) { 155 + $this->badges[] = $badge; 150 156 return $this; 151 157 } 152 158 ··· 355 361 ''); 356 362 357 363 $image = null; 364 + $badges = null; 358 365 if ($image_uri) { 359 366 $image = phutil_tag( 360 367 'div', ··· 363 370 'class' => 'phui-timeline-image', 364 371 ), 365 372 ''); 373 + if ($this->badges) { 374 + $flex = new PHUIBadgeBoxView(); 375 + $flex->addItems($this->badges); 376 + $flex->setCollapsed(true); 377 + $badges = phutil_tag( 378 + 'div', 379 + array( 380 + 'class' => 'phui-timeline-badges', 381 + ), 382 + $flex); 383 + } 366 384 } 367 385 368 386 $content_classes = array(); ··· 404 422 array( 405 423 'class' => implode(' ', $content_classes), 406 424 ), 407 - array($image, $wedge, $content)); 425 + array($image, $badges, $wedge, $content)); 408 426 409 427 $outer_classes = $this->classes; 410 428 $outer_classes[] = 'phui-timeline-shell';
+58
webroot/rsrc/css/phui/phui-badge.css
··· 13 13 padding: 4px 8px; 14 14 } 15 15 16 + .phui-badge-flex-view.flex-view-collapsed { 17 + padding: 0; 18 + } 19 + 20 + .flex-view-collapsed .phui-badge-flex-item { 21 + padding: 1px; 22 + } 23 + 16 24 .phui-badge-view { 17 25 display: inline-block; 18 26 position: relative; ··· 157 165 background-color: {$sh-yellowbackground}; 158 166 border-color: {$sh-lightyellowborder}; 159 167 } 168 + 169 + /** Mini View ****************************************************************/ 170 + 171 + .phui-badge-mini { 172 + background-color: {$greyborder}; 173 + border-radius: 18px; 174 + height: 25px; 175 + width: 25px; 176 + line-height: 24px; 177 + text-align: center; 178 + display: inline-block; 179 + opacity: 0.7; 180 + } 181 + 182 + .phui-badge-mini:hover { 183 + opacity: 1; 184 + } 185 + 186 + .phui-badge-mini .phui-icon-view { 187 + color: #fff; 188 + font-size: 12px; 189 + } 190 + 191 + .phui-badge-mini-grey { 192 + background-color: {$greyborder}; 193 + } 194 + 195 + .phui-badge-mini-white { 196 + background-color: {$lightblueborder}; 197 + } 198 + 199 + .phui-badge-mini-green { 200 + background-color: {$sh-greenicon}; 201 + } 202 + 203 + .phui-badge-mini-blue { 204 + background-color: {$blue}; 205 + } 206 + 207 + .phui-badge-mini-indigo { 208 + background-color: {$sh-indigoicon}; 209 + } 210 + 211 + .phui-badge-mini-orange { 212 + background-color: {$sh-orangeicon}; 213 + } 214 + 215 + .phui-badge-mini-yellow { 216 + background-color: {$sh-yellowicon}; 217 + }
+7
webroot/rsrc/css/phui/phui-timeline-view.css
··· 388 388 .phui-timeline-view + .phui-object-box { 389 389 margin-top: 0; 390 390 } 391 + 392 + .phui-timeline-badges { 393 + position: absolute; 394 + left: -64px; 395 + top: 52px; 396 + width: 54px; 397 + }