PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.6
Kubio AI Page Builder v2.8.6
2.9.0 2.8.6 2.8.5 2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / build / block-library / blocks / navigation / index.php
kubio / build / block-library / blocks / navigation Last commit date
blocks 2 years ago config 4 years ago index.php 1 year ago
index.php
150 lines
1 <?php
2
3 namespace Kubio\Blocks;
4
5 use Kubio\Core\Blocks\BlockContainerBase;
6 use Kubio\Core\LodashBasic;
7 use Kubio\Core\Registry;
8 use Kubio\Core\Styles\FlexAlign;
9 use Kubio\Core\Utils;
10
11
12 class NavigationTopBarBlock extends SectionBlock {
13
14 }
15
16 class NavigationBlock extends BlockContainerBase {
17
18 const NAVIGATION_CONTAINER = 'outer';
19 const NAVIGATION_SECTION = 'section';
20
21
22 public function mapPropsToElements() {
23 $overlap = $this->getProp( 'overlap' );
24 $verticalAlignByMedia = $this->getPropByMedia( 'verticalAlign' );
25 $verticalAlignClasses = FlexAlign::getVAlignClasses( $verticalAlignByMedia );
26
27 $map = array();
28 $containerClasses = array();
29 if ( $overlap ) {
30 $containerClasses[] = 'h-navigation_overlap';
31 }
32
33 $map[ self::NAVIGATION_CONTAINER ] = LodashBasic::merge(
34 $overlap ? Utils::useJSComponentProps( 'overlap', $overlap ) : array(),
35 array(
36 'className' => $containerClasses,
37 )
38 );
39
40 return $map;
41 }
42 }
43
44
45 class NavigationSectionBlock extends BlockContainerBase {
46
47 const NAVIGATION = 'nav';
48 const NAVIGATION_SECTION = 'nav-section';
49
50 // move to json
51 const IMMEDIATELY = 'immediately';
52 const AFTER_HERO = 'afterHero';
53 static $WidthTypesClasses = array(
54 'full-width' => 'h-section-fluid-container',
55 'boxed' => 'h-section-boxed-container',
56 );
57
58 public function mapPropsToElements() {
59 $navigation_block = Registry::getInstance()->getLastBlockOfName( 'kubio/navigation' );
60
61 $width = $navigation_block->getProp( 'width', 'boxed' );
62 $map = array();
63
64 $map[ self::NAVIGATION_SECTION ] = array( 'className' => self::$WidthTypesClasses[ $width ] );
65 $map[ self::NAVIGATION ] = LodashBasic::merge(
66 Utils::useJSComponentProps( 'navigation', $this->navigationScriptExport( $navigation_block ) ),
67 array()
68 );
69
70 return $map;
71 }
72
73 public function navigationScriptExport( $block ) {
74 return array(
75 'sticky' => $this->stickyExport( $block ),
76 'overlap' => $block->getProp( 'overlap' ),
77 );
78 }
79
80 public function stickyExport( $block ) {
81 $isSticky = $block->getProp( 'sticky', false );
82
83 if ( ! $isSticky ) {
84 return false;
85 }
86 $stickyStartAt = $block->getProp( 'stickyStartAt' );
87 $enableAnimation = $stickyStartAt === self::AFTER_HERO;
88
89 $animationName = $block->getProp( 'animation.name' );
90 $animationDuration = $block->getStyle(
91 'animation.duration.value',
92 0,
93 array(
94 'styledComponent' => NavigationBlock::NAVIGATION_SECTION,
95 'media' => 'desktop',
96 'ancestor' => '',
97 )
98 );
99
100 return array(
101 'startAfterNode' => array(
102 'enabled' => $enableAnimation,
103 ),
104 'animations' => array(
105 'enabled' => $enableAnimation,
106 'duration' => $animationDuration,
107 'name' => $animationName,
108 ),
109 );
110 }
111 }
112
113
114 class NavigationItemsBlock extends BlockContainerBase {
115
116 const NAVIGATION_CONTAINER = 'outer';
117
118 public function mapPropsToElements() {
119 $map = array();
120 $map[ self::NAVIGATION_CONTAINER ] = array();
121
122 return $map;
123 }
124 }
125
126 class NavigationStickyItemsBlock extends BlockContainerBase {
127
128 const NAVIGATION_CONTAINER = 'outer';
129
130 public function mapPropsToElements() {
131 $navigation_block = Registry::getInstance()->getLastBlockOfName( 'kubio/navigation' );
132 $isSticky = $navigation_block->getProp( 'sticky', false );
133 $map = array();
134 $map[ self::NAVIGATION_CONTAINER ] = array(
135 'shouldRender' => $isSticky,
136 'style' => array(
137 'display' => 'none',
138 ),
139 );
140
141 return $map;
142 }
143 }
144
145 Registry::registerBlock( __DIR__ . '/blocks/navigation', NavigationBlock::class );
146 Registry::registerBlock( __DIR__ . '/blocks/navigation-section', NavigationSectionBlock::class );
147 Registry::registerBlock( __DIR__ . '/blocks/navigation-normal', NavigationItemsBlock::class );
148 Registry::registerBlock( __DIR__ . '/blocks/navigation-sticky', NavigationStickyItemsBlock::class );
149 Registry::registerBlock( __DIR__ . '/blocks/navigation-top-bar', NavigationTopBarBlock::class );
150