2013-04-18 11:34:02 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PHUIBoxView extends AphrontTagView {
|
|
|
|
|
|
|
|
private $margin = array();
|
|
|
|
private $padding = array();
|
2013-08-26 11:53:11 -07:00
|
|
|
private $border = false;
|
2016-01-20 12:18:01 -08:00
|
|
|
private $color;
|
|
|
|
|
|
|
|
const BLUE = 'phui-box-blue';
|
|
|
|
const GREY = 'phui-box-grey';
|
2013-04-18 11:34:02 -07:00
|
|
|
|
|
|
|
public function addMargin($margin) {
|
|
|
|
$this->margin[] = $margin;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addPadding($padding) {
|
|
|
|
$this->padding[] = $padding;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-08-26 11:53:11 -07:00
|
|
|
public function setBorder($border) {
|
|
|
|
$this->border = $border;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-01-20 12:18:01 -08:00
|
|
|
public function setColor($color) {
|
|
|
|
$this->color = $color;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-09-06 10:42:44 -07:00
|
|
|
protected function getTagAttributes() {
|
2014-02-19 23:05:42 -08:00
|
|
|
require_celerity_resource('phui-box-css');
|
2013-04-18 11:34:02 -07:00
|
|
|
$outer_classes = array();
|
|
|
|
$outer_classes[] = 'phui-box';
|
2016-01-20 12:18:01 -08:00
|
|
|
|
2013-08-26 11:53:11 -07:00
|
|
|
if ($this->border) {
|
|
|
|
$outer_classes[] = 'phui-box-border';
|
|
|
|
}
|
2016-01-20 12:18:01 -08:00
|
|
|
|
2013-04-18 11:34:02 -07:00
|
|
|
foreach ($this->margin as $margin) {
|
|
|
|
$outer_classes[] = $margin;
|
|
|
|
}
|
2016-01-20 12:18:01 -08:00
|
|
|
|
2014-02-19 23:05:42 -08:00
|
|
|
foreach ($this->padding as $padding) {
|
|
|
|
$outer_classes[] = $padding;
|
|
|
|
}
|
2016-01-20 12:18:01 -08:00
|
|
|
|
|
|
|
if ($this->color) {
|
|
|
|
$outer_classes[] = $this->color;
|
|
|
|
}
|
|
|
|
|
2013-09-06 10:42:44 -07:00
|
|
|
return array('class' => $outer_classes);
|
|
|
|
}
|
|
|
|
|
2015-01-14 06:54:39 +11:00
|
|
|
protected function getTagName() {
|
2013-09-06 10:42:44 -07:00
|
|
|
return 'div';
|
|
|
|
}
|
|
|
|
|
2015-01-14 06:54:39 +11:00
|
|
|
protected function getTagContent() {
|
2014-02-19 23:05:42 -08:00
|
|
|
return $this->renderChildren();
|
2013-04-18 11:34:02 -07:00
|
|
|
}
|
|
|
|
}
|