Generics
4 years ago
Props
1 year ago
BlockStyleRender.php
4 years ago
DynamicStyles.php
3 years ago
GlobalStyleRender.php
2 years ago
MainAttribute.php
4 years ago
ParserUtils.php
2 years ago
StyleManager.php
2 years ago
StyleParser.php
2 years ago
StyleRender.php
2 years ago
Utils.php
4 years ago
DynamicStyles.php
62 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Kubio\Core\StyleManager; |
| 5 | |
| 6 | use Kubio\Core\LodashBasic; |
| 7 | |
| 8 | class DynamicStyles { |
| 9 | |
| 10 | |
| 11 | public static function hSpaceParent( $spaceByMedia ) { |
| 12 | $style = array(); |
| 13 | foreach ( $spaceByMedia as $media => $mediaValue ) { |
| 14 | $style[ $media ] = array(); |
| 15 | if ( isset( $mediaValue['value'] ) ) { |
| 16 | $halfSpace = number_format( $mediaValue['value'] / 2, 0 ); |
| 17 | $style[ $media ]['marginLeft'] = -$halfSpace . 'px'; |
| 18 | $style[ $media ]['marginRight'] = -$halfSpace . 'px'; |
| 19 | } |
| 20 | } |
| 21 | return $style; |
| 22 | } |
| 23 | |
| 24 | public static function hSpace( $spaceByMedia ) { |
| 25 | $style = array(); |
| 26 | |
| 27 | foreach ( $spaceByMedia as $media => $mediaValue ) { |
| 28 | $style[ $media ] = array(); |
| 29 | if ( isset( $mediaValue['value'] ) ) { |
| 30 | $halfSpace = number_format( $mediaValue['value'] / 2, 0 ); |
| 31 | $style[ $media ]['paddingLeft'] = $halfSpace . 'px'; |
| 32 | $style[ $media ]['paddingRight'] = $halfSpace . 'px'; |
| 33 | } |
| 34 | } |
| 35 | return $style; |
| 36 | } |
| 37 | |
| 38 | public static function vSpace( $spaceByMedia, $negative = false ) { |
| 39 | $style = array(); |
| 40 | foreach ( $spaceByMedia as $media => $mediaValue ) { |
| 41 | $style[ $media ] = array(); |
| 42 | if ( isset( $mediaValue['value'] ) ) { |
| 43 | $style[ $media ]['marginBottom'] = ( $negative ? '-' : '' ) . $mediaValue['value'] . 'px'; |
| 44 | } |
| 45 | } |
| 46 | return $style; |
| 47 | } |
| 48 | |
| 49 | public static function typographyHolders( $typographyHoldersByMedia ) { |
| 50 | |
| 51 | $typographyByMedia = array(); |
| 52 | foreach ( $typographyHoldersByMedia as $media => $holders ) { |
| 53 | $typographyByMedia[ $media ] = array( |
| 54 | 'typography' => array( |
| 55 | 'holders' => $holders, |
| 56 | ), |
| 57 | ); |
| 58 | } |
| 59 | return $typographyByMedia; |
| 60 | } |
| 61 | } |
| 62 |