Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View thamas's full-sized avatar

Tamás Hajas thamas

View GitHub Profile
@thamas
thamas / menu.html.twig
Created April 29, 2016 20:28
create class using memu_name
{{ menus.menu_links(items, attributes, 0, menu_name) }}
{% macro menu_links(items, attributes, menu_level, menu_name) %}
{% import _self as menus %}
{%
set menu_classes = [
'c-menu-' ~ menu_name|clean_class,
]
%}
@thamas
thamas / menu.html.twig
Last active May 3, 2016 09:54
addClass
{{ menus.menu_links(items, attributes, 0, menu_name) }}
{% macro menu_links(items, attributes, menu_level, menu_name) %}
{% import _self as menus %}
{%
set menu_classes = [
'c-menu-' ~ menu_name|clean_class,
]
%}
{% if items %}
@thamas
thamas / menu.html.twig
Last active May 3, 2016 09:53
addClass to sub ul
{{ menus.menu_links(items, attributes, 0, menu_name) }}
{% macro menu_links(items, attributes, menu_level, menu_name) %}
{% import _self as menus %}
{%
set menu_classes = [
'o-menu',
'c-menu-' ~ menu_name|clean_class,
]
%}
@thamas
thamas / menu.html.twig
Created April 29, 2016 20:46
add class to menu items
{% for item in items %}
{%
set item_classes = [
'c-menu-' ~ menu_name|clean_class ~ '__item',
item.is_expanded ? 'c-menu-' ~ menu_name|clean_class ~ '__item--expanded',
item.is_collapsed ? 'c-menu-' ~ menu_name|clean_class ~ '__item--collapsed',
item.in_active_trail ? 'c-menu-' ~ menu_name|clean_class ~ '__item--active-trail',
]
%}
<li{{ item.attributes.addClass(item_classes) }}>
@thamas
thamas / menu.html.twig
Created April 29, 2016 21:37
add class to links
{# Create CSS class #}
{%
set link_classes = [
'c-menu-' ~ menu_name|clean_class ~ '__link',
]
%}
<li{{ item.attributes.addClass(item_classes) }}>
{# In link function add link class and remove leaking item classes #}
{{
link(
@thamas
thamas / menu.html.twig
Last active October 3, 2018 14:16
Full template
{#
/**
* @file
* Theme override to display a menu.
*/
#}
{% import _self as menus %}
{#
We call a macro which calls itself to render the full tree.
@thamas
thamas / stephen-hay-backside-of-the-css-class.md
Last active May 13, 2016 09:54
Digest of the presentation The Back(side) of the Class by Stephen Hay

Stephen Hay: The Back(side) of the Class

Video: https://vimeo.com/134190982

Have you ever been taught that “modularizing” CSS via an endless number of “reusable” object-like “classes” is the “proper” way to use CSS on “large-scale websites”, or have you taught others that these are “best practices”? Do you think there’s a difference between the term “large-scale websites” and “enterprise websites”? When I say “inheritance” and “specificity”, do you feel dirty?
If you answered yes to the above questions, then you, my friend, are going to absolutely hate this session.
Slides: http://slideshare.net/stephenhay/the-backsideoftheclass
About Stephen: http://the-haystack.com
More about CSS Day: http://cssday.nl or https://twitter.com/cssdayconf

Working with chx was like having the lead engineer of the best formula-1 team tune your car! I do not think anyone knows Drupal 8 migration better (because he wrote the code). He is a professional developer and a kind person in one.

{% set current_date = date()|date('U')|format_date('short') %}
<p>
{% trans %}
The current date is {{ current_date|placeholder|striptags }}
{% endtrans %}
</p>