Skip to content

Commit 424ced3

Browse files
committed
[ButtonGroup] Refactor
1 parent 7b9bdfe commit 424ced3

File tree

1 file changed

+98
-127
lines changed

1 file changed

+98
-127
lines changed

widgets/buttongroup.php

Lines changed: 98 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -82,46 +82,7 @@ protected function _register_controls() {
8282
],
8383
]
8484
);
85-
86-
$repeater->add_control(
87-
'button_type',
88-
[
89-
'label' => __('Button Type', 'mighty'),
90-
'type' => \Elementor\Controls_Manager::SELECT,
91-
'default' => 'ma-btn-primary',
92-
'options' => [
93-
'ma-btn-primary' => __('Primary', 'mighty'),
94-
'ma-btn-secondary' => __('Secondary', 'mighty'),
95-
'ma-btn-success' => __('Success', 'mighty'),
96-
'ma-btn-warning' => __('Warning', 'mighty'),
97-
'ma-btn-danger' => __('Danger', 'mighty'),
98-
'ma-btn-info' => __('Info', 'mighty'),
99-
],
100-
]
101-
);
102-
103-
$repeater->add_control(
104-
'button_size',
105-
[
106-
'label' => __('Button Size', 'mighty'),
107-
'type' => \Elementor\Controls_Manager::SELECT,
108-
'default' => 'ma-btn-md',
109-
'options' => [
110-
'ma-btn-sm' => __('Small', 'mighty'),
111-
'ma-btn-md' => __('Medium', 'mighty'),
112-
'ma-btn-lg' => __('Large', 'mighty'),
113-
],
114-
]
115-
);
116-
117-
$repeater->add_control(
118-
'hover_animation',
119-
[
120-
'label' => __('Hover Animation', 'mighty'),
121-
'type' => \Elementor\Controls_Manager::HOVER_ANIMATION,
122-
]
123-
);
124-
85+
12586
$repeater->add_control(
12687
'button_icon',
12788
[
@@ -130,7 +91,7 @@ protected function _register_controls() {
13091
'type' => \Elementor\Controls_Manager::ICONS,
13192
]
13293
);
133-
94+
13495
$repeater->add_control(
13596
'button_icon_align',
13697
[
@@ -187,19 +148,34 @@ protected function _register_controls() {
187148
);
188149

189150
$repeater->add_control(
190-
'button_css_id',
151+
'button_type',
191152
[
192-
'label' => __('HTML ID', 'mighty'),
193-
'type' => Controls_Manager::TEXT,
194-
'default' => __('', 'mighty'),
153+
'label' => __('Button Type', 'mighty'),
154+
'type' => \Elementor\Controls_Manager::SELECT,
155+
'default' => 'ma-btn-primary',
156+
'options' => [
157+
'ma-btn-primary' => __('Primary', 'mighty'),
158+
'ma-btn-secondary' => __('Secondary', 'mighty'),
159+
'ma-btn-success' => __('Success', 'mighty'),
160+
'ma-btn-warning' => __('Warning', 'mighty'),
161+
'ma-btn-danger' => __('Danger', 'mighty'),
162+
'ma-btn-info' => __('Info', 'mighty'),
163+
],
164+
'separator' => 'before',
195165
]
196166
);
197167

198168
$repeater->add_control(
199-
'button_css_class',
169+
'button_size',
200170
[
201-
'label' => __('CSS Class', 'mighty'),
202-
'type' => Controls_Manager::TEXT,
171+
'label' => __('Button Size', 'mighty'),
172+
'type' => \Elementor\Controls_Manager::SELECT,
173+
'default' => 'ma-btn-md',
174+
'options' => [
175+
'ma-btn-sm' => __('Small', 'mighty'),
176+
'ma-btn-md' => __('Medium', 'mighty'),
177+
'ma-btn-lg' => __('Large', 'mighty'),
178+
],
203179
]
204180
);
205181

@@ -240,37 +216,6 @@ protected function _register_controls() {
240216
]
241217
);
242218

243-
// $repeater->add_group_control(
244-
// Group_Control_Background::get_type(),
245-
// [
246-
// 'name' => 'buttongroup_gradient_color',
247-
// 'label' => __( 'Gradient', 'mighty' ),
248-
// 'types' => [ 'classic', 'gradient' ],
249-
// 'selector' => '{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a',
250-
// ]
251-
// );
252-
253-
$repeater->add_group_control(
254-
Group_Control_Border::get_type(),
255-
[
256-
'name' => 'border',
257-
'label' => __( 'Border', 'mighty' ),
258-
'selector' => '{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a',
259-
]
260-
);
261-
262-
$repeater->add_control(
263-
'buttongroup_border_radius',
264-
[
265-
'label' => __( 'Border Radius', 'mighty' ),
266-
'type' => Controls_Manager::DIMENSIONS,
267-
'size_units' => [ 'px' ],
268-
'selectors' => [
269-
'{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
270-
],
271-
]
272-
);
273-
274219
$repeater->end_controls_tab();
275220

276221
// Hover styling
@@ -287,7 +232,7 @@ protected function _register_controls() {
287232
'label' => __( 'Color', 'mighty' ),
288233
'type' => Controls_Manager::COLOR,
289234
'selectors' => [
290-
'' => 'color: {{VALUES}}'
235+
'{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a:hover' => 'color: {{VALUES}}'
291236
]
292237
]
293238
);
@@ -298,65 +243,91 @@ protected function _register_controls() {
298243
'label' => __( 'Background Color', 'mighty' ),
299244
'type' => Controls_Manager::COLOR,
300245
'selectors' => [
301-
'' => 'background-color: {{VALUES}}'
246+
'{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a:hover' => 'background-color: {{VALUES}}'
302247
]
303248
]
304249
);
305-
250+
306251
$repeater->add_control(
307-
'buttongroup_hover_border_color',
252+
'hover_animation',
308253
[
309-
'label' => __( 'Border Color', 'mighty' ),
310-
'type' => Controls_Manager::COLOR,
311-
'selectors' => [
312-
'' => 'border-color: {{VALUES}}'
313-
]
254+
'label' => __('Hover Animation', 'mighty'),
255+
'type' => \Elementor\Controls_Manager::HOVER_ANIMATION,
314256
]
315257
);
316258

317-
259+
$repeater->end_controls_tab();
260+
261+
$repeater->end_controls_tabs();
318262

319-
$repeater->add_group_control(
320-
Group_Control_Background::get_type(),
321-
[
322-
'name' => 'buttongroup_gradient_hover_color',
323-
'label' => __( 'Gradient', 'mighty' ),
324-
'types' => [ 'classic', 'gradient' ],
325-
'selector' => '{{WRAPPER}} .wrapper',
326-
]
327-
);
263+
$repeater->add_group_control(
264+
Group_Control_Border::get_type(),
265+
[
266+
'name' => 'border',
267+
'label' => __( 'Border', 'mighty' ),
268+
'selector' => '{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a',
269+
'separator' => 'before',
270+
]
271+
);
328272

329-
$repeater->add_group_control(
330-
Group_Control_Box_Shadow::get_type(),
331-
[
332-
'name' => 'buttongroup_btn_shadow',
333-
'label' => __( 'Box Shadow', 'mighty' ),
334-
'selector' => '{{WRAPPER}} .wrapper',
335-
]
336-
);
273+
$repeater->add_control(
274+
'buttongroup_border_radius',
275+
[
276+
'label' => __( 'Border Radius', 'mighty' ),
277+
'type' => Controls_Manager::DIMENSIONS,
278+
'size_units' => [ 'px' ],
279+
'selectors' => [
280+
'{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
281+
],
282+
]
283+
);
337284

338-
$repeater->add_control(
339-
'buttongroup_button_padding',
340-
[
341-
'label' => __( 'Button Padding', 'mighty' ),
342-
'type' => Controls_Manager::DIMENSIONS,
343-
'size_units' => [ 'px' ],
344-
'selectors' => [
345-
'{{WRAPPER}} ' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
346-
],
347-
]
348-
);
285+
$repeater->add_group_control(
286+
Group_Control_Box_Shadow::get_type(),
287+
[
288+
'name' => 'buttongroup_btn_shadow',
289+
'label' => __( 'Box Shadow', 'mighty' ),
290+
'selector' => '{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a',
291+
]
292+
);
349293

350-
$repeater->add_group_control(
351-
Group_Control_Typography::get_type(),
352-
[
353-
'name' => 'testimonial_typography',
354-
'scheme' => Scheme_Typography::TYPOGRAPHY_1,
355-
'selector' => '{{WRAPPER}} ',
356-
]
357-
);
294+
$repeater->add_control(
295+
'buttongroup_button_padding',
296+
[
297+
'label' => __( 'Button Padding', 'mighty' ),
298+
'type' => Controls_Manager::DIMENSIONS,
299+
'size_units' => [ 'px' ],
300+
'selectors' => [
301+
'{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
302+
],
303+
]
304+
);
358305

359-
$repeater->end_controls_tab();
306+
$repeater->add_group_control(
307+
Group_Control_Typography::get_type(),
308+
[
309+
'name' => 'testimonial_typography',
310+
'scheme' => Scheme_Typography::TYPOGRAPHY_1,
311+
'selector' => '{{WRAPPER}} .mighty-buttongroup {{CURRENT_ITEM}} a',
312+
]
313+
);
314+
315+
$repeater->add_control(
316+
'button_css_id',
317+
[
318+
'label' => __('HTML ID', 'mighty'),
319+
'type' => Controls_Manager::TEXT,
320+
'default' => __('', 'mighty'),
321+
]
322+
);
323+
324+
$repeater->add_control(
325+
'button_css_class',
326+
[
327+
'label' => __('CSS Class', 'mighty'),
328+
'type' => Controls_Manager::TEXT,
329+
]
330+
);
360331

361332
$this->add_control(
362333
'mt_buttongroup_btns',
@@ -429,7 +400,7 @@ protected function _register_controls() {
429400
'stack-on-mobile' => __( 'Mobile', 'mighty' ),
430401
],
431402
]
432-
);
403+
);
433404

434405
$this->end_controls_section();
435406
}

0 commit comments

Comments
 (0)