| 1 |
<?php |
| 2 |
namespace Depicter\Document\Models\Elements; |
| 3 |
|
| 4 |
use Depicter\Front\Symbols; |
| 5 |
use Depicter\Html\Html; |
| 6 |
|
| 7 |
class Rating extends Svg { |
| 8 |
|
| 9 |
/** |
| 10 |
* Render arrow markup |
| 11 |
* |
| 12 |
* @return \TypeRocket\Html\Html|void |
| 13 |
* @throws \JsonMapper_Exception |
| 14 |
*/ |
| 15 |
public function render() { |
| 16 |
|
| 17 |
\Depicter::symbolsProvider()->add( $this->options->rating->symbol ); |
| 18 |
|
| 19 |
$args = $this->getDefaultAttributes(); |
| 20 |
$args['data-rate-value'] = $this->maybeReplaceDataSheetTags( $this->options->content ); |
| 21 |
if ( $this->options->rating->round ) { |
| 22 |
$args['data-rate-value'] = round( $args['data-rate-value'] ); |
| 23 |
} |
| 24 |
$args['data-symbol'] = $this->options->rating->symbol; |
| 25 |
|
| 26 |
return Html::div( $args, "\n" ); |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
/** |
| 31 |
* Get list of selector and CSS for element |
| 32 |
* |
| 33 |
* @return array |
| 34 |
* @throws \JsonMapper_Exception |
| 35 |
*/ |
| 36 |
public function getSelectorAndCssList(){ |
| 37 |
$this->selectorCssList = parent::getSelectorAndCssList(); |
| 38 |
|
| 39 |
foreach ( $this->devices as $device ) { |
| 40 |
if ( !empty( $this->options->rating->styles->trackColor->{$device} ) ){ |
| 41 |
$this->selectorCssList[ '.' . $this->getSelector() . ' .depicter-track-container' ][$device]['fill'] = $this->options->rating->styles->trackColor->{$device}; |
| 42 |
} |
| 43 |
|
| 44 |
if ( !empty( $this->options->rating->hover->trackColor->{$device} ) ){ |
| 45 |
$this->selectorCssList[ '.' . $this->getSelector() . ':hover .depicter-track-container' ][$device]['fill'] = $this->options->rating->hover->trackColor->{$device}; |
| 46 |
} |
| 47 |
|
| 48 |
if ( !empty( $this->options->rating->styles->patternColor->{$device} ) ){ |
| 49 |
$this->selectorCssList[ '.' . $this->getSelector() . ' .depicter-symbol-container' ][$device]['fill'] = $this->options->rating->styles->patternColor->{$device}; |
| 50 |
} |
| 51 |
|
| 52 |
if ( !empty( $this->options->rating->hover->patternColor->{$device} ) ){ |
| 53 |
$this->selectorCssList[ '.' . $this->getSelector() . ':hover .depicter-symbol-container' ][$device]['fill'] = $this->options->rating->hover->patternColor->{$device}; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
return $this->selectorCssList; |
| 58 |
} |
| 59 |
} |
| 60 |
|