@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 139 lines 3.0 kB view raw
1<?php 2 3final class PHUIXComponentsExample extends PhabricatorUIExample { 4 5 public function getName() { 6 return pht('PHUIX Components'); 7 } 8 9 public function getDescription() { 10 return pht('Copy/paste to make design maintenance twice as difficult.'); 11 } 12 13 public function getCategory() { 14 return pht('PHUIX'); 15 } 16 17 public function renderExample() { 18 $content = array(); 19 20 $icons = array( 21 array( 22 'icon' => 'fa-rocket', 23 ), 24 array( 25 'icon' => 'fa-cloud', 26 'color' => 'indigo', 27 ), 28 ); 29 30 foreach ($icons as $spec) { 31 $icon = new PHUIIconView(); 32 33 $icon->setIcon(idx($spec, 'icon'), idx($spec, 'color')); 34 35 $client_id = celerity_generate_unique_node_id(); 36 37 $server_view = $icon; 38 $client_view = javelin_tag( 39 'div', 40 array( 41 'id' => $client_id, 42 )); 43 44 Javelin::initBehavior( 45 'phuix-example', 46 array( 47 'type' => 'icon', 48 'id' => $client_id, 49 'spec' => $spec, 50 )); 51 52 $content[] = id(new AphrontMultiColumnView()) 53 ->addColumn($server_view) 54 ->addColumn($client_view); 55 } 56 57 58 $buttons = array( 59 array( 60 'text' => pht('Submit'), 61 ), 62 array( 63 'text' => pht('Activate'), 64 'icon' => 'fa-rocket', 65 ), 66 array( 67 'type' => PHUIButtonView::BUTTONTYPE_SIMPLE, 68 'text' => pht('3 / 5 Comments'), 69 'icon' => 'fa-comment', 70 ), 71 array( 72 'color' => PHUIButtonView::GREEN, 73 'text' => pht('Environmental!'), 74 ), 75 array( 76 'icon' => 'fa-cog', 77 ), 78 array( 79 'icon' => 'fa-cog', 80 'type' => PHUIButtonView::BUTTONTYPE_SIMPLE, 81 ), 82 array( 83 'text' => array('2 + 2', ' ', '=', ' ', '4'), 84 ), 85 array( 86 'color' => PHUIButtonView::GREY, 87 'text' => pht('Cancel'), 88 ), 89 array( 90 'text' => array('<strong />'), 91 ), 92 ); 93 94 foreach ($buttons as $spec) { 95 $button = new PHUIButtonView(); 96 97 if (idx($spec, 'text') !== null) { 98 $button->setText($spec['text']); 99 } 100 101 if (idx($spec, 'icon') !== null) { 102 $button->setIcon($spec['icon']); 103 } 104 105 if (idx($spec, 'type') !== null) { 106 $button->setButtonType($spec['type']); 107 } 108 109 if (idx($spec, 'color') !== null) { 110 $button->setColor($spec['color']); 111 } 112 113 $client_id = celerity_generate_unique_node_id(); 114 115 $server_view = $button; 116 $client_view = javelin_tag( 117 'div', 118 array( 119 'id' => $client_id, 120 )); 121 122 Javelin::initBehavior( 123 'phuix-example', 124 array( 125 'type' => 'button', 126 'id' => $client_id, 127 'spec' => $spec, 128 )); 129 130 $content[] = id(new AphrontMultiColumnView()) 131 ->addColumn($server_view) 132 ->addColumn($client_view); 133 } 134 135 return id(new PHUIBoxView()) 136 ->appendChild($content) 137 ->addMargin(PHUI::MARGIN_LARGE); 138 } 139}