2013-06-13 03:23:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PHUIButtonExample extends PhabricatorUIExample {
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return 'Buttons';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
return hsprintf('Use <tt><button></tt> to render buttons.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderExample() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$colors = array('', 'green', 'grey', 'black', 'disabled');
|
|
|
|
$sizes = array('', 'small');
|
|
|
|
$tags = array('a', 'button');
|
|
|
|
|
|
|
|
// phutil_tag
|
|
|
|
|
|
|
|
$column = array();
|
|
|
|
foreach ($tags as $tag) {
|
|
|
|
foreach ($colors as $color) {
|
|
|
|
foreach ($sizes as $key => $size) {
|
|
|
|
$class = implode(' ', array($color, $size));
|
|
|
|
|
|
|
|
if ($tag == 'a') {
|
|
|
|
$class .= ' button';
|
|
|
|
}
|
|
|
|
|
|
|
|
$column[$key][] = phutil_tag(
|
|
|
|
$tag,
|
|
|
|
array(
|
|
|
|
'class' => $class,
|
|
|
|
),
|
|
|
|
phutil_utf8_ucwords($size.' '.$color.' '.$tag));
|
|
|
|
|
|
|
|
$column[$key][] = hsprintf('<br /><br />');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$column3 = array();
|
|
|
|
foreach ($colors as $color) {
|
|
|
|
$caret = phutil_tag('span', array('class' => 'caret'), '');
|
|
|
|
$column3[] = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'class' => $color.' button dropdown'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
phutil_utf8_ucwords($color.' Dropdown'),
|
|
|
|
$caret,
|
|
|
|
));
|
|
|
|
$column3[] = hsprintf('<br /><br />');
|
|
|
|
}
|
|
|
|
|
|
|
|
$layout1 = id(new AphrontMultiColumnView())
|
|
|
|
->addColumn($column[0])
|
|
|
|
->addColumn($column[1])
|
|
|
|
->addColumn($column3)
|
|
|
|
->setFluidLayout(true)
|
|
|
|
->setGutter(AphrontMultiColumnView::GUTTER_MEDIUM);
|
|
|
|
|
|
|
|
// PHUIButtonView
|
|
|
|
|
|
|
|
$colors = array(null,
|
|
|
|
PHUIButtonView::GREEN,
|
|
|
|
PHUIButtonView::GREY,
|
|
|
|
PHUIButtonView::BLACK,
|
|
|
|
PHUIButtonView::DISABLED);
|
|
|
|
$sizes = array(null, PHUIButtonView::SMALL);
|
|
|
|
$column = array();
|
|
|
|
foreach ($colors as $color) {
|
|
|
|
foreach ($sizes as $key => $size) {
|
|
|
|
$column[$key][] = id(new PHUIButtonView())
|
|
|
|
->setColor($color)
|
|
|
|
->setSize($size)
|
|
|
|
->setTag('a')
|
|
|
|
->setText('Clicky');
|
|
|
|
$column[$key][] = hsprintf('<br /><br />');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($colors as $color) {
|
|
|
|
$column[2][] = id(new PHUIButtonView())
|
|
|
|
->setColor($color)
|
|
|
|
->setTag('button')
|
|
|
|
->setText('Button')
|
|
|
|
->setDropdown(true);
|
|
|
|
$column[2][] = hsprintf('<br /><br />');
|
|
|
|
}
|
|
|
|
|
|
|
|
$layout2 = id(new AphrontMultiColumnView())
|
|
|
|
->addColumn($column[0])
|
|
|
|
->addColumn($column[1])
|
|
|
|
->addColumn($column[2])
|
|
|
|
->setFluidLayout(true)
|
|
|
|
->setGutter(AphrontMultiColumnView::GUTTER_MEDIUM);
|
|
|
|
|
|
|
|
// Icon Buttons
|
|
|
|
|
|
|
|
$column = array();
|
|
|
|
$icons = array(
|
2014-05-12 19:08:32 +02:00
|
|
|
'Comment' => 'fa-comment',
|
|
|
|
'Give Token' => 'fa-trophy',
|
|
|
|
'Reverse Time' => 'fa-clock-o',
|
|
|
|
'Implode Earth' => 'fa-exclamation-triangle red');
|
2013-06-13 03:23:35 +02:00
|
|
|
foreach ($icons as $text => $icon) {
|
|
|
|
$image = id(new PHUIIconView())
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIconFont($icon);
|
2013-06-13 03:23:35 +02:00
|
|
|
$column[] = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setColor(PHUIButtonView::GREY)
|
|
|
|
->setIcon($image)
|
|
|
|
->setText($text)
|
|
|
|
->addClass(PHUI::MARGIN_SMALL_RIGHT);
|
|
|
|
}
|
|
|
|
|
2013-12-03 17:34:04 +01:00
|
|
|
$column2 = array();
|
|
|
|
$icons = array(
|
2014-05-12 19:08:32 +02:00
|
|
|
'Subscribe' => 'fa-check-circle bluegrey',
|
|
|
|
'Edit' => 'fa-pencil bluegrey');
|
2013-12-03 17:34:04 +01:00
|
|
|
foreach ($icons as $text => $icon) {
|
|
|
|
$image = id(new PHUIIconView())
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIconFont($icon);
|
2013-12-03 17:34:04 +01:00
|
|
|
$column2[] = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setColor(PHUIButtonView::SIMPLE)
|
|
|
|
->setIcon($image)
|
|
|
|
->setText($text)
|
|
|
|
->addClass(PHUI::MARGIN_SMALL_RIGHT);
|
|
|
|
}
|
|
|
|
|
2013-06-13 03:23:35 +02:00
|
|
|
$layout3 = id(new AphrontMultiColumnView())
|
|
|
|
->addColumn($column)
|
2013-12-03 17:34:04 +01:00
|
|
|
->addColumn($column2)
|
2013-06-13 03:23:35 +02:00
|
|
|
->setFluidLayout(true)
|
|
|
|
->setGutter(AphrontMultiColumnView::GUTTER_MEDIUM);
|
|
|
|
|
|
|
|
|
|
|
|
// Baby Got Back Buttons
|
|
|
|
|
|
|
|
$column = array();
|
|
|
|
$icons = array('Asana', 'Github', 'Facebook', 'Google', 'LDAP');
|
|
|
|
foreach ($icons as $icon) {
|
|
|
|
$image = id(new PHUIIconView())
|
|
|
|
->setSpriteSheet(PHUIIconView::SPRITE_LOGIN)
|
|
|
|
->setSpriteIcon($icon);
|
|
|
|
$column[] = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setSize(PHUIButtonView::BIG)
|
|
|
|
->setColor(PHUIButtonView::GREY)
|
|
|
|
->setIcon($image)
|
|
|
|
->setText('Login or Register')
|
|
|
|
->setSubtext($icon)
|
|
|
|
->addClass(PHUI::MARGIN_MEDIUM_RIGHT);
|
|
|
|
}
|
|
|
|
|
|
|
|
$layout4 = id(new AphrontMultiColumnView())
|
|
|
|
->addColumn($column)
|
|
|
|
->setFluidLayout(true)
|
|
|
|
->setGutter(AphrontMultiColumnView::GUTTER_MEDIUM);
|
|
|
|
|
|
|
|
|
|
|
|
// Set it and forget it
|
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
$head1 = id(new PHUIHeaderView())
|
2013-06-13 03:23:35 +02:00
|
|
|
->setHeader('phutil_tag');
|
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
$head2 = id(new PHUIHeaderView())
|
2013-06-13 03:23:35 +02:00
|
|
|
->setHeader('PHUIButtonView');
|
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
$head3 = id(new PHUIHeaderView())
|
2013-06-13 03:23:35 +02:00
|
|
|
->setHeader('Icon Buttons');
|
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
$head4 = id(new PHUIHeaderView())
|
2013-06-13 03:23:35 +02:00
|
|
|
->setHeader('Big Icon Buttons');
|
|
|
|
|
|
|
|
$wrap1 = id(new PHUIBoxView())
|
|
|
|
->appendChild($layout1)
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE);
|
|
|
|
|
|
|
|
$wrap2 = id(new PHUIBoxView())
|
|
|
|
->appendChild($layout2)
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE);
|
|
|
|
|
|
|
|
$wrap3 = id(new PHUIBoxView())
|
|
|
|
->appendChild($layout3)
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE);
|
|
|
|
|
|
|
|
$wrap4 = id(new PHUIBoxView())
|
|
|
|
->appendChild($layout4)
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE);
|
|
|
|
|
|
|
|
return array($head1, $wrap1, $head2, $wrap2, $head3, $wrap3,
|
|
|
|
$head4, $wrap4);
|
|
|
|
}
|
|
|
|
}
|