| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace UiCoreElements\Utils; |
| 3 | 4 | |
| 4 | 5 | use Elementor\Controls_Manager; |
| 5 | 6 | use Elementor\Group_Control_Background; |
| @@ -7,25 +8,23 @@ | ||
| 7 | 8 | use Elementor\Group_Control_Box_Shadow; |
| 8 | 9 | |
| 9 | 10 | defined('ABSPATH') || exit(); |
| 10 | 11 | |
| 11 | -trait Grid_Trait { | |
| 12 | +trait Grid_Trait | |
| 13 | +{ | |
| 12 | 14 | |
| 13 | 15 | /** |
| 14 | 16 | * Registers the grid layout controls. |
| 15 | 17 | * |
| 16 | - * @param bool $maso Whether to enable masonry layout. (Default: true) | |
| 17 | - * @param array $maso_conditions The conditions for masonry layout. | |
| 18 | - * @param bool $legacy_maso Whether to use legacy masonry layout. | |
| 19 | - * @param bool/array $column_prefix Set a prefix class to be returned with the column value | |
| 20 | - * @param array $gap_conditions The conditions for columns. | |
| 18 | + * @param array $conditions Conditions for the grid layout controls. Eg: ['{control-slug}' => '{control-value}'] | |
| 21 | 19 | */ |
| 22 | - function TRAIT_register_grid_layout_controls() | |
| 20 | + function TRAIT_register_grid_layout_controls($conditions = []) | |
| 23 | 21 | { |
| 22 | + | |
| 24 | 23 | $this->add_responsive_control( |
| 25 | 24 | 'columns', |
| 26 | 25 | [ |
| 27 | - 'label' => __( 'Columns', 'uicore-elements' ), | |
| 26 | + 'label' => __('Columns', 'uicore-elements'), | |
| 28 | 27 | 'type' => Controls_Manager::SELECT, |
| 29 | 28 | 'desktop_default' => 3, |
| 30 | 29 | 'tablet_default' => 2, |
| 31 | 30 | 'mobile_default' => 1, |
| @@ -42,30 +41,32 @@ | ||
| 42 | 41 | 'selectors' => [ |
| 43 | 42 | '{{WRAPPER}} .ui-e-grid' => 'grid-template-columns: repeat({{VALUE}}, minmax(0, 1fr)); --ui-e-column-count: {{VALUE}};', // the var is used by masonry |
| 44 | 43 | '{{WRAPPER}} .ui-e-adv-grid' => 'grid-template-columns: repeat({{VALUE}}, minmax(0, 1fr))', // Old APG Suport |
| 45 | 44 | ], |
| 45 | + 'condition' => $conditions | |
| 46 | 46 | ] |
| 47 | 47 | ); |
| 48 | 48 | $this->add_responsive_control( |
| 49 | 49 | 'gap', |
| 50 | 50 | [ |
| 51 | - 'label' => esc_html__( 'Items Gap', 'uicore-elements' ), | |
| 51 | + 'label' => esc_html__('Items Gap', 'uicore-elements'), | |
| 52 | 52 | 'type' => Controls_Manager::SLIDER, |
| 53 | 53 | 'size_units' => ['px'], |
| 54 | - 'range' => [ | |
| 55 | - 'px' => [ | |
| 56 | - 'min' => 0, | |
| 57 | - 'max' => 200, | |
| 58 | - ], | |
| 59 | - ], | |
| 60 | - 'default' => [ | |
| 61 | - 'unit' => 'px', | |
| 62 | - 'size' => 20, | |
| 63 | - ], | |
| 54 | + 'range' => [ | |
| 55 | + 'px' => [ | |
| 56 | + 'min' => 0, | |
| 57 | + 'max' => 200, | |
| 58 | + ], | |
| 59 | + ], | |
| 60 | + 'default' => [ | |
| 61 | + 'unit' => 'px', | |
| 62 | + 'size' => 20, | |
| 63 | + ], | |
| 64 | 64 | 'selectors' => [ |
| 65 | 65 | '{{WRAPPER}} .ui-e-grid' => 'grid-gap: {{SIZE}}{{UNIT}};', |
| 66 | 66 | '{{WRAPPER}} .ui-e-adv-grid' => 'grid-gap: {{SIZE}}{{UNIT}};', // Old APG Suport |
| 67 | 67 | ], |
| 68 | + 'condition' => $conditions | |
| 68 | 69 | ] |
| 69 | 70 | ); |
| 70 | 71 | $this->add_control( |
| 71 | 72 | 'masonry', |
| @@ -71,14 +72,14 @@ | ||
| 71 | 72 | 'masonry', |
| 72 | 73 | [ |
| 73 | 74 | 'label' => __('Masonry', 'uicore-elements'), |
| 74 | 75 | 'type' => Controls_Manager::SWITCHER, |
| 75 | - 'prefix_class' => 'ui-e-maso-', | |
| 76 | 76 | 'selectors' => [ |
| 77 | 77 | '{{WRAPPER}} .ui-e-grid' => 'column-count: var(--ui-e-column-count); column-gap: {{gap.SIZE}}{{gap.UNIT}};', |
| 78 | 78 | '{{WRAPPER}} .ui-e-wrp' => 'margin-bottom: {{gap.SIZE}}{{gap.UNIT}};' |
| 79 | 79 | ], |
| 80 | - //'render_type' => 'template', | |
| 80 | + 'render_type' => 'template', | |
| 81 | + 'condition' => $conditions | |
| 81 | 82 | ] |
| 82 | 83 | ); |
| 83 | 84 | } |
| 84 | -} | |
| 85 | +} | |