Created
September 1, 2016 19:28
-
-
Save jacine/4689e6a9ace665cee2f435585c62006c to your computer and use it in GitHub Desktop.
My Icon Twig Component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
/** | |
* @file | |
* SVG Icon template | |
* | |
* Variables: | |
* - icon: Name of the icon; SVG should exist as build/img/icons/{icon}.swg | |
* - text: Fallback text for screen readers, and when icon is not present. | |
* - text_class: Provides a class using boolean text_visible, to add a class | |
* which determines whether fallback text should appear visually or not. | |
* - location: Location of text in markup: left (default) or right of icon). | |
*/ | |
#} | |
{% set text_class, location = | |
text_visible ? 'icon-text' : 'icon-text-fallback', | |
location ? location : 'left' | |
%} | |
{% if icon %} | |
{% if text and location == 'right' %} | |
<span class="{{ text_class }}">{{ text }}</span> | |
{% endif %} | |
<svg class="icon icon-{{ icon }}"><use xlink:href="#icon-{{ icon }}"></use></svg> | |
{% if text and location == 'left' %} | |
<span class="{{ text_class }}">{{ text }}</span> | |
{% endif %} | |
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="search"> | |
<button class="search-toggle"> | |
<span class="search-toggle-icon search-toggle-icon--expand"> | |
{% embed '@components/icon.twig' with { icon: 'search-alt', text: 'Toggle Search' } %}{% endembed %} | |
</span> | |
<span class="search-toggle-icon search-toggle-icon--collapse"> | |
{% embed '@components/icon.twig' with { icon: 'close-x', text: 'Toggle Search' } %}{% endembed %} | |
</span> | |
</button> | |
{{ form.search }} | |
<div class="search-buttons"> | |
<span class="search-submit-icon"> | |
{% embed '@components/icon.twig' with { icon: 'search-alt', text: 'Search' } %}{% endembed %} | |
</span> | |
{{ form.actions.submit }} | |
</div> | |
{{ children }} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment