| 1 |
<?php |
| 2 |
namespace Depicter\Document\Models\Common\Styles; |
| 3 |
|
| 4 |
|
| 5 |
use Depicter\Document\CSS\Breakpoints; |
| 6 |
|
| 7 |
class Flex extends States |
| 8 |
{ |
| 9 |
/** |
| 10 |
* style name |
| 11 |
*/ |
| 12 |
const NAME = 'flex'; |
| 13 |
|
| 14 |
/** |
| 15 |
* @var int |
| 16 |
*/ |
| 17 |
public $flex = 1; |
| 18 |
|
| 19 |
/** |
| 20 |
* @var string|null |
| 21 |
*/ |
| 22 |
public $alignSelf; |
| 23 |
|
| 24 |
public function set( $css ) { |
| 25 |
$devices = Breakpoints::names(); |
| 26 |
foreach ( $devices as $device ) { |
| 27 |
if ( !empty( $this->{$device}->columnGap ) ) { |
| 28 |
$css[ $device ]['column-gap'] = $this->{$device}->columnGap . 'px'; |
| 29 |
} |
| 30 |
if ( !empty( $this->{$device}->display ) ) { |
| 31 |
$css[ $device ]['display'] = $this->{$device}->display; |
| 32 |
} |
| 33 |
if ( !empty( $this->{$device}->flex ) ) { |
| 34 |
$css[ $device ]['flex'] = $this->{$device}->flex ?? $this->flex; |
| 35 |
} |
| 36 |
if ( !empty( $this->{$device} ) && !empty( $this->{$device}->rowGap ) ) { |
| 37 |
$css[ $device ]['row-gap'] = $this->{$device}->rowGap . 'px'; |
| 38 |
} |
| 39 |
if ( !empty( $this->{$device}->alignSelf ) ) { |
| 40 |
$css[ $device ]['align-self'] = $this->{$device}->alignSelf; |
| 41 |
} |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
return $css; |
| 46 |
} |
| 47 |
} |
| 48 |
|