1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 02:42:40 +01:00

Try layering state icons on PHUICircleIconView

Summary: I think this is reasonable for my current use case, but stacking icons overally is pretty clunky.

Test Plan:
UIExamples

{F4978899}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D18032
This commit is contained in:
Chad Little 2017-05-26 11:42:31 -07:00
parent aefc006ba5
commit 81809713e0
4 changed files with 98 additions and 6 deletions

View file

@ -9,7 +9,7 @@ return array(
'names' => array( 'names' => array(
'conpherence.pkg.css' => 'ff161f2d', 'conpherence.pkg.css' => 'ff161f2d',
'conpherence.pkg.js' => 'b5b51108', 'conpherence.pkg.js' => 'b5b51108',
'core.pkg.css' => 'b666574e', 'core.pkg.css' => '19f6f61f',
'core.pkg.js' => '21d34805', 'core.pkg.js' => '21d34805',
'darkconsole.pkg.js' => '1f9a31bc', 'darkconsole.pkg.js' => '1f9a31bc',
'differential.pkg.css' => '7d4cfa59', 'differential.pkg.css' => '7d4cfa59',
@ -158,7 +158,7 @@ return array(
'rsrc/css/phui/phui-header-view.css' => 'a3d1aecd', 'rsrc/css/phui/phui-header-view.css' => 'a3d1aecd',
'rsrc/css/phui/phui-hovercard.css' => 'f0592bcf', 'rsrc/css/phui/phui-hovercard.css' => 'f0592bcf',
'rsrc/css/phui/phui-icon-set-selector.css' => '87db8fee', 'rsrc/css/phui/phui-icon-set-selector.css' => '87db8fee',
'rsrc/css/phui/phui-icon.css' => '12b387a1', 'rsrc/css/phui/phui-icon.css' => '4c6d624c',
'rsrc/css/phui/phui-image-mask.css' => 'a8498f9c', 'rsrc/css/phui/phui-image-mask.css' => 'a8498f9c',
'rsrc/css/phui/phui-info-panel.css' => '27ea50a1', 'rsrc/css/phui/phui-info-panel.css' => '27ea50a1',
'rsrc/css/phui/phui-info-view.css' => '6e217679', 'rsrc/css/phui/phui-info-view.css' => '6e217679',
@ -862,7 +862,7 @@ return array(
'phui-hovercard' => '1bd28176', 'phui-hovercard' => '1bd28176',
'phui-hovercard-view-css' => 'f0592bcf', 'phui-hovercard-view-css' => 'f0592bcf',
'phui-icon-set-selector-css' => '87db8fee', 'phui-icon-set-selector-css' => '87db8fee',
'phui-icon-view-css' => '12b387a1', 'phui-icon-view-css' => '4c6d624c',
'phui-image-mask-css' => 'a8498f9c', 'phui-image-mask-css' => 'a8498f9c',
'phui-info-panel-css' => '27ea50a1', 'phui-info-panel-css' => '27ea50a1',
'phui-info-view-css' => '6e217679', 'phui-info-view-css' => '6e217679',

View file

@ -130,6 +130,23 @@ final class PHUIIconExample extends PhabricatorUIExample {
->addClass('mmr'); ->addClass('mmr');
} }
$circles = array('fa-gear', 'fa-recycle');
$colors = array('green', 'pink', 'red', 'sky', 'violet');
foreach ($circles as $circle) {
$states = PHUIIconCircleView::getStateMap();
foreach ($states as $state => $name) {
$i = array_rand($colors);
$circleview[] =
id(new PHUIIconCircleView())
->setIcon($circle)
->setSize(PHUIIconCircleView::SMALL)
->setState($state)
->setColor($colors[$i])
->setHref('#')
->addClass('mmr');
}
}
$squares = array('fa-briefcase', 'fa-code', 'fa-globe', 'fa-home'); $squares = array('fa-briefcase', 'fa-code', 'fa-globe', 'fa-home');
$squareview = array(); $squareview = array();
foreach ($squares as $icon) { foreach ($squares as $icon) {

View file

@ -6,10 +6,22 @@ final class PHUIIconCircleView extends AphrontTagView {
private $icon; private $icon;
private $color; private $color;
private $size; private $size;
private $state;
const SMALL = 'circle-small'; const SMALL = 'circle-small';
const MEDIUM = 'circle-medium'; const MEDIUM = 'circle-medium';
const STATE_FAIL = 'fa-times-circle';
const STATE_INFO = 'fa-info-circle';
const STATE_STOP = 'fa-stop-circle';
const STATE_START = 'fa-play-circle';
const STATE_PAUSE = 'fa-pause-circle';
const STATE_SUCCESS = 'fa-check-circle';
const STATE_WARNING = 'fa-exclamation-circle';
const STATE_PLUS = 'fa-plus-circle';
const STATE_MINUS = 'fa-minus-circle';
const STATE_UNKNOWN = 'fa-question-circle';
public function setHref($href) { public function setHref($href) {
$this->href = $href; $this->href = $href;
return $this; return $this;
@ -30,6 +42,11 @@ final class PHUIIconCircleView extends AphrontTagView {
return $this; return $this;
} }
public function setState($state) {
$this->state = $state;
return $this;
}
protected function getTagName() { protected function getTagName() {
$tag = 'span'; $tag = 'span';
if ($this->href) { if ($this->href) {
@ -54,6 +71,10 @@ final class PHUIIconCircleView extends AphrontTagView {
$classes[] = $this->size; $classes[] = $this->size;
} }
if ($this->state) {
$classes[] = 'phui-icon-circle-state';
}
return array( return array(
'href' => $this->href, 'href' => $this->href,
'class' => $classes, 'class' => $classes,
@ -61,8 +82,32 @@ final class PHUIIconCircleView extends AphrontTagView {
} }
protected function getTagContent() { protected function getTagContent() {
$state = null;
if ($this->state) {
$state = id(new PHUIIconView())
->setIcon($this->state.' '.$this->color)
->addClass('phui-icon-circle-state-icon');
}
return id(new PHUIIconView()) return id(new PHUIIconView())
->setIcon($this->icon); ->setIcon($this->icon)
->addClass('phui-icon-circle-icon')
->appendChild($state);
}
public static function getStateMap() {
return array(
self::STATE_FAIL => pht('Failure'),
self::STATE_INFO => pht('Information'),
self::STATE_STOP => pht('Stop'),
self::STATE_START => pht('Start'),
self::STATE_PAUSE => pht('Pause'),
self::STATE_SUCCESS => pht('Success'),
self::STATE_WARNING => pht('Warning'),
self::STATE_PLUS => pht('Plus'),
self::STATE_MINUS => pht('Minus'),
self::STATE_UNKNOWN => pht('Unknown'),
);
} }
} }

View file

@ -57,6 +57,7 @@ img.phui-image-disabled {
cursor: pointer; cursor: pointer;
background: transparent; background: transparent;
padding: 0; padding: 0;
position: relative;
} }
.phui-icon-circle.circle-medium { .phui-icon-circle.circle-medium {
@ -65,7 +66,21 @@ img.phui-image-disabled {
border-radius: 36px; border-radius: 36px;
} }
.phui-icon-circle .phui-icon-view { .phui-icon-circle.phui-icon-circle-state {
border-color: transparent;
background-color: {$bluebackground};
}
.phui-icon-circle.phui-icon-circle-state .phui-icon-circle-icon {
color: {$bluetext};
font-size: 16px;
}
a.phui-icon-circle.phui-icon-circle-state:hover {
border-color: transparent !important;
}
.phui-icon-circle .phui-icon-circle-icon {
height: 24px; height: 24px;
width: 24px; width: 24px;
font-size: 11px; font-size: 11px;
@ -74,7 +89,7 @@ img.phui-image-disabled {
cursor: pointer; cursor: pointer;
} }
.phui-icon-circle.circle-medium .phui-icon-view { .phui-icon-circle.circle-medium .phui-icon-circle-icon {
font-size: 18px; font-size: 18px;
line-height: 36px; line-height: 36px;
} }
@ -129,6 +144,21 @@ a.phui-icon-circle.hover-red:hover .phui-icon-view {
color: {$red}; color: {$red};
} }
a.phui-icon-circle .phui-icon-view.phui-icon-circle-state-icon {
position: absolute;
width: 14px;
height: 14px;
display: inline-block;
font-size: 12px;
right: -3px;
top: -4px;
text-shadow:
-1px -1px 0 #fff,
1px -1px 0 #fff,
-1px 1px 0 #fff,
1px 1px 0 #fff;
}
/* - Icon in a Square ------------------------------------------------------- */ /* - Icon in a Square ------------------------------------------------------- */
.phui-icon-view.phui-icon-square { .phui-icon-view.phui-icon-square {