mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Make PHUIIconView extend AprontTagView
Summary: Less code, more options. Test Plan: Test UIExamples page (action headers, tokens, icons and images). No visible difference. Reviewers: epriestley, btrahan, vrana Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5742
This commit is contained in:
parent
e8dd67b88c
commit
fdde45c623
2 changed files with 16 additions and 37 deletions
|
@ -2374,7 +2374,7 @@ phutil_register_library_map(array(
|
||||||
'PHUIBoxView' => 'AphrontTagView',
|
'PHUIBoxView' => 'AphrontTagView',
|
||||||
'PHUIFeedStoryView' => 'AphrontView',
|
'PHUIFeedStoryView' => 'AphrontView',
|
||||||
'PHUIIconExample' => 'PhabricatorUIExample',
|
'PHUIIconExample' => 'PhabricatorUIExample',
|
||||||
'PHUIIconView' => 'AphrontView',
|
'PHUIIconView' => 'AphrontTagView',
|
||||||
'PackageCreateMail' => 'PackageMail',
|
'PackageCreateMail' => 'PackageMail',
|
||||||
'PackageDeleteMail' => 'PackageMail',
|
'PackageDeleteMail' => 'PackageMail',
|
||||||
'PackageMail' => 'PhabricatorMail',
|
'PackageMail' => 'PhabricatorMail',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PHUIIconView extends AphrontView {
|
final class PHUIIconView extends AphrontTagView {
|
||||||
|
|
||||||
const SPRITE_MINICONS = 'minicons';
|
const SPRITE_MINICONS = 'minicons';
|
||||||
const SPRITE_ACTIONS = 'actions';
|
const SPRITE_ACTIONS = 'actions';
|
||||||
|
@ -10,8 +10,7 @@ final class PHUIIconView extends AphrontView {
|
||||||
const HEAD_SMALL = 'phuihead-small';
|
const HEAD_SMALL = 'phuihead-small';
|
||||||
const HEAD_MEDIUM = 'phuihead-medium';
|
const HEAD_MEDIUM = 'phuihead-medium';
|
||||||
|
|
||||||
private $href;
|
private $href = null;
|
||||||
private $workflow;
|
|
||||||
private $image;
|
private $image;
|
||||||
private $headSize = null;
|
private $headSize = null;
|
||||||
private $spriteIcon;
|
private $spriteIcon;
|
||||||
|
@ -22,11 +21,6 @@ final class PHUIIconView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setWorkflow($workflow) {
|
|
||||||
$this->workflow = $workflow;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setImage($image) {
|
public function setImage($image) {
|
||||||
$this->image = $image;
|
$this->image = $image;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -47,46 +41,31 @@ final class PHUIIconView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render() {
|
public function getTagName() {
|
||||||
require_celerity_resource('phui-icon-view-css');
|
|
||||||
|
|
||||||
$tag = 'span';
|
$tag = 'span';
|
||||||
if ($this->href) {
|
if ($this->href) {
|
||||||
$tag = 'a';
|
$tag = 'a';
|
||||||
}
|
}
|
||||||
|
return $tag;
|
||||||
|
}
|
||||||
|
|
||||||
$classes = array();
|
public function getTagAttributes() {
|
||||||
$classes[] = 'phui-icon-item-link';
|
require_celerity_resource('phui-icon-view-css');
|
||||||
|
|
||||||
|
$this->addClass('phui-icon-item-link');
|
||||||
|
|
||||||
if ($this->spriteIcon) {
|
if ($this->spriteIcon) {
|
||||||
require_celerity_resource('sprite-'.$this->spriteSheet.'-css');
|
require_celerity_resource('sprite-'.$this->spriteSheet.'-css');
|
||||||
$classes[] = 'sprite-'.$this->spriteSheet;
|
$this->addClass('sprite-'.$this->spriteSheet);
|
||||||
$classes[] = $this->spriteSheet.'-'.$this->spriteIcon;
|
$this->addClass($this->spriteSheet.'-'.$this->spriteIcon);
|
||||||
|
|
||||||
$action_icon = phutil_tag(
|
|
||||||
$tag,
|
|
||||||
array(
|
|
||||||
'href' => $this->href ? $this->href : null,
|
|
||||||
'class' => implode(' ', $classes),
|
|
||||||
'sigil' => $this->workflow ? 'workflow' : null,
|
|
||||||
),
|
|
||||||
'');
|
|
||||||
} else {
|
} else {
|
||||||
if ($this->headSize) {
|
if ($this->headSize) {
|
||||||
$classes[] = $this->headSize;
|
$this->addClass($this->headSize);
|
||||||
}
|
}
|
||||||
|
$this->setStyle('background-image: url('.$this->image.');');
|
||||||
$action_icon = phutil_tag(
|
|
||||||
$tag,
|
|
||||||
array(
|
|
||||||
'href' => $this->href ? $this->href : null,
|
|
||||||
'class' => implode(' ', $classes),
|
|
||||||
'sigil' => $this->workflow ? 'workflow' : null,
|
|
||||||
'style' => 'background-image: url('.$this->image.');'
|
|
||||||
),
|
|
||||||
'');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $action_icon;
|
$attribs = array('href' => $this->href);
|
||||||
|
return $attribs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue