Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter popsantiago

    (@popsantiago)

    Hello,
    I’m not a dev so i don’t know if it’s the right way to do this… but i found a solution near line 460 :

    // Change this >
    $color = $set['color'];
    // By that >
    $color = $this->hex2rgba($set['color'] , $set['alpha']);
    

    Can you check if it’s a bug ?

    Thx

    Plugin Author Daniel Men?ies

    (@kungtiger)

    Hi, I see what you are trying to do.
    You can set a colour format for each colour. Move your mouse over a input field where you would enter a colour code and a little arrow appears on the right side of the field. Click on it and you can select a colour format.

    Hope that helps.

    Thread Starter popsantiago

    (@popsantiago)

    Hello Daniel,

    Thx for reply.

    I’m not a dev but i did this function maybe you can make it better and add it on your plugin as feature > Elementor Pro integration.

    // custom Custom_Avg_Tag dynamic tag
    add_action( 'elementor/dynamic_tags/register_tags', function( $dynamic_tags ) {
    	class Elementor_Global_Colors_Tag extends \Elementor\Core\DynamicTags\Tag {
    
    		public function colors_options(){
    			$colors = kt_Central_Palette::instance()->get_palette();
    			$colors_array = array();
    			$color_code_array = array();
    			$color_name_array = array();			
    			
    			foreach ($colors as $color) {
    				$color_name = $color['name'];
    				$color_code = 'var(--' . str_replace(' ', '', $color_name) . ')';
    				$color_code_array[] = $color_code;
    				$color_name_array[] = $color['name'];
    			}	
    			$colors_array = array_combine($color_code_array, $color_name_array);	
    
    			return $colors_array;
    		}
    
    		
    		public function get_name() {
    			return 'Elementor_Global_Colors_Tag';
    		}
    
    		public function get_categories() {
    			return [ 'color' ];
    		}
    
    		public function get_group() {
    			return [ 'site' ];
    		}
    
    		public function get_title() {
    			return 'Global Colors';
    		}
    
    		protected function _register_controls() {
    			$colors_array = $this->colors_options();
    			$this->add_control(
    				'fields',
    				[
    					'label' => __( 'Fields', 'text-domain' ),
    					'type' => \Elementor\Controls_Manager::SELECT,
    					'options' => $colors_array,
    					'default' => 'default',
    				]
    			);
    		}
    		public function render() {
    			$fields = $this->get_settings( 'fields' );
    			echo $fields;
    		}
    
    	}
    	$dynamic_tags->register_tag( 'Elementor_Global_Colors_Tag' );
    } );

    This add a custom Tag from the Elementor Dynamic tags who get the Palette of your plugin.

    But name is a problem more with autogeneration… so maybe we need a static name by id > kt-palette-1, kt-palette-2 etc… and set the default value to kt-palette-1

    Maybe you can have a look.

    Thx Laurent

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘rgba color in CSS variable’ is closed to new replies.