startControlsSection( 'section_icon', [ 'label' => __('Icon'), ] ); $this->addControl( 'selected_icon', [ 'label' => __('Icon'), 'type' => ControlsManager::ICONS, 'fa4compatibility' => 'icon', 'default' => [ 'value' => 'fas fa-star', 'library' => 'fa-solid', ], ] ); $this->addControl( 'view', [ 'label' => __('View'), 'type' => ControlsManager::SELECT, 'options' => [ 'default' => __('Default'), 'stacked' => __('Stacked'), 'framed' => __('Framed'), ], 'default' => 'default', 'prefix_class' => 'elementor-view-', ] ); $this->addControl( 'shape', [ 'label' => __('Shape'), 'type' => ControlsManager::SELECT, 'options' => [ 'circle' => __('Circle'), 'square' => __('Square'), ], 'default' => 'circle', 'condition' => [ 'view!' => 'default', ], 'prefix_class' => 'elementor-shape-', ] ); $this->addControl( 'link', [ 'label' => __('Link'), 'type' => ControlsManager::URL, 'dynamic' => [ 'active' => true, ], 'placeholder' => __('https://your-link.com'), ] ); $this->addResponsiveControl( 'align', [ 'label' => __('Alignment'), 'type' => ControlsManager::CHOOSE, 'options' => [ 'left' => [ 'title' => __('Left'), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => __('Center'), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => __('Right'), 'icon' => 'eicon-text-align-right', ], ], 'default' => 'center', 'selectors' => [ '{{WRAPPER}} .elementor-icon-wrapper' => 'text-align: {{VALUE}};', ], ] ); $this->endControlsSection(); $this->startControlsSection( 'section_style_icon', [ 'label' => __('Icon'), 'tab' => ControlsManager::TAB_STYLE, ] ); $this->startControlsTabs('icon_colors'); $this->startControlsTab( 'icon_colors_normal', [ 'label' => __('Normal'), ] ); $this->addControl( 'primary_color', [ 'label' => __('Primary Color'), 'type' => ControlsManager::COLOR, 'selectors' => [ '{{WRAPPER}}.elementor-view-stacked .elementor-icon' => 'background-color: {{VALUE}};', '{{WRAPPER}}.elementor-view-framed .elementor-icon:not(#e), {{WRAPPER}}.elementor-view-default .elementor-icon:not(#e)' => 'color: {{VALUE}};', ], 'scheme' => [ 'type' => SchemeColor::getType(), 'value' => SchemeColor::COLOR_1, ], ] ); $this->addControl( 'secondary_color', [ 'label' => __('Secondary Color'), 'type' => ControlsManager::COLOR, 'condition' => [ 'view!' => 'default', ], 'selectors' => [ '{{WRAPPER}}.elementor-view-framed .elementor-icon' => 'background-color: {{VALUE}};', '{{WRAPPER}}.elementor-view-stacked .elementor-icon:not(#e)' => 'color: {{VALUE}};', ], ] ); $this->endControlsTab(); $this->startControlsTab( 'icon_colors_hover', [ 'label' => __('Hover'), ] ); $this->addControl( 'hover_primary_color', [ 'label' => __('Primary Color'), 'type' => ControlsManager::COLOR, 'selectors' => [ '{{WRAPPER}}.elementor-view-stacked .elementor-icon:hover' => 'background-color: {{VALUE}};', '{{WRAPPER}}.elementor-view-framed .elementor-icon:not(#e):hover, {{WRAPPER}}.elementor-view-default .elementor-icon:not(#e):hover' => 'color: {{VALUE}};', ], ] ); $this->addControl( 'hover_secondary_color', [ 'label' => __('Secondary Color'), 'type' => ControlsManager::COLOR, 'condition' => [ 'view!' => 'default', ], 'selectors' => [ '{{WRAPPER}}.elementor-view-framed .elementor-icon:hover' => 'background-color: {{VALUE}};', '{{WRAPPER}}.elementor-view-stacked .elementor-icon:not(#e):hover' => 'color: {{VALUE}};', ], ] ); $this->addControl( 'hover_animation', [ 'label' => __('Hover Animation'), 'type' => ControlsManager::HOVER_ANIMATION, ] ); $this->endControlsTab(); $this->endControlsTabs(); $this->addResponsiveControl( 'size', [ 'label' => __('Size'), 'type' => ControlsManager::SLIDER, 'range' => [ 'px' => [ 'min' => 6, 'max' => 300, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-icon' => 'font-size: {{SIZE}}{{UNIT}};', ], 'separator' => 'before', ] ); $this->addControl( 'icon_padding', [ 'label' => __('Padding'), 'type' => ControlsManager::SLIDER, 'selectors' => [ '{{WRAPPER}} .elementor-icon' => 'padding: {{SIZE}}{{UNIT}};', ], 'range' => [ 'em' => [ 'min' => 0, 'max' => 5, ], ], 'condition' => [ 'view!' => 'default', ], ] ); $this->addResponsiveControl( 'rotate', [ 'label' => __('Rotate'), 'type' => ControlsManager::SLIDER, 'size_units' => ['deg'], 'default' => [ 'size' => 0, 'unit' => 'deg', ], 'tablet_default' => [ 'unit' => 'deg', ], 'mobile_default' => [ 'unit' => 'deg', ], 'selectors' => [ '{{WRAPPER}} .elementor-icon i, {{WRAPPER}} .elementor-icon svg' => 'transform: rotate({{SIZE}}{{UNIT}});', ], ] ); $this->addControl( 'border_width', [ 'label' => __('Border Width'), 'type' => ControlsManager::DIMENSIONS, 'selectors' => [ '{{WRAPPER}} .elementor-icon' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'condition' => [ 'view' => 'framed', ], ] ); $this->addControl( 'border_radius', [ 'label' => __('Border Radius'), 'type' => ControlsManager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} .elementor-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'condition' => [ 'view!' => 'default', ], ] ); $this->endControlsSection(); } /** * Render icon widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.0.0 */ protected function render() { $settings = $this->getSettingsForDisplay(); $this->addRenderAttribute('wrapper', 'class', 'elementor-icon-wrapper'); $this->addRenderAttribute('icon-wrapper', 'class', 'elementor-icon'); if (!empty($settings['hover_animation'])) { $this->addRenderAttribute('icon-wrapper', 'class', 'elementor-animation-' . $settings['hover_animation']); } $icon_tag = 'div'; if (!empty($settings['link']['url'])) { $this->addLinkAttributes('icon-wrapper', $settings['link']); $icon_tag = 'a'; } ?>
printRenderAttributeString('wrapper'); ?>> < printRenderAttributeString('icon-wrapper'); ?>> 'true']); ?> >
<# var link = settings.link.url ? 'href="' + settings.link.url + '"' : '', iconTag = link ? 'a' : 'div'; #>
<{{{ iconTag }}} class="elementor-icon elementor-animation-{{ settings.hover_animation }}" {{{ link }}}> {{{ elementor.helpers.getBcIcon(view, settings, 'icon', {'aria-hidden': true}) }}}