PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Document / Models / Common / Styles / Border.php

Border.php in Depicter — Popup & Slider Builder trunk, at app/src/Document/Models/Common/Styles/Border.php

67 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Document\Models\Common\Styles;
3
4 use Depicter\Document\CSS\Breakpoints;
5 use Depicter\Document\Models\Traits\HoverAbleStyleTrait;
6
7 class Border extends States
8 {
9 use HoverAbleStyleTrait;
10
11 /**
12 * style name
13 */
14 const NAME = 'border';
15
16 /**
17 * @var string
18 */
19 public $borderWidth = '1px';
20
21 /**
22 * @var string
23 */
24 public $borderStyle = 'solid';
25
26 /**
27 * @var string
28 */
29 public $borderColor = '#000';
30
31 public function set( $css ) {
32 $devices = Breakpoints::names();
33
34 foreach ( $devices as $device ) {
35
36 // If in Hover state and Hover is enabled for a breakpoint, just set the border color and skip the other properties
37 if( $this->isHoverEnabled( $device ) ){
38 if ( !empty( $this->{$device}->color ) ) {
39 $css[ $device ]['border-color'] = $this->{$device}->color;
40 }
41
42 // If in "Normal" state and properties for a breakpoint are available, generate appropriate styles
43 } elseif ( $this->isBreakpointEnabled( $device ) ) {
44 if( isset( $this->{$device}->top->value ) ){
45 if ( !empty( $this->{$device}->link ) ) {
46 $css[$device]['border-width'] = $this->{$device}->top->value . $this->{$device}->top->unit;
47 } else {
48 $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;
49 }
50 }
51
52 // make sure to set default border styles if not defined
53 $css[ $device ]['border-width'] = $css[ $device ]['border-width'] ?? "1px";
54 $css[ $device ]['border-style'] = $this->{$device}->style ?? "solid";
55 $css[ $device ]['border-color'] = $this->{$device}->color ?? "#000";
56
57 // If breakpoint is disabled in normal state, reset the border style
58 } elseif( $this->isBreakpointDisabled( $device ) ){
59 $css[ $device ][ self::NAME ] = "none";
60 }
61
62 }
63
64 return $css;
65 }
66 }
67