liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Theme Editor color picker breaks liquid files in the assets folder when choosing branding colors

Open naxorn opened this issue 3 years ago • 6 comments

Issue

If a user chooses a dynamic source for the color picker in the Theme Editor, such as Brand > Primary Color 1, any .liquid files in the assets folder that rely on the setting will output {{ shop.brand.colors.primary[0].background }} instead of the css color.

Expected Behaviour

If the file theme/assets/test.css.liquid has the following

.some-class {
    background-color: {{ settings.theme_color }}; /* set as Brand > Primary Color 1 */
}

it should become

.some-class {
    background-color: #112233; /* set as Brand > Primary Color 1 */
}

Actual

Instead it does this

.some-class {
    background-color: {{ shop.brand.colors.primary[0].background }}; /* set as Brand > Primary Color 1 */
}

Steps to Replicate

  1. Create a color picker in the theme's settings, such as
{
  "type": "color",
  "id": "theme_color",
  "label": "Theme Color",
  "default": "#000000"
}
  1. Choose a dynamic color source, such as Brand > Primary Color 1 image
  2. Create a test.css.liquid file in the assets folder of the theme
.some-class {
    background-color: {{ settings.theme_color }};
}
  1. Add the css file to the theme to get the link to the generated file, such as
{{ 'test.css' | asset_url | stylesheet_tag }}
  1. View the file and it will show {{ shop.brand.colors.primary[0].background }} instead of the css color, such as #112233
.some-class {
    background-color: {{ shop.brand.colors.primary[0].background }};
}

naxorn avatar Nov 08 '22 19:11 naxorn

Having this exact problem.

alezzzzz avatar Feb 02 '23 18:02 alezzzzz

Also having this problem in our themes. Partner Support referred me to this GitHub Issue.

willbroderick avatar Feb 06 '23 09:02 willbroderick

Having the same issue. A quick way to fix this issue is to move the css variables into the <head> tag of layout/theme.liquid. The liquid variable: {{ shop.brand.colors.primary[0].background }} seems to work outside of the assets directory.

+1 I have the same issue. I'd like to follow best practices while working on client's themes without creating my own custom convention for calling brand colors/assets.

image

Shopify please fix!

fevish avatar Jul 24 '23 16:07 fevish

I came across this bug myself too. Reported to Shopify Plus support who told me "heavily customised themes aren't supported", or something to that effect.

Nothing to do with customised themes, since I've replicated the same issue on other themes from the Shopify Theme Store installed as theme trials (e.g. not possible to change any of the original coding).

This is a clear bug on Shopify's side. You're supposed to be able to use Liquid in css.liquid files, all we're doing is reference a settings.my_setting_name, the problem is introduced by Shopify within Theme Customiser.

binarymonkey84 avatar Apr 22 '24 13:04 binarymonkey84

Having the same problem here. It's sad that I have to put a lot of css code into theme.liquid instead, it makes that file even more bloated. And worse, makes the DOM on the site bigger which is not good for SEO and performance. I would prefer to be able to have styling in separate css files.

tbb2 avatar Jun 21 '24 07:06 tbb2