| 1 |
<?php |
| 2 |
namespace Depicter\Document\Models\Elements; |
| 3 |
|
| 4 |
use Depicter\Document\Models\Element; |
| 5 |
use Depicter\Html\Html; |
| 6 |
|
| 7 |
class LineTimer extends Element { |
| 8 |
|
| 9 |
/** |
| 10 |
* render lineTimer markup |
| 11 |
* @return \TypeRocket\Html\Html|void |
| 12 |
*/ |
| 13 |
public function render() { |
| 14 |
$args = $this->getDefaultAttributes(); |
| 15 |
return Html::div( $args ); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* get timer bar selector |
| 20 |
* @return string |
| 21 |
*/ |
| 22 |
protected function getTimerBarSelector() { |
| 23 |
return '.' . $this->getSelector() . ' .depicter-timer-bar'; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* get timer bar styles |
| 28 |
* @return array |
| 29 |
*/ |
| 30 |
protected function getTimerBarCss() { |
| 31 |
$styles = []; |
| 32 |
|
| 33 |
foreach ( $this->devices as $device ) { |
| 34 |
if ( isset( $this->options->lineTimer->styles->color->{$device} ) ) { |
| 35 |
$styles[ $device ]['background-color'] = $this->options->lineTimer->styles->color->{$device}; |
| 36 |
} |
| 37 |
|
| 38 |
if ( isset( $this->options->lineTimer->styles->radius->{$device} ) ) { |
| 39 |
$borderRadius = $this->options->lineTimer->styles->radius->{$device}->value; |
| 40 |
$styles[ $device ]['border-radius'] = $borderRadius->topRight->value . $borderRadius->topRight->unit ." " . $borderRadius->bottomRight->value . $borderRadius->bottomRight->unit ." " .$borderRadius->bottomLeft->value . $borderRadius->bottomLeft->unit ." ". $borderRadius->topLeft->value . $borderRadius->topLeft->unit; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
return $styles; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Get list of selector and CSS for element |
| 49 |
* |
| 50 |
* @return array |
| 51 |
* @throws \JsonMapper_Exception |
| 52 |
*/ |
| 53 |
public function getSelectorAndCssList(){ |
| 54 |
parent::getSelectorAndCssList(); |
| 55 |
|
| 56 |
$this->selectorCssList[ $this->getTimerBarSelector() ] = $this->getTimerBarCss(); |
| 57 |
|
| 58 |
return $this->selectorCssList; |
| 59 |
} |
| 60 |
} |
| 61 |
|