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

Add ability to attach library stylesheets and/or scripts #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

waako
Copy link

@waako waako commented Feb 18, 2019

Makes it possible to attach local or external css files even if in multiple groups.

Library file like this should work in all instances:

accordion:
  js:
    dist/02-molecules/accordion-item/accordion-item.js: {}
  css:
    theme:
      dist/02-molecules/accordion-item/accordion-item.css: {}

icons:
  css:
    base:
      https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css { type: external }
    theme:
      dist/01-base/04-images/icons/icons.css: {}

mobile_menu:
  css:
    base:
      dist/02-molecules/menus/mobile-menu.css: {}

slideout_menu:
  js:
    https://cdnjs.cloudflare.com/ajax/libs/slideout/1.0.1/slideout.min.js { type: external }

Add missing spaces.
Keep array syntax consistent and short.
If CSS files, create merged array of files for each group (base, theme).
Then for each CSS file create link stylesheet.
Wrap foreach js files in if statement so library can contain JS or CSS.
@georgebrook
Copy link

Hi @waako , I tried using your patch, but it didn't seem to work for me

Also are these supposed to be echo's or return's

@waako
Copy link
Author

waako commented Mar 3, 2020

@georgebrook in what way is it not working, not loading css/js assets defined in THEMENAME.libraries.yml?
How are your assets paths set in libraries file, relative to theme folder?

If I recall, have to use echo in order to ouput js scripts and/or css files, depending on which are defined. if used return for $styleTags then $scriptTags would never be ouput, and function woulderror if no $styleTags.

To be honest, a better solution for that part is Pr #11 use of $library_tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants