diff --git a/components/_patterns/01-atoms/04-images/00-image/01-image~logo.yml b/components/_patterns/01-atoms/04-images/00-image/image~logo.yml similarity index 100% rename from components/_patterns/01-atoms/04-images/00-image/01-image~logo.yml rename to components/_patterns/01-atoms/04-images/00-image/image~logo.yml diff --git a/components/_patterns/01-atoms/04-images/icons/_icon.twig b/components/_patterns/01-atoms/04-images/icons/_icon.twig new file mode 100644 index 00000000..87a380fc --- /dev/null +++ b/components/_patterns/01-atoms/04-images/icons/_icon.twig @@ -0,0 +1,23 @@ +{# +/** + * Available variables: + * - icon_base_class - base class name + * - icon_modifiers - modifiers for icons (array) + * - icon_blockname - blockname prepended to the base classname + * - icon_name - the name of the icon + */ +#} +{% set icon_base_class = icon_base_class|default('icon') %} +{% set icon_url = '' %} + +{# Drupal #} +{# {% if attributes or theme_hook_original %} + {% set icon_url = '/themes/custom/YOURTHEME/dist/img/sprite/' %} + {{ attach_library('emulsify/sprite') }} +{% else %} #} + {% set icon_url = '/dist/img/sprite/' %} +{# {% endif %} #} + + diff --git a/components/_patterns/01-atoms/04-images/icons/_icon_sprite.scss b/components/_patterns/01-atoms/04-images/icons/_icon_sprite.scss deleted file mode 100644 index 7c583568..00000000 --- a/components/_patterns/01-atoms/04-images/icons/_icon_sprite.scss +++ /dev/null @@ -1,14 +0,0 @@ -@mixin svg-common { - background: url("svg/sprite.css.svg") no-repeat; -} - -@mixin sprite-menu { - @include svg-common; - - background-position: 0 0; -} - -.sprite-menu { - @include sprite-menu; -} - diff --git a/components/_patterns/01-atoms/04-images/icons/_icons.scss b/components/_patterns/01-atoms/04-images/icons/_icons.scss deleted file mode 100644 index d651f192..00000000 --- a/components/_patterns/01-atoms/04-images/icons/_icons.scss +++ /dev/null @@ -1,17 +0,0 @@ -// Icon Styling -.sprite-icon { - background-size: 100% 100%; - display: block; - height: 0; - padding: 40%; - width: 100%; -} - -.icon-inline-menu { - display: flex; - - &::before { - @include sprite-menu; - @include with-icon; - } -} diff --git a/components/_patterns/01-atoms/04-images/icons/icons.md b/components/_patterns/01-atoms/04-images/icons/icons.md index a51c6ee7..68d28414 100644 --- a/components/_patterns/01-atoms/04-images/icons/icons.md +++ b/components/_patterns/01-atoms/04-images/icons/icons.md @@ -3,15 +3,42 @@ title: Icons --- ### How to use icons -We are using a gulp SVG sprite generator, which automatically creates the SVG CSS in `_icon_sprite.scss`. Simply add separate SVG files into `images/icons/src/` and they will be added to the sprite the next time `gulp icons` is run. +We are using a gulp SVG sprite generator (details [here](https://una.im/svg-icons)), which automatically creates the SVG in `/images/icons/sprite/sprite.svg`. Simply run `gulp icons` to add to the sprite. -**Writing Sass** +**Usage** -If you look in `_icon_sprite.scss`, you will notice there is a mixin and class for each sprite. You can use whatever approach suits your situation. **Note: You will need to tweak the background-size in 04-images/icons/_icons.scss each time a sprite is added.** You can also make use of the following mixins from `00-base/_mixins.scss` to provide inline icons before text: +The SVG component is found here: `/components/_patterns/01-atoms/04-images/icons/_icon.twig`. See available variables in that file. Examples of usage below: + +Simple: (no BEM renaming) + +``` +{% include "@atoms/04-images/icons/_icon.twig" with { + icon_name: 'bars', +} %} +``` + +... creates... + +``` + +``` + +Complex (BEM classes): + +``` +{% include "@atoms/04-images/icons/_icon.twig" with { + icon_base_class: 'icon', + icon_blockname: 'toggle-expand', + icon_name: 'bars', +} %} +``` + +... creates... ``` -.TEXT_WITH_ICON_BEFORE_IT { - @include ICONNAME; // e.g., sprite-chevron-right - @include with-icon; -} + ``` diff --git a/components/_patterns/01-atoms/04-images/icons/icons.twig b/components/_patterns/01-atoms/04-images/icons/icons.twig index eafa9296..137bdaa5 100644 --- a/components/_patterns/01-atoms/04-images/icons/icons.twig +++ b/components/_patterns/01-atoms/04-images/icons/icons.twig @@ -1,13 +1,14 @@
{{ item.name }}
{{ item.value }}
+