liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Replace colors swatch

Open javimata opened this issue 4 years ago • 0 comments

Hi, i have a textarea with a list of color / hex value, example negro #000 rojo #f00 blanco #fff

This value i convert to array with this: assign colors = settings.swatch_colors_list | newline_to_br | strip_newlines | split: "
"

In each option values check if the option is Color then wanna check if the value color is in the colors array, i have this:

{% if option.name == 'Color' or option.name == 'color' %} {%- liquid assign colorp = value | downcase | escape | strip // THIS IS THE OPTION COLOR for c in colors

  assign eachcolor = c | uniq | split: " #"
  
  for ec in eachcolor
    if ec[0] == colorp
      assign bg = ec[1]
    endif
  endfor

endfor

%}

data-color="{{ colorp }}" data-bg="{{ bg }}" {% endif %}

but simple i dont have put in bg the correct value :-( i try many options but i can't do it, can help me?

the idea is to have a textarea in the theme where the client can put a list of colors and this is replaced by a hexadecimal that he can put

javimata avatar Jul 09 '21 15:07 javimata