@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
at upstream/main 249 lines 7.1 kB view raw
1<?php 2 3final class PHUIIconExample extends PhabricatorUIExample { 4 5 public function getName() { 6 return pht('Icons and Images'); 7 } 8 9 public function getDescription() { 10 return pht('Easily render icons or images with links and sprites.'); 11 } 12 13 public function getCategory() { 14 return pht('Catalogs'); 15 } 16 17 private function listTransforms() { 18 return array( 19 'ph-rotate-90', 20 'ph-rotate-180', 21 'ph-rotate-270', 22 'ph-flip-horizontal', 23 'ph-flip-vertical', 24 'ph-spin', 25 ); 26 } 27 28 public function renderExample() { 29 30 $colors = PHUIIconView::getIconColors(); 31 $colors = array_merge(array(null), $colors); 32 $fas = PHUIIconView::getIcons(); 33 34 $trans = $this->listTransforms(); 35 36 $cicons = array(); 37 foreach ($colors as $color) { 38 $cicons[] = id(new PHUIIconView()) 39 ->addClass('phui-example-icon-transform') 40 ->setIcon('fa-tag '.$color) 41 ->setText(pht('fa-tag %s', $color)); 42 } 43 $ficons = array(); 44 sort($fas); 45 foreach ($fas as $fa) { 46 $ficons[] = id(new PHUIIconView()) 47 ->addClass('phui-example-icon-name') 48 ->setIcon($fa) 49 ->setText($fa); 50 } 51 52 $person1 = new PHUIIconView(); 53 $person1->setHeadSize(PHUIIconView::HEAD_MEDIUM); 54 $person1->setHref('https://en.wikipedia.org/wiki/George_Washington'); 55 $person1->setImage( 56 celerity_get_resource_uri('/rsrc/image/people/washington.png')); 57 58 $person2 = new PHUIIconView(); 59 $person2->setHeadSize(PHUIIconView::HEAD_MEDIUM); 60 $person2->setHref('https://en.wikipedia.org/wiki/Warren_G._Harding'); 61 $person2->setImage( 62 celerity_get_resource_uri('/rsrc/image/people/harding.png')); 63 64 $person3 = new PHUIIconView(); 65 $person3->setHeadSize(PHUIIconView::HEAD_MEDIUM); 66 $person3->setHref('https://en.wikipedia.org/wiki/William_Howard_Taft'); 67 $person3->setImage( 68 celerity_get_resource_uri('/rsrc/image/people/taft.png')); 69 70 $person4 = new PHUIIconView(); 71 $person4->setHeadSize(PHUIIconView::HEAD_SMALL); 72 $person4->setHref('https://en.wikipedia.org/wiki/George_Washington'); 73 $person4->setImage( 74 celerity_get_resource_uri('/rsrc/image/people/washington.png')); 75 76 $person5 = new PHUIIconView(); 77 $person5->setHeadSize(PHUIIconView::HEAD_SMALL); 78 $person5->setHref('https://en.wikipedia.org/wiki/Warren_G._Harding'); 79 $person5->setImage( 80 celerity_get_resource_uri('/rsrc/image/people/harding.png')); 81 82 $person6 = new PHUIIconView(); 83 $person6->setHeadSize(PHUIIconView::HEAD_SMALL); 84 $person6->setHref('https://en.wikipedia.org/wiki/William_Howard_Taft'); 85 $person6->setImage( 86 celerity_get_resource_uri('/rsrc/image/people/taft.png')); 87 88 $tokens = array( 89 'like-1', 90 'like-2', 91 'heart-1', 92 'heart-2', 93 ); 94 $tokenview = array(); 95 foreach ($tokens as $token) { 96 $tokenview[] = 97 id(new PHUIIconView()) 98 ->setSpriteSheet(PHUIIconView::SPRITE_TOKENS) 99 ->setSpriteIcon($token); 100 } 101 102 $logins = array( 103 'Asana', 104 'Dropbox', 105 'Google', 106 'Github', 107 ); 108 $loginview = array(); 109 foreach ($logins as $login) { 110 $loginview[] = 111 id(new PHUIIconView()) 112 ->setSpriteSheet(PHUIIconView::SPRITE_LOGIN) 113 ->setSpriteIcon($login) 114 ->addClass(PHUI::MARGIN_SMALL_RIGHT); 115 } 116 117 $circles = array('fa-pencil', 'fa-chevron-left', 'fa-chevron-right'); 118 $circleview = array(); 119 foreach ($circles as $circle) { 120 $circleview[] = 121 id(new PHUIIconCircleView()) 122 ->setIcon($circle) 123 ->setHref('#') 124 ->addClass('mmr'); 125 } 126 127 $circles = array('fa-plus', 'fa-bars', 'fa-paw'); 128 foreach ($circles as $circle) { 129 $circleview[] = 130 id(new PHUIIconCircleView()) 131 ->setIcon($circle) 132 ->setSize(PHUIIconCircleView::MEDIUM) 133 ->setHref('#') 134 ->addClass('mmr'); 135 } 136 137 $circles = array('fa-gear', 'fa-recycle'); 138 $colors = array('green', 'pink', 'red', 'sky', 'violet'); 139 foreach ($circles as $circle) { 140 $states = PHUIIconCircleView::getStateMap(); 141 foreach ($states as $state => $name) { 142 $i = array_rand($colors); 143 $circleview[] = 144 id(new PHUIIconCircleView()) 145 ->setIcon($circle) 146 ->setSize(PHUIIconCircleView::SMALL) 147 ->setState($state) 148 ->setColor($colors[$i]) 149 ->setHref('#') 150 ->addClass('mmr'); 151 } 152 } 153 154 $squares = array('fa-briefcase', 'fa-code', 'fa-globe', 'fa-home'); 155 $squareview = array(); 156 foreach ($squares as $icon) { 157 $squareview[] = 158 id(new PHUIIconView()) 159 ->setIcon($icon) 160 ->setBackground('bg-blue') 161 ->setHref('#') 162 ->addClass('mmr') 163 ->setTooltip($icon); 164 } 165 166 $layout_cicons = id(new PHUIBoxView()) 167 ->appendChild($cicons) 168 ->addMargin(PHUI::MARGIN_LARGE); 169 170 $layout_fa = id(new PHUIBoxView()) 171 ->appendChild($ficons) 172 ->addMargin(PHUI::MARGIN_LARGE); 173 174 $layout2 = id(new PHUIBoxView()) 175 ->appendChild(array($person1, $person2, $person3)) 176 ->addMargin(PHUI::MARGIN_MEDIUM); 177 178 $layout2a = id(new PHUIBoxView()) 179 ->appendChild(array($person4, $person5, $person6)) 180 ->addMargin(PHUI::MARGIN_MEDIUM); 181 182 $layout3 = id(new PHUIBoxView()) 183 ->appendChild($tokenview) 184 ->addMargin(PHUI::MARGIN_MEDIUM); 185 186 $layout4 = id(new PHUIBoxView()) 187 ->appendChild($circleview) 188 ->addMargin(PHUI::MARGIN_MEDIUM); 189 190 $layout5 = id(new PHUIBoxView()) 191 ->appendChild($squareview) 192 ->addMargin(PHUI::MARGIN_MEDIUM); 193 194 $layout6 = id(new PHUIBoxView()) 195 ->appendChild($loginview) 196 ->addMargin(PHUI::MARGIN_MEDIUM); 197 198 $fa_link = phutil_tag( 199 'a', 200 array( 201 'href' => 'http://fontawesome.io', 202 ), 203 'http://fontawesome.io'); 204 $fa_text = pht('Font Awesome by Dave Gandy - %s', $fa_link); 205 206 $fontawesome = id(new PHUIObjectBoxView()) 207 ->setHeaderText($fa_text) 208 ->appendChild($layout_fa); 209 210 $transforms = id(new PHUIObjectBoxView()) 211 ->setHeaderText(pht('Colors and Transforms')) 212 ->appendChild($layout_cicons); 213 214 $wrap2 = id(new PHUIObjectBoxView()) 215 ->setHeaderText(pht('People!')) 216 ->appendChild(array($layout2, $layout2a)); 217 218 $wrap3 = id(new PHUIObjectBoxView()) 219 ->setHeaderText(pht('Tokens')) 220 ->appendChild($layout3); 221 222 $wrap4 = id(new PHUIObjectBoxView()) 223 ->setHeaderText(pht('Circles')) 224 ->appendChild($layout4); 225 226 $wrap5 = id(new PHUIObjectBoxView()) 227 ->setHeaderText(pht('Squares')) 228 ->appendChild($layout5); 229 230 $wrap6 = id(new PHUIObjectBoxView()) 231 ->setHeaderText(pht('Authentication')) 232 ->appendChild($layout6); 233 234 return phutil_tag( 235 'div', 236 array( 237 'class' => 'phui-icon-example', 238 ), 239 array( 240 $fontawesome, 241 $transforms, 242 $wrap2, 243 $wrap3, 244 $wrap4, 245 $wrap5, 246 $wrap6, 247 )); 248 } 249}