Documentation, preview and usage of icons and image utilities.
Files
app/styles/components/icons_images/config.scss
app/styles/components/icons_images/style.scss
Icons
Here is preview of icon set used in this project. An icon can be created by using pug mixin +icon(iconName)
.
Using just HTML, the markup is: <svg class="icon"><use xlink:href="#icon-iconName"></svg class="icon">
Warning
The SVG sprite needs to be inlined in current document, so that <use xlink:href="#icon-iconName">
can access the appropriate symbol.
dependency
Icons require app/svgicons/icons.svg
file to be inlined just before the </body>
tag.
<ul>
- for (var i=0; i < getIcons().length; i++) {
<li>
<svg class="icon icon-add">
<use xlink:href="#icon-getSvgIcons()[i]"></use>
</svg>
</li>
- }
</ul>
Large icons
<ul>
- for (var i=0; i < getIcons().length; i++) {
<li>
<svg class="icon icon-add">
<use xlink:href="#icon-getSvgIcons()[i]"></use>
</svg>
</li>
- }
</ul>
Colors
Icons use same text color priciple for colors as typography.
Note
In case there is no class for color, icon will inherit color from parent color property.
<ul>
<li>
<svg class="icon icon-home text-color-theme-500">
<use xlink:href="#icon-home"></use>
</svg>
</li>
<li>
<svg class="icon icon-home text-color-theme-100">
<use xlink:href="#icon-home"></use>
</svg>
</li>
<li class="text-color-semiblack">
<svg class="icon icon-home icon--large">
<use xlink:href="#icon-home"></use>
</svg>
</li>
<li class="text-color-error">
<svg class="icon icon-home icon--large">
<use xlink:href="#icon-home"></use>
</svg>
</li>
</ul>
Accessibility
Icons have two use cases:
- Presentational icon accompanied by text. such icon does not need to be picked up by screenreaders and should have role='presentation' and aria-hidden='true' attributes on its svg tag.
- Content icon, that needs an accessible text alternative. A content icon might be a button that only holds an icon without any text. To make such an icon accessible, add role='img' and aria-label='Text alternative' attributes to its svg tag.
Luckily, the +icon() pug mixin can handle both cases. Passing an accessible text alternative as an alt paramter, automatically generates the markup for a content icon. To create a presentational icon, just omit the paramter.
-
I'm accompanied by button text, my purpose is purely presentational -
I clearly represent what will happen when the button is clicked. Therefore an accessbile text alternative is appropriate.
<button class="btn btn--large">
<svg class="icon icon-check" role="img" aria-hidden="true">
<use xlink:href="#icon-check"></use>
</svg>
Done
</button>
<button class="btn btn--large">
<svg class="icon icon-settings" role="presentation" aria-label="Settings">
<use xlink:href="#icon-settings"></use>
</svg>
</button>
Image utilities
There are three basic image utilities: fluid, rounded and circle. Fluid utility gives image ability to change size coresponding to its parent. Circle and rounded utilities provides specific shapes for images.



<img src="..." class="img img--fluid">
<img src="..." class="img img--rounded">
<img src="..." class="img img--circle">
Avatars
Avatars hold a user image or a generic icon and can include a status indicator
<div class="avatar">
<img class="avatar__image" src="https://placehold.it/22x22">
<div class="avatar__status" aria-label="offline"></div>
</div>
<div class="avatar">
<span class="icon icon-user text-color-grey-300 icon--medium">
<svg ...
</span>
<div class="avatar__status" aria-label="offline"></div>
</div>
Notification count
Notification count shows the number of pending actions
<div class="notifications">
<span class="icon icon-notifications text-color-grey-300 icon--medium">
<svg ...
</span>
<div class="notifications__count">3</div>
</div>