1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 15:30:58 +01:00

Make "simple" a "button type", not a "color"

Summary:
Ref M1476. Currently, `setColor('simple')` is meaningful. Instead, `setButtonType('simple')`.

Depends on D18047.

Test Plan: Looked at UI examples, Phame, Auth. Notifications mooted by D18047.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D18048
This commit is contained in:
epriestley 2017-05-30 14:32:54 -07:00
parent 83e99fb691
commit 2c0dab055f
8 changed files with 37 additions and 15 deletions

View file

@ -103,7 +103,7 @@ final class PhabricatorAuthListController
$button = id(new PHUIButtonView())
->setTag('a')
->setColor(PHUIButtonView::SIMPLE)
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
->setHref($this->getApplicationURI('config/new/'))
->setIcon('fa-plus')
->setDisabled(!$can_manage)

View file

@ -30,7 +30,7 @@ final class PhabricatorGuideListView extends AphrontView {
->setText(pht('Skip'))
->setTag('a')
->setHref($skip_href)
->setColor(PHUIButtonView::SIMPLE);
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE);
$list_item->setSideColumn($skip);
}
$list->addItem($list_item);

View file

@ -98,7 +98,7 @@ final class PhameBlogSearchEngine
->setTag('a')
->setText('New Post')
->setHref($this->getApplicationURI('/post/edit/?blog='.$id))
->setColor(PHUIButtonView::SIMPLE);
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE);
$item->setSideColumn($button);
}

View file

@ -62,11 +62,11 @@ final class PHUIBoxExample extends PhabricatorUIExample {
);
$button = id(new PHUIButtonView())
->setTag('a')
->setColor(PHUIButtonView::SIMPLE)
->setIcon('fa-heart')
->setText(pht('Such Wow'))
->addClass(PHUI::MARGIN_SMALL_RIGHT);
->setTag('a')
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
->setIcon('fa-heart')
->setText(pht('Such Wow'))
->addClass(PHUI::MARGIN_SMALL_RIGHT);
$badge1 = id(new PHUIBadgeMiniView())
->setIcon('fa-bug')

View file

@ -36,7 +36,7 @@ final class PHUIButtonBarExample extends PhabricatorUIExample {
foreach ($icons as $text => $icon) {
$button = id(new PHUIButtonView())
->setTag('a')
->setColor(PHUIButtonView::SIMPLE)
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
->setTitle($text)
->setText($text);
@ -47,7 +47,7 @@ final class PHUIButtonBarExample extends PhabricatorUIExample {
foreach ($icons as $text => $icon) {
$button = id(new PHUIButtonView())
->setTag('a')
->setColor(PHUIButtonView::SIMPLE)
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
->setTitle($text)
->setTooltip($text)
->setIcon($icon);

View file

@ -129,15 +129,15 @@ final class PHUIButtonExample extends PhabricatorUIExample {
'Subscribe' => 'fa-check-circle bluegrey',
'Edit' => 'fa-pencil bluegrey',
);
$colors = array(
PHUIButtonView::SIMPLE,
$designs = array(
PHUIButtonView::BUTTONTYPE_SIMPLE,
);
$column = array();
foreach ($colors as $color) {
foreach ($designs as $design) {
foreach ($icons as $text => $icon) {
$column[] = id(new PHUIButtonView())
->setTag('a')
->setColor($color)
->setButtonType($design)
->setIcon($icon)
->setText($text)
->addClass(PHUI::MARGIN_SMALL_RIGHT);

View file

@ -10,6 +10,9 @@ final class PHUIButtonView extends AphrontTagView {
const SMALL = 'small';
const BIG = 'big';
const BUTTONTYPE_DEFAULT = 'buttontype.default';
const BUTTONTYPE_SIMPLE = 'buttontype.simple';
private $size;
private $text;
private $subtext;
@ -25,6 +28,7 @@ final class PHUIButtonView extends AphrontTagView {
private $tooltip;
private $noCSS;
private $hasCaret;
private $buttonType = self::BUTTONTYPE_DEFAULT;
public function setName($name) {
$this->name = $name;
@ -103,6 +107,15 @@ final class PHUIButtonView extends AphrontTagView {
return $this->hasCaret;
}
public function setButtonType($button_type) {
$this->buttonType = $button_type;
return $this;
}
public function getButtonType() {
return $this->buttonType;
}
public function setIcon($icon, $first = true) {
if (!($icon instanceof PHUIIconView)) {
$icon = id(new PHUIIconView())
@ -169,6 +182,15 @@ final class PHUIButtonView extends AphrontTagView {
$classes[] = 'disabled';
}
switch ($this->getButtonType()) {
case self::BUTTONTYPE_DEFAULT:
// Nothing special for default buttons.
break;
case self::BUTTONTYPE_SIMPLE:
$classes[] = 'simple';
break;
}
$sigil = null;
$meta = null;
if ($this->tooltip) {

View file

@ -79,7 +79,7 @@ final class PHUIDocumentViewPro extends AphrontTagView {
$toc[] = id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-align-left')
->setColor(PHUIButtonView::SIMPLE)
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
->addClass('phui-document-toc')
->addSigil('jx-toggle-class')
->setMetaData(array(