mirror of
https://github.com/proelements/proelements.git
synced 2026-05-14 13:05:03 +00:00
v4.0.4.1
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{% set classes = settings.classes | merge( [ base_styles.base ] ) | join(' ') | trim %}
|
||||
{% set id_attribute = settings._cssid is not empty ? 'id=' ~ settings._cssid | e('html_attr') : '' %}
|
||||
{% set for_attribute = settings['input-id'] is not empty ? 'for=' ~ settings['input-id'] | e('html_attr') : '' %}
|
||||
{% set interactions_attribute = interactions is not empty ? 'data-interactions=' ~ interactions | json_encode | e('html_attr') : '' %}
|
||||
{% set allowed_tags = '<b><strong><sup><sub><s><em><i><u><a><del><span><br>' %}
|
||||
<label
|
||||
{{ id_attribute }}
|
||||
class="{{ classes }}"
|
||||
{{ for_attribute }}
|
||||
data-interaction-id="{{ interaction_id | default(id) }}"
|
||||
{{ settings.attributes | raw }}
|
||||
{{ interactions_attribute }}
|
||||
>{{ settings.text | striptags(allowed_tags) | raw }}</label>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\AtomicForm\Label;
|
||||
|
||||
use Elementor\Modules\AtomicWidgets\Controls\Section;
|
||||
use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
|
||||
use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control;
|
||||
use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base;
|
||||
use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template;
|
||||
use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
|
||||
use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
|
||||
use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
|
||||
use Elementor\Modules\AtomicWidgets\PropTypes\Html_V3_Prop_Type;
|
||||
use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
|
||||
use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
|
||||
use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
|
||||
use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type;
|
||||
use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Label extends Atomic_Widget_Base {
|
||||
use Has_Template;
|
||||
|
||||
public static $widget_description = 'Display a label with customizable text and for attribute.';
|
||||
|
||||
public static function get_element_type(): string {
|
||||
return 'e-form-label';
|
||||
}
|
||||
|
||||
public function get_title(): string {
|
||||
return esc_html__( 'Label', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon(): string {
|
||||
return 'eicon-atomic-label';
|
||||
}
|
||||
|
||||
public function get_categories(): array {
|
||||
return [ 'atomic-form' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'atomic', 'form', 'label', 'text' ];
|
||||
}
|
||||
|
||||
protected static function define_props_schema(): array {
|
||||
return [
|
||||
'tag' => String_Prop_Type::make()
|
||||
->default( 'label' ),
|
||||
'classes' => Classes_Prop_Type::make()
|
||||
->default( [] ),
|
||||
'text' => Html_V3_Prop_Type::make()
|
||||
->default( [
|
||||
'content' => String_Prop_Type::generate( 'Form label' ),
|
||||
'children' => [],
|
||||
] ),
|
||||
'input-id' => String_Prop_Type::make()
|
||||
->default( '' ),
|
||||
'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
|
||||
];
|
||||
}
|
||||
|
||||
protected function define_atomic_controls(): array {
|
||||
return [
|
||||
Section::make()
|
||||
->set_label( __( 'Content', 'elementor-pro' ) )
|
||||
->set_items( [
|
||||
Inline_Editing_Control::bind_to( 'text' )
|
||||
->set_label( __( 'Label text', 'elementor-pro' ) ),
|
||||
Text_Control::bind_to( 'input-id' )
|
||||
->set_label( __( 'Connected to input ID', 'elementor-pro' ) )
|
||||
->set_meta( [
|
||||
'layout' => 'two-columns',
|
||||
] ),
|
||||
] ),
|
||||
Section::make()
|
||||
->set_label( __( 'Settings', 'elementor-pro' ) )
|
||||
->set_id( 'settings' )
|
||||
->set_items( $this->get_settings_controls() ),
|
||||
];
|
||||
}
|
||||
|
||||
protected function get_settings_controls(): array {
|
||||
return [
|
||||
Text_Control::bind_to( '_cssid' )
|
||||
->set_label( __( 'ID', 'elementor-pro' ) )
|
||||
->set_meta( $this->get_css_id_control_meta() ),
|
||||
];
|
||||
}
|
||||
|
||||
protected function get_templates(): array {
|
||||
return [
|
||||
'label' => __DIR__ . '/label.html.twig',
|
||||
];
|
||||
}
|
||||
|
||||
protected function get_css_id_control_meta(): array {
|
||||
return [
|
||||
'layout' => 'two-columns',
|
||||
'topDivider' => false,
|
||||
];
|
||||
}
|
||||
|
||||
protected function define_base_styles(): array {
|
||||
|
||||
$text_color_value = Color_Prop_Type::generate( '#0c0d0e' );
|
||||
$font_size_value = Size_Prop_Type::generate( [
|
||||
'size' => 14,
|
||||
'unit' => 'px',
|
||||
] );
|
||||
|
||||
return [
|
||||
'base' => Style_Definition::make()
|
||||
->add_variant(
|
||||
Style_Variant::make()
|
||||
->add_props( [
|
||||
'color' => $text_color_value,
|
||||
'font-size' => $font_size_value,
|
||||
] ),
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user