-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak: Button icon constrols #27296
base: main
Are you sure you want to change the base?
Tweak: Button icon constrols #27296
Changes from 39 commits
4876a44
c816782
0397592
fc66eba
94b4a5c
5e6c085
e2a9964
a8156d5
9d713f8
b2b2a8f
b002282
85ae070
af55972
59a107e
a457997
958bc36
6e5948d
32fb80b
b294a9d
a544284
2b44780
3359c83
5dccecf
77ff4ef
873e9d9
0e8906c
654efff
2785ef5
7f4eb6b
f808224
ad35460
ac84cc3
fdfec7e
e39103c
b91bf3a
ed6f79d
9ae29c0
1450127
dd13e5a
93ef15a
e3dc0d0
b400d01
e2a2ac4
d25229f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,71 +132,6 @@ protected function register_button_content_controls( $args = [] ) { | |
] | ||
); | ||
|
||
$start = is_rtl() ? 'right' : 'left'; | ||
$end = is_rtl() ? 'left' : 'right'; | ||
|
||
$this->add_control( | ||
'icon_align', | ||
[ | ||
'label' => esc_html__( 'Icon Position', 'elementor' ), | ||
'type' => Controls_Manager::CHOOSE, | ||
'default' => is_rtl() ? 'row-reverse' : 'row', | ||
'options' => [ | ||
'row' => [ | ||
'title' => esc_html__( 'Start', 'elementor' ), | ||
'icon' => "eicon-h-align-{$start}", | ||
], | ||
'row-reverse' => [ | ||
'title' => esc_html__( 'End', 'elementor' ), | ||
'icon' => "eicon-h-align-{$end}", | ||
], | ||
], | ||
'selectors_dictionary' => [ | ||
'left' => is_rtl() ? 'row-reverse' : 'row', | ||
'right' => is_rtl() ? 'row' : 'row-reverse', | ||
], | ||
'selectors' => [ | ||
'{{WRAPPER}} .elementor-button-content-wrapper' => 'flex-direction: {{VALUE}};', | ||
], | ||
'condition' => array_merge( | ||
$args['section_condition'], | ||
[ | ||
'text!' => '', | ||
'selected_icon[value]!' => '', | ||
] | ||
), | ||
] | ||
); | ||
|
||
$this->add_control( | ||
'icon_indent', | ||
[ | ||
'label' => esc_html__( 'Icon Spacing', 'elementor' ), | ||
'type' => Controls_Manager::SLIDER, | ||
'size_units' => [ 'px', 'em', 'rem', 'custom' ], | ||
'range' => [ | ||
'px' => [ | ||
'max' => 50, | ||
], | ||
'em' => [ | ||
'max' => 5, | ||
], | ||
'rem' => [ | ||
'max' => 5, | ||
], | ||
], | ||
'selectors' => [ | ||
'{{WRAPPER}} .elementor-button .elementor-button-content-wrapper' => 'gap: {{SIZE}}{{UNIT}};', | ||
], | ||
'condition' => array_merge( | ||
$args['section_condition'], | ||
[ | ||
'text!' => '', | ||
'selected_icon[value]!' => '', | ||
] | ||
), | ||
] | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two empty lines here. |
||
$this->add_control( | ||
'button_css_id', | ||
|
@@ -438,7 +373,7 @@ protected function register_button_style_controls( $args = [] ) { | |
'unit' => 's', | ||
], | ||
'selectors' => [ | ||
'{{WRAPPER}} .elementor-button' => 'transition-duration: {{SIZE}}{{UNIT}};', | ||
'{{WRAPPER}}' => '--button-icon-transition: {{SIZE}}{{UNIT}};', | ||
], | ||
] | ||
); | ||
|
@@ -503,6 +438,160 @@ protected function register_button_style_controls( $args = [] ) { | |
); | ||
} | ||
|
||
protected function register_icon_style_controls( $args = [] ) { | ||
$default_args = [ | ||
'section_condition' => [], | ||
'alignment_default' => '', | ||
'alignment_control_prefix_class' => 'elementor%s-align-', | ||
'content_alignment_default' => '', | ||
]; | ||
|
||
$args = wp_parse_args( $args, $default_args ); | ||
|
||
$start = is_rtl() ? 'right' : 'left'; | ||
$end = is_rtl() ? 'left' : 'right'; | ||
|
||
$this->add_control( | ||
'icon_align', | ||
[ | ||
'label' => esc_html__( 'Position', 'elementor' ), | ||
'type' => Controls_Manager::CHOOSE, | ||
'options' => [ | ||
'row' => [ | ||
'title' => esc_html__( 'Start', 'elementor' ), | ||
'icon' => "eicon-h-align-{$start}", | ||
], | ||
'row-reverse' => [ | ||
'title' => esc_html__( 'End', 'elementor' ), | ||
'icon' => "eicon-h-align-{$end}", | ||
], | ||
'column' => [ | ||
'title' => esc_html__( 'Above', 'elementor' ), | ||
'icon' => "eicon-v-align-top", | ||
], | ||
'column-reverse' => [ | ||
'title' => esc_html__( 'Below', 'elementor' ), | ||
'icon' => "eicon-v-align-bottom", | ||
], | ||
], | ||
'selectors_dictionary' => [ | ||
'row' => is_rtl() ? '--button-flex-direction: row-reverse' : '--button-flex-direction: row', | ||
'row-reverse' => is_rtl() ? '--button-flex-direction: row' : '--button-flex-direction: row-reverse', | ||
'column' => '--button-flex-direction: column; --button-align-self: center; --button-icon-display: flex;', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated this.
|
||
'column-reverse' => '--button-flex-direction: column-reverse; --button-align-self: center; --button-icon-display: flex;', | ||
], | ||
'selectors' => [ | ||
'{{WRAPPER}}' => '{{VALUE}};', | ||
], | ||
'condition' => array_merge( | ||
$args['section_condition'], | ||
[ | ||
'text!' => '', | ||
'selected_icon[value]!' => '', | ||
] | ||
), | ||
] | ||
); | ||
|
||
$this->add_responsive_control( | ||
'icon_size', | ||
[ | ||
'label' => esc_html__( 'Size', 'elementor' ), | ||
'type' => Controls_Manager::SLIDER, | ||
'range' => [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This range values can be deleted, because these are the default values. |
||
'px' => [ | ||
'max' => 100, | ||
], | ||
'em' => [ | ||
'max' => 10, | ||
], | ||
'rem' => [ | ||
'max' => 10, | ||
], | ||
], | ||
'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ], | ||
'selectors' => [ | ||
'{{WRAPPER}}' => '--button-icon-size: {{SIZE}}{{UNIT}}; --button-icon-display: flex; --button-align-self: center;', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added the new |
||
], | ||
] ); | ||
|
||
$this->add_control( | ||
'icon_indent', | ||
[ | ||
'label' => esc_html__( 'Spacing', 'elementor' ), | ||
'type' => Controls_Manager::SLIDER, | ||
'size_units' => [ 'px', 'em', 'rem', 'custom' ], | ||
'range' => [ | ||
'px' => [ | ||
'max' => 50, | ||
], | ||
'em' => [ | ||
'max' => 5, | ||
], | ||
'rem' => [ | ||
'max' => 5, | ||
], | ||
], | ||
'selectors' => [ | ||
'{{WRAPPER}} .elementor-button .elementor-button-content-wrapper' => 'gap: {{SIZE}}{{UNIT}};', | ||
], | ||
'condition' => array_merge( | ||
$args['section_condition'], | ||
[ | ||
'text!' => '', | ||
'selected_icon[value]!' => '', | ||
] | ||
), | ||
] | ||
); | ||
|
||
|
||
$this->start_controls_tabs( 'icons_button_style', [ | ||
'condition' => $args['section_condition'], | ||
] ); | ||
|
||
$this->start_controls_tab( | ||
'icon_button_normal', | ||
[ | ||
'label' => esc_html__( 'Normal', 'elementor' ), | ||
'condition' => $args['section_condition'], | ||
] | ||
); | ||
|
||
$this->add_control( 'icon_color', [ | ||
'label' => esc_html__( 'Color', 'elementor' ), | ||
'type' => Controls_Manager::COLOR, | ||
'selectors' => [ | ||
'{{WRAPPER}}' => '--button-icon-color: {{VALUE}};', | ||
], | ||
] ); | ||
|
||
$this->end_controls_tab(); | ||
|
||
|
||
$this->start_controls_tab( | ||
'icon_button_hover', | ||
[ | ||
'label' => esc_html__( 'Hover', 'elementor' ), | ||
'condition' => $args['section_condition'], | ||
] | ||
); | ||
|
||
$this->add_control( 'icon_color_hover', [ | ||
'label' => esc_html__( 'Color', 'elementor' ), | ||
'type' => Controls_Manager::COLOR, | ||
'selectors' => [ | ||
'{{WRAPPER}}' => '--button-icon-color-hover: {{VALUE}};', | ||
], | ||
] ); | ||
|
||
$this->end_controls_tab(); | ||
|
||
|
||
$this->end_controls_tabs(); | ||
|
||
} | ||
|
||
/** | ||
* Render button widget output on the frontend. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These dictionary values where used because the old controls where updated. We can't remove them. I believe that you triggered had changed them to 'row' and 'row-reverse', but we need to keep the original once as well.
And there is no need for an rtl conversion inside the row/row-reverse settings.