| 1 |
<?php |
| 2 |
namespace Depicter\Document\Models\Common\Styles; |
| 3 |
|
| 4 |
|
| 5 |
use Depicter\Document\CSS\Breakpoints; |
| 6 |
|
| 7 |
class Border extends States |
| 8 |
{ |
| 9 |
/** |
| 10 |
* style name |
| 11 |
*/ |
| 12 |
const NAME = 'border'; |
| 13 |
|
| 14 |
/** |
| 15 |
* @var string |
| 16 |
*/ |
| 17 |
public $borderWidth = '1px'; |
| 18 |
|
| 19 |
/** |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
public $borderStyle = 'solid'; |
| 23 |
|
| 24 |
/** |
| 25 |
* @var string |
| 26 |
*/ |
| 27 |
public $borderColor = '#000'; |
| 28 |
|
| 29 |
public function set( $css ) { |
| 30 |
$devices = Breakpoints::names(); |
| 31 |
|
| 32 |
foreach ( $devices as $device ) { |
| 33 |
if ( isset( $this->{$device}->enable ) ) { |
| 34 |
|
| 35 |
// If it is disabled in a breakpoint other than default, generate a reset style for breakpoint |
| 36 |
if( $device !== 'default' && ! empty( $this->default->enable ) && ! $this->{$device}->enable ){ |
| 37 |
$css[$device][ self::NAME ] = 'none'; |
| 38 |
|
| 39 |
} elseif( $this->{$device}->enable ) { |
| 40 |
|
| 41 |
if( isset( $this->{$device}->top->value ) ){ |
| 42 |
if ( !empty( $this->{$device}->link ) ) { |
| 43 |
$css[$device]['border-width'] = $this->{$device}->top->value . $this->{$device}->top->unit; |
| 44 |
} else { |
| 45 |
$css[$device]['border-width'] = $this->{$device}->top->value . $this->{$device}->top->unit . " " . $this->{$device}->right->value . $this->{$device}->right->unit . " " . $this->{$device}->bottom->value . $this->{$device}->bottom->unit . " " . $this->{$device}->left->value . $this->{$device}->left->unit; |
| 46 |
} |
| 47 |
} elseif ( $device == 'default') { |
| 48 |
$css[$device]['border-width'] = $this->borderWidth; |
| 49 |
} |
| 50 |
|
| 51 |
if ( !empty($this->{$device}->style) ) { |
| 52 |
$css[$device]['border-style'] = $this->{$device}->style; |
| 53 |
} elseif ($device == 'default') { |
| 54 |
$css[$device]['border-style'] = $this->borderStyle; |
| 55 |
} |
| 56 |
|
| 57 |
if ( !empty( $this->{$device}->color ) ) { |
| 58 |
$css[$device]['border-color'] = $this->{$device}->color; |
| 59 |
} elseif ( $device == 'default' ) { |
| 60 |
$css[$device]['border-color'] = $this->borderColor; |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
return $css; |
| 67 |
} |
| 68 |
} |
| 69 |
|