| 1 |
<?php |
| 2 |
/** |
| 3 |
* Gutenify Count Down Block style file. |
| 4 |
* |
| 5 |
* @package Gutenify |
| 6 |
*/ |
| 7 |
|
| 8 |
// Exit if accessed directly. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
function gutenify_count_down_style( $blockId, $attributes ){ |
| 14 |
$containerWidthKey = 'containerWidth'; |
| 15 |
|
| 16 |
// Wrapper Styles. |
| 17 |
$containerDesktopWidth = ! empty( $attributes[ $containerWidthKey ]['desktop']['value'] ) ? absint( $attributes[ $containerWidthKey ]['desktop']['value'] ) : ''; |
| 18 |
$containerDesktopWidthUnit = ! empty( $attributes[ $containerWidthKey ]['desktop']['unit'] ) ? $attributes[ $containerWidthKey ]['desktop']['unit'] : '%'; |
| 19 |
|
| 20 |
$containerTabletWidth = ! empty( $attributes[ $containerWidthKey ]['tablet']['value'] ) ? absint( $attributes[ $containerWidthKey ]['tablet']['value'] ) : ''; |
| 21 |
$containerTabletWidthUnit = ! empty( $attributes[ $containerWidthKey ]['tablet']['unit'] ) ? $attributes[ $containerWidthKey ]['tablet']['unit'] : '%'; |
| 22 |
|
| 23 |
$containerMobileWidth = ! empty( $attributes[ $containerWidthKey ]['mobile']['value'] ) ? absint( $attributes[ $containerWidthKey ]['mobile']['value'] ) : ''; |
| 24 |
$containerMobileWidthUnit = ! empty( $attributes[ $containerWidthKey ]['mobile']['unit'] ) ? $attributes[ $containerWidthKey ]['mobile']['unit'] : '%'; |
| 25 |
|
| 26 |
// Positon |
| 27 |
$counterPosition = ! empty( $attributes['counterPosition'] ) ? $attributes['counterPosition'] : 'center'; |
| 28 |
$counterPositionRight = 'center' === $counterPosition || 'right' === $counterPosition ? 'auto' : 0; |
| 29 |
$counterPositionLeft = 'center' === $counterPosition || 'left' === $counterPosition ? 'auto' : 0; |
| 30 |
|
| 31 |
// Box Background |
| 32 |
$boxBackgroundColor = ! empty( $attributes['backgroundAttrs']['color'] ) ? $attributes['backgroundAttrs']['color'] : '#fff'; |
| 33 |
$boxBorderColor = ! empty( $attributes['borderAttrs']['color'] ) ? $attributes['borderAttrs']['color'] : '#fff'; |
| 34 |
$boxBorderWidth = ! empty( $attributes['borderAttrs']['width'] ) ? $attributes['borderAttrs']['width'] : 0; |
| 35 |
|
| 36 |
// Digit style |
| 37 |
$digitFontFamily = ! empty( $attributes['digitAttrs']['typography']['fontFamily'] ) ? $attributes['digitAttrs']['typography']['fontFamily'] . ', sans-serif' : false; |
| 38 |
$digitColor = ! empty( $attributes['digitAttrs']['color'] ) ? $attributes['digitAttrs']['color'] : false; |
| 39 |
$titleColor = ! empty( $attributes['titleAttrs']['color'] ) ? $attributes['titleAttrs']['color'] : false; |
| 40 |
|
| 41 |
return '#' . $blockId . ' { |
| 42 |
'. ( ! empty( $containerDesktopWidth ) ? 'width: ' . $containerDesktopWidth . $containerDesktopWidthUnit.';' : '' ).' |
| 43 |
margin-top: 0; |
| 44 |
margin-bottom: 0; |
| 45 |
margin-right: ' . $counterPositionLeft . '; |
| 46 |
margin-left: ' . $counterPositionRight . '; |
| 47 |
} |
| 48 |
|
| 49 |
#' . $blockId . ' .time-part{ |
| 50 |
background: '.$boxBackgroundColor.'; |
| 51 |
border:'.$boxBorderWidth.'px solid '.$boxBorderColor.'; |
| 52 |
margin-left:'. ( ! empty( $attributes['boxSpacing']['desktop']['value'] ) ? $attributes['boxSpacing']['desktop']['value'].'px;' : '0' ).'; |
| 53 |
} |
| 54 |
|
| 55 |
#' . $blockId . ' .time-part:first-child{ |
| 56 |
margin-left:0; |
| 57 |
} |
| 58 |
|
| 59 |
#' . $blockId . ' .time-part span{ |
| 60 |
' . Gutenify_Helpers::typography_style( $attributes['digitAttrs']['typography'], 'desktop' ) . ' |
| 61 |
' . ( ! empty( $digitColor ) ? 'color: ' . $digitColor . ';' : '' ) . ' |
| 62 |
} |
| 63 |
|
| 64 |
#' . $blockId . ' .time-part .smalltext{ |
| 65 |
' . Gutenify_Helpers::typography_style( $attributes['titleAttrs']['typography'], 'desktop' ) . ' |
| 66 |
' . ( ! empty( $titleColor ) ? 'color: ' . $titleColor . ';' : '' ) . ' |
| 67 |
} |
| 68 |
|
| 69 |
@media only screen and (max-width: 768px) { |
| 70 |
#' . $blockId . ' { |
| 71 |
'. ( ! empty( $containerTabletWidth ) ? 'width: ' . $containerTabletWidth . $containerTabletWidthUnit.';' : '' ).' |
| 72 |
} |
| 73 |
|
| 74 |
#' . $blockId . ' .time-part{ |
| 75 |
margin-left:'. ( ! empty( $attributes['boxSpacing']['tablet']['value'] ) ? $attributes['boxSpacing']['tablet']['value'].'px;' : '0' ).'; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
#' . $blockId . ' .time-part span{ |
| 80 |
' . Gutenify_Helpers::typography_style( $attributes['digitAttrs']['typography'], 'tablet' ) . ' |
| 81 |
} |
| 82 |
|
| 83 |
#' . $blockId . ' .time-part .smalltext{ |
| 84 |
' . Gutenify_Helpers::typography_style( $attributes['titleAttrs']['typography'], 'tablet' ) . ' |
| 85 |
} |
| 86 |
} |
| 87 |
@media only screen and (max-width: 360px) { |
| 88 |
#' . $blockId . ' { |
| 89 |
'. ( ! empty( $containerMobileWidth ) ? 'width: ' . $containerMobileWidth . $containerMobileWidthUnit.';' : '' ).' |
| 90 |
} |
| 91 |
#' . $blockId . ' .time-part{ |
| 92 |
margin-left:'. ( ! empty( $attributes['boxSpacing']['mobile']['value'] ) ? $attributes['boxSpacing']['mobile']['value'].'px;' : '0' ).'; |
| 93 |
} |
| 94 |
|
| 95 |
#' . $blockId . ' .time-part span{ |
| 96 |
' . Gutenify_Helpers::typography_style( $attributes['digitAttrs']['typography'], 'mobile' ) . ' |
| 97 |
} |
| 98 |
#' . $blockId . ' .time-part .smalltext{ |
| 99 |
' . Gutenify_Helpers::typography_style( $attributes['titleAttrs']['typography'], 'mobile' ) . ' |
| 100 |
} |
| 101 |
}'; |
| 102 |
} |