← All changes
|
modules/atomic-widgets/elements/flexbox/flexbox.php
+27
-3
4.0.9
→
4.3.0-beta3
View file →
| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\AtomicWidgets\Elements\Flexbox; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Element_Base; |
| 5 | +use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Element_Template; | |
| 6 | +use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer; | |
| 5 | 7 | use Elementor\Modules\AtomicWidgets\PropDependencies\Manager as Dependency_Manager; |
| 6 | 8 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 7 | 9 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 8 | 10 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| @@ -20,8 +22,10 @@ | ||
| 20 | 22 | exit; // Exit if accessed directly. |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | 25 | class Flexbox extends Atomic_Element_Base { |
| 26 | + use Has_Element_Template; | |
| 27 | + | |
| 24 | 28 | const BASE_STYLE_KEY = 'base'; |
| 25 | 29 | |
| 26 | 30 | public function __construct( $data = [], $args = null ) { |
| 27 | 31 | parent::__construct( $data, $args ); |
| @@ -31,8 +35,10 @@ | ||
| 31 | 35 | public static function get_type() { |
| 32 | 36 | return 'e-flexbox'; |
| 33 | 37 | } |
| 34 | 38 | |
| 39 | + public static $widget_description = 'A container (div) with flex display and flex-direction row by default.'; | |
| 40 | + | |
| 35 | 41 | public static function get_element_type(): string { |
| 36 | 42 | return 'e-flexbox'; |
| 37 | 43 | } |
| 38 | 44 | |
| @@ -40,9 +46,9 @@ | ||
| 40 | 46 | return esc_html__( 'Flexbox', 'elementor' ); |
| 41 | 47 | } |
| 42 | 48 | |
| 43 | 49 | public function get_keywords() { |
| 44 | - return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 50 | + return [ 'ato', 'atom', 'atoms', 'atomic', 'container', 'wrapper', 'section', 'row', 'column', 'flex', 'layout' ]; | |
| 45 | 51 | } |
| 46 | 52 | |
| 47 | 53 | public function get_icon() { |
| 48 | 54 | return 'eicon-flexbox'; |
| @@ -47,8 +53,12 @@ | ||
| 47 | 53 | public function get_icon() { |
| 48 | 54 | return 'eicon-flexbox'; |
| 49 | 55 | } |
| 50 | 56 | |
| 57 | + public static function get_computed_html_tag( array $settings ): string { | |
| 58 | + return Html_Tag_Computer::compute( $settings, 'div' ); | |
| 59 | + } | |
| 60 | + | |
| 51 | 61 | protected static function define_props_schema(): array { |
| 52 | 62 | $tag_dependencies = Dependency_Manager::make( Dependency_Manager::RELATION_AND ) |
| 53 | 63 | ->where( [ |
| 54 | 64 | 'operator' => 'ne', |
| @@ -71,11 +81,11 @@ | ||
| 71 | 81 | return [ |
| 72 | 82 | 'classes' => Classes_Prop_Type::make() |
| 73 | 83 | ->default( [] ), |
| 74 | 84 | 'tag' => String_Prop_Type::make() |
| 75 | - ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer', 'a', 'button' ] ) | |
| 85 | + ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer', 'a', 'button', 'main', 'nav' ] ) | |
| 76 | 86 | ->default( 'div' ) |
| 77 | - ->description( 'The HTML tag for the flexbox container. Could be div, header, section, article, aside, footer, or a (link).' ) | |
| 87 | + ->description( 'The HTML tag for the flexbox container. One of: div, header, section, article, aside, footer, main, nav, a (link), or button.' ) | |
| 78 | 88 | ->set_dependencies( $tag_dependencies ), |
| 79 | 89 | 'link' => Link_Prop_Type::make(), |
| 80 | 90 | 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), |
| 81 | 91 | ]; |
| @@ -114,8 +124,16 @@ | ||
| 114 | 124 | [ |
| 115 | 125 | 'value' => 'footer', |
| 116 | 126 | 'label' => 'Footer', |
| 117 | 127 | ], |
| 128 | + [ | |
| 129 | + 'value' => 'main', | |
| 130 | + 'label' => 'Main', | |
| 131 | + ], | |
| 132 | + [ | |
| 133 | + 'value' => 'nav', | |
| 134 | + 'label' => 'Nav', | |
| 135 | + ], | |
| 118 | 136 | ]) |
| 119 | 137 | ->set_label( esc_html__( 'HTML Tag', 'elementor' ) ) |
| 120 | 138 | ->set_fallback_labels( [ |
| 121 | 139 | 'a' => 'a (link)', |
| @@ -179,6 +197,12 @@ | ||
| 179 | 197 | $attributes = array_merge( $attributes, $link_attributes ); |
| 180 | 198 | } |
| 181 | 199 | |
| 182 | 200 | $this->add_render_attribute( '_wrapper', array_merge( $initial_attributes, $attributes ) ); |
| 201 | + } | |
| 202 | + | |
| 203 | + protected function get_templates(): array { | |
| 204 | + return [ | |
| 205 | + 'elementor/elements/flexbox' => __DIR__ . '/flexbox.html.twig', | |
| 206 | + ]; | |
| 183 | 207 | } |
| 184 | 208 | } |