Skip to content

Instantly share code, notes, and snippets.

@thamas
Created October 19, 2018 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thamas/45a1abb1c4db2d720d3aa8b64db52b99 to your computer and use it in GitHub Desktop.
Save thamas/45a1abb1c4db2d720d3aa8b64db52b99 to your computer and use it in GitHub Desktop.

jsheffers [4:15 PM] I copied the code emulsify uses for the menus, but I’m having trouble with the actual link class. It’s pulling the base class from the item instead of adding __link

Obviously that should be __link (edited)

{% embed '@atoms/lists/_list-item.twig' with {
  "list_item_label": item_label,
  "li_base_class": item_base_class|default(menu_class ~ '__item'),
  "li_modifiers": item_modifiers,
  "li_blockname": item_blockname,
} %}
  {% block list_item_content %}
    {% include "@atoms/links/link.twig" with {
      "link_content": item.title,
      "link_url": item.url,
      "link_base_class": item_base_class|default(menu_class ~ '__link'),
      "link_modifiers": item_modifiers,
    } %}

    {% if item.below %}
      {{ menus.menu_links(item.below, attributes, menu_level + 1, menu_class, menu_modifiers, menu_blockname, item_base_class, item_modifiers, item_blockname) }}
    {% endif %}
  {% endblock %}
{% endembed %}

(edited) Any ideas?

Johnny5th [4:20 PM] should "link_base_class": item_base_class|default(menu_class ~ '__link'), be "link_base_class": link_base_class|default(menu_class ~ '__link'),? your default won’t trigger if item_base_class is already set

jsheffers [4:21 PM] https://github.com/fourkitchens/emulsify/blob/develop/components/_patterns/02-molecules/menus/_menu-item.twig GitHub fourkitchens/emulsify Emulsify: Pattern Lab + Drupal 8. Contribute to fourkitchens/emulsify development by creating an account on GitHub.

jsheffers [4:23 PM] Yeah, that does fix the issue, but that’s not how emulsify has it. Just wondering if I was missing something (edited)

bjlewis2 [20 hours ago] That looks like a typo to me

bjlewis2 [20 hours ago] To be honest, the whole menu files should probably be updated. I think every new project I start, I make a half-dozen (at least) tweaks to the menu macros to support the project at hand

bjlewis2 [20 hours ago] A lot of those could (should) probable be merged back into Emulsify core to make life easier for everyone

bjlewis2 [20 hours ago] But regarding your original question, changing: "link_base_class": item_base_class|default(menu_class ~ '__link'), "link_modifiers": item_modifiers, to " link_base_class": link_base_class|default(menu_class ~ '__link'), "link_modifiers": link_modifiers, is probably what I’d do

bjlewis2 [20 hours ago] Actually… no it isn’t. I’d implement the bem function more thouroughly…

bjlewis2 [20 hours ago]

{% embed '@atoms/lists/_list-item.twig' with {
  list_item_label: item_label,
  li_base_class: item_base_class|default('item'),
  li_modifiers: item_modifiers,
  li_blockname: item_blockname|default(menu_class),
} %}
  {% block list_item_content %}
    {% include "@atoms/links/link.twig" with {
      link_content: item.title,
      link_url: item.url,
      link_base_class: link_base_class|default('link'),
      link_modifiers: item_modifiers,
      link_blockname: link_blockname|default(menu_class),
    } %}

    {% if item.below %}
      {{ menus.menu_links(item.below, attributes, menu_level + 1, menu_class, menu_modifiers, menu_blockname, item_base_class, item_modifiers, item_blockname, link_base_class, link_modifiers, link_blockname) }}
    {% endif %}
  {% endblock %}
{% endembed %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment