1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Add a tooltip method to PHUIIconView

Summary: We seem to use these a lot. Makes the code cleaner.

Test Plan: UIExamples.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D18114
This commit is contained in:
Chad Little 2017-06-12 18:00:04 +00:00 committed by chad
parent 6cb326e58e
commit 2a3022913f
2 changed files with 21 additions and 1 deletions

View file

@ -159,7 +159,8 @@ final class PHUIIconExample extends PhabricatorUIExample {
->setIcon($icon) ->setIcon($icon)
->setBackground('bg-blue') ->setBackground('bg-blue')
->setHref('#') ->setHref('#')
->addClass('mmr'); ->addClass('mmr')
->setTooltip($icon);
} }
$layout_cicons = id(new PHUIBoxView()) $layout_cicons = id(new PHUIBoxView())

View file

@ -18,6 +18,7 @@ final class PHUIIconView extends AphrontTagView {
private $iconFont; private $iconFont;
private $iconColor; private $iconColor;
private $iconBackground; private $iconBackground;
private $tooltip;
public function setHref($href) { public function setHref($href) {
$this->href = $href; $this->href = $href;
@ -60,6 +61,11 @@ final class PHUIIconView extends AphrontTagView {
return $this; return $this;
} }
public function setTooltip($text) {
$this->tooltip = $text;
return $this;
}
protected function getTagName() { protected function getTagName() {
$tag = 'span'; $tag = 'span';
if ($this->href) { if ($this->href) {
@ -100,11 +106,24 @@ final class PHUIIconView extends AphrontTagView {
$this->appendChild($this->text); $this->appendChild($this->text);
} }
$sigil = null;
$meta = array();
if ($this->tooltip) {
Javelin::initBehavior('phabricator-tooltips');
require_celerity_resource('aphront-tooltip-css');
$sigil = 'has-tooltip';
$meta = array(
'tip' => $this->tooltip,
);
}
return array( return array(
'href' => $this->href, 'href' => $this->href,
'style' => $style, 'style' => $style,
'aural' => false, 'aural' => false,
'class' => $classes, 'class' => $classes,
'sigil' => $sigil,
'meta' => $meta,
); );
} }