When generating a theme, and using theme-options.yml the variable overrides are not respected.

Somehow the following lines got removed from gulpfile.js and thus are no longer copied over to sub themes:

// Load theme options if theme-options.yml file exist and merge it with
// options.sass variable.
if (fs.existsSync('./theme-options.yml')) {
  var themeOptions = yaml.safeLoad(fs.readFileSync('./theme-options.yml', 'utf8'));
  if (themeOptions && typeof themeOptions.sass != 'undefined') {
    options.sass = merge(options.sass, themeOptions.sass);
  }
}

This also raised questions to me:

  1. What's the difference between sass/variables/_theme_name.scss and theme-options.yml ?
  2. Should the theme-options.yml from parent themes also taken into the chain (right now, they're not) ?
  3. Variables from parent themes should be available in both files ?

Tried to document that here: https://www.drupal.org/docs/8/themes/bs-base/theme-development/sass-vari...

Comments

ytsurk created an issue. See original summary.

ytsurk’s picture

StatusFileSize
new761 bytes

Here the patch re-introducing the left-out code.

Not sure if we should provide an update hook to check the file in existing theme(s).
I would say no, as we're still in alpha ...

ytsurk’s picture

Issue summary: View changes
ytsurk’s picture

Issue summary: View changes
ytsurk’s picture

Issue summary: View changes
ytsurk’s picture

Status: Active » Needs review
pivica’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.65 KB
new1.09 KB

Thx for spotting this, checked and this is indeed a bug. Provided a new patch - just some comments improvements.

> 1. What's the difference between sass/variables/_theme_name.scss and theme-options.yml ?

The only difference is that theme-options.yml will be loaded first and then the _theme_name.scss.

> 2. Should the theme-options.yml from parent themes also taken into the chain (right now, they're not) ?

Hmmm, good question.

Currently, theme-options.yml is more an exotic feature of bs_base theme. We have an idea in the future to offer inline code editor so site admins can edit this file, save it and the theme will autogenerate then CSS. This is the main and only reason this support for yaml SASS variable file exists. However

  • We are still not sure will we do this in the future, it is still an idea.
  • Even if we do this i don't think we will offer this support in bs_base theme for now, but more in our custom base commercial themes.

This would mean that theme-options.yml is really only intended for end custom child themes and not custom base themes.

So i would say, yes it would be correct to include this yaml files from parent themes if they exist. However due to other things i don't think it makes sense to spent time on this now.
Let us see what will happen with this yaml support. It does not offer really any benefit from regular SASS variables file and only imposes a lot of limitation - for example, you can not import custom mixins and functions that you would like to use it in it, etc.

> 3. Variables from parent themes should be available in both files ?

No, idea is that this files sits on top and that they can override variables from parent themes. For this to happen we need first to load these files and then variable files from parent themes. This is how SASS variable override works with !default. I know it is annoying when you want to use some parent variable in this files, but the only thing you can do is to define this parent variable in this files again, you can not reuse them.

pivica’s picture

Issue tags: +next-release

  • pivica committed ced5468 on 8.x-1.x authored by ytsurk
    Issue #3071854 by pivica, ytsurk: Generated child themes no longer...
pivica’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

@ytsurk i am not sure do we need some follow-up issus for this, feel free to create some if you think so.

ytsurk’s picture

I think for now the behaviour is documented and shall stay as is ..

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.