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