phabricator /src/applications/uiexample/examples/PHUITagExample.php

Language PHP Lines 178
MD5 Hash ca8efebbf2e259c81c5c2952c53094cc
Repository https://github.com/navyuginfo/phabricator.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php

final class PHUITagExample extends PhabricatorUIExample {

  public function getName() {
    return 'Tags';
  }

  public function getDescription() {
    return hsprintf('Use <tt>PHUITagView</tt> to render various tags.');
  }

  public function renderExample() {
    $intro = array();

    $intro[] = 'Hey, ';
    $intro[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_PERSON)
      ->setName('@alincoln')
      ->setHref('#');
    $intro[] = ' how is stuff?';
    $intro[] = hsprintf('<br /><br />');


    $intro[] = 'Did you hear that ';
    $intro[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_PERSON)
      ->setName('@gwashington')
      ->setDotColor(PHUITagView::COLOR_RED)
      ->setHref('#');
    $intro[] = ' is away, ';
    $intro[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_PERSON)
      ->setName('@tjefferson')
      ->setDotColor(PHUITagView::COLOR_ORANGE)
      ->setHref('#');
    $intro[] = ' has some errands, and ';
    $intro[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_PERSON)
      ->setName('@rreagan')
      ->setDotColor(PHUITagView::COLOR_GREY)
      ->setHref('#');
    $intro[] = ' is gone?';
    $intro[] = hsprintf('<br /><br />');

    $intro[] = 'Take a look at ';
    $intro[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_OBJECT)
      ->setName('D123')
      ->setHref('#');
    $intro[] = ' when you get a chance.';
    $intro[] = hsprintf('<br /><br />');

    $intro[] = 'Hmm? ';
    $intro[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_OBJECT)
      ->setName('D123')
      ->setClosed(true)
      ->setHref('#');
    $intro[] = ' is ';
    $intro[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_STATE)
      ->setBackgroundColor(PHUITagView::COLOR_BLACK)
      ->setName('Abandoned');
    $intro[] = '.';
    $intro[] = hsprintf('<br /><br />');

    $intro[] = 'I hope someone is going to ';
    $intro[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_OBJECT)
      ->setName('T123: Water The Dog')
      ->setHref('#');
    $intro[] = ' -- that task is ';
    $intro[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_STATE)
      ->setBackgroundColor(PHUITagView::COLOR_RED)
      ->setName('High Priority');
    $intro[] = '!';

    $intro = id(new PHUIBoxView())
      ->appendChild($intro)
      ->addPadding(PHUI::PADDING_LARGE);

    $header1 = id(new PHUIHeaderView())
      ->setHeader('Colors');

    $colors = PHUITagView::getColors();
    $tags = array();
    foreach ($colors as $color) {
      $tags[] = id(new PHUITagView())
        ->setType(PHUITagView::TYPE_STATE)
        ->setBackgroundColor($color)
        ->setName(ucwords($color));
      $tags[] = hsprintf('<br /><br />');
    }

    $content1 = id(new PHUIBoxView())
      ->appendChild($tags)
      ->addPadding(PHUI::PADDING_LARGE);

    $tags = array();
    $tags[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_STATE)
      ->setBackgroundColor(PHUITagView::COLOR_GREEN)
      ->setDotColor(PHUITagView::COLOR_RED)
      ->setName('Christmas');
    $tags[] = hsprintf('<br /><br />');
    $tags[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_OBJECT)
      ->setBackgroundColor(PHUITagView::COLOR_ORANGE)
      ->setDotColor(PHUITagView::COLOR_BLACK)
      ->setName('Halloween');
    $tags[] = hsprintf('<br /><br />');
    $tags[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_STATE)
      ->setBackgroundColor(PHUITagView::COLOR_INDIGO)
      ->setDotColor(PHUITagView::COLOR_YELLOW)
      ->setName('Easter');

    $content2 = id(new PHUIBoxView())
      ->appendChild($tags)
      ->addPadding(PHUI::PADDING_LARGE);

    $icons = array();
    $icons[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_STATE)
      ->setBackgroundColor(PHUITagView::COLOR_GREEN)
      ->setIcon('fa-check white')
      ->setName('Passed');
    $icons[] = hsprintf('<br /><br />');
    $icons[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_STATE)
      ->setBackgroundColor(PHUITagView::COLOR_RED)
      ->setIcon('fa-times white')
      ->setName('Failed');
    $icons[] = hsprintf('<br /><br />');
    $icons[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_STATE)
      ->setBackgroundColor(PHUITagView::COLOR_BLUE)
      ->setIcon('fa-refresh white')
      ->setName('Running');
    $icons[] = hsprintf('<br /><br />');
    $icons[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_STATE)
      ->setBackgroundColor(PHUITagView::COLOR_GREY)
      ->setIcon('fa-pause white')
      ->setName('Paused');
    $icons[] = hsprintf('<br /><br />');
    $icons[] = id(new PHUITagView())
      ->setType(PHUITagView::TYPE_STATE)
      ->setBackgroundColor(PHUITagView::COLOR_BLACK)
      ->setIcon('fa-stop white')
      ->setName('Stopped');

    $content3 = id(new PHUIBoxView())
      ->appendChild($icons)
      ->addPadding(PHUI::PADDING_LARGE);

    $box = id(new PHUIObjectBoxView())
      ->setHeaderText('Inline')
      ->appendChild($intro);

    $box1 = id(new PHUIObjectBoxView())
      ->setHeaderText('Colors')
      ->appendChild($content1);

    $box2 = id(new PHUIObjectBoxView())
      ->setHeaderText('Holidays')
      ->appendChild($content2);

    $box3 = id(new PHUIObjectBoxView())
      ->setHeaderText('Icons')
      ->appendChild($content3);

    return array($box, $box1, $box2, $box3);
  }
}
Back to Top