From 2c0dab055f73e53f2989c9d1ce8ca26ae402a302 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 30 May 2017 14:32:54 -0700 Subject: [PATCH] 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 --- .../config/PhabricatorAuthListController.php | 2 +- .../guides/view/PhabricatorGuideListView.php | 2 +- .../phame/query/PhameBlogSearchEngine.php | 2 +- .../uiexample/examples/PHUIBoxExample.php | 10 ++++----- .../examples/PHUIButtonBarExample.php | 4 ++-- .../uiexample/examples/PHUIButtonExample.php | 8 +++---- src/view/phui/PHUIButtonView.php | 22 +++++++++++++++++++ src/view/phui/PHUIDocumentViewPro.php | 2 +- 8 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/applications/auth/controller/config/PhabricatorAuthListController.php b/src/applications/auth/controller/config/PhabricatorAuthListController.php index ae5808ed78..c5d4f7ad77 100644 --- a/src/applications/auth/controller/config/PhabricatorAuthListController.php +++ b/src/applications/auth/controller/config/PhabricatorAuthListController.php @@ -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) diff --git a/src/applications/guides/view/PhabricatorGuideListView.php b/src/applications/guides/view/PhabricatorGuideListView.php index 04ab7c3058..089f325e0c 100644 --- a/src/applications/guides/view/PhabricatorGuideListView.php +++ b/src/applications/guides/view/PhabricatorGuideListView.php @@ -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); diff --git a/src/applications/phame/query/PhameBlogSearchEngine.php b/src/applications/phame/query/PhameBlogSearchEngine.php index 3d23a9763d..eaef32af1c 100644 --- a/src/applications/phame/query/PhameBlogSearchEngine.php +++ b/src/applications/phame/query/PhameBlogSearchEngine.php @@ -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); } diff --git a/src/applications/uiexample/examples/PHUIBoxExample.php b/src/applications/uiexample/examples/PHUIBoxExample.php index 7a2674da94..4a551de707 100644 --- a/src/applications/uiexample/examples/PHUIBoxExample.php +++ b/src/applications/uiexample/examples/PHUIBoxExample.php @@ -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') diff --git a/src/applications/uiexample/examples/PHUIButtonBarExample.php b/src/applications/uiexample/examples/PHUIButtonBarExample.php index 1501770dcf..d7992aa830 100644 --- a/src/applications/uiexample/examples/PHUIButtonBarExample.php +++ b/src/applications/uiexample/examples/PHUIButtonBarExample.php @@ -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); diff --git a/src/applications/uiexample/examples/PHUIButtonExample.php b/src/applications/uiexample/examples/PHUIButtonExample.php index 900125cbc2..8f2e1e57a7 100644 --- a/src/applications/uiexample/examples/PHUIButtonExample.php +++ b/src/applications/uiexample/examples/PHUIButtonExample.php @@ -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); diff --git a/src/view/phui/PHUIButtonView.php b/src/view/phui/PHUIButtonView.php index ac3f8aabe0..0d0e0f3363 100644 --- a/src/view/phui/PHUIButtonView.php +++ b/src/view/phui/PHUIButtonView.php @@ -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) { diff --git a/src/view/phui/PHUIDocumentViewPro.php b/src/view/phui/PHUIDocumentViewPro.php index d60cd78d44..51ecc3526e 100644 --- a/src/view/phui/PHUIDocumentViewPro.php +++ b/src/view/phui/PHUIDocumentViewPro.php @@ -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(