Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access section setting in sections.scss file #714

Closed
crvella opened this issue Aug 26, 2018 · 3 comments

Comments

@crvella
Copy link

commented Aug 26, 2018

Problem

I am unable to reference a sections settings from the section.scss file

Replication steps

  1. Add following to src/sections/header.liquid
    {
    "type": "color",
    "id": "announcement_bg_color",
    "label": "Announcement BG Color",
    "info": "info"
    },

  2. Add following to src/snippets/css-variables.liquid
    :root {
    ....existing entries
    --annbar-bg-color: {{ settings.announcement_bg_color }}
    }

  3. Add following to assets/styles/variables.scss
    // Announcement bar
    $annbar_bg_color: var(--annbar-bg-color);

  4. Add following to assets/styles/sections/announcement.scss
    background-color: $annbar_bg_colour

Any additional information which might be helpful.
I get an error saying

Try opening assets/layout.theme.styleLiquid.scss.liquid in the template editor to fix the error below:
Undefined variable: "$annbar_bg_color". at 10

@jonathanmoore

This comment has been minimized.

Copy link
Collaborator

commented Aug 27, 2018

This technically wouldn't be an issue with Slate, but rather how Shopify's sections fundamentally work. Section settings and block information are isolated and only accessible inside the section. This allows for quick partial reloads in the customize theme menu.

The right approach is to set colors or other values directly in the section's markup with classes, data attributes for JavaScript or <script> tags. starter-theme has several good examples of this.
https://github.com/Shopify/starter-theme/blob/master/src/sections/header.liquid#L131

@t-kelly

This comment has been minimized.

Copy link
Contributor

commented Sep 10, 2018

As @jonathanmoore mentioned, this is not a problem with Slate rather a challenge in building themes in general. Closing.

@lock

This comment has been minimized.

Copy link

commented Oct 26, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.