2 Elements
Every littles UI elements.
2.1 Alerts
Description
Default styles for alerts.
Default styling
Example of alert with a link
Modifiers
.alert-info
info alert
Example of alert-info alert with a link
.alert-success
success alert
Example of alert-success alert with a link
.alert-warning
warning alert
Example of alert-warning alert with a link
.alert-error
error alert
Example of alert-error alert with a link
Markup
- Compiled HTML
- Template
<p class="alert pa1">Example of alert <a href="#">with a link</a></p>
<p class="alert {{ modifier_class }} pa1">Example of {{ modifier_class }} alert <a href="#">with a link</a></p>
Source: src/styl/_elements/_alert.styl
, line 1
2.2 Avatar
Description
Use a square image.
Avatar element use em
so we can and should modify its font-size
to manage the size of the element.
Example
Markup
- Compiled HTML
- Template
<div class="avatar">
<img src="./img/72x72_avatar.png" alt="" />
</div>
<div class="avatar">
<svg width="72" height="72">
<use xlink:href="#symbol-user"></use>
</svg>
</div>
<div class="avatar">
<img src="./img/72x72_avatar.png" alt="" />
</div>
<div class="avatar">
<svg width="72" height="72"><use xlink:href="#symbol-user"></use></svg>
</div>
Source: src/styl/_elements/_avatar.styl
, line 1
2.5 Icon
Description
Button with icon and label.
It can be styled by btnSkin
Default styling
Modifiers
.icon-inline
inline version
Markup
- Compiled HTML
- Template
<span class="icon ">
<svg class="icon-picto">
<use xlink:href="#symbol-newspaper" />
</svg>
<span class="icon-label">
Newspaper
</span>
</span>
{%- set classes = classes|default([]) -%}
{%- if modifier_class %}{% set classes = classes|merge([modifier_class]) %}{% endif -%}
<span class="icon {{ ' ' ~ classes|join(' ') }}">
<svg class="icon-picto"><use xlink:href="#symbol-newspaper"/></svg>
<span class="icon-label">
Newspaper
</span>
</span>
Source: src/styl/_elements/_icon.styl
, line 1
2.6 Link with icon
Description
Colette comes with a basic style for a link associated with an SVG (placed in front of it).
Example
Markup
- Compiled HTML
- Template
<a class="linkIcon " href="#">
<svg height="11" width="11">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-more"></use>
</svg>
<span class="mask">Plus</span>
<span class="linkIcon-label">d’articles</span>
</a>
<a class="linkIcon {{ modifier_class }}" href="#">
<svg height="11" width="11">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-more"></use>
</svg>
<span class="mask">Plus</span>
<span class="linkIcon-label">d’articles</span>
</a>
Source: src/styl/_elements/_linkIcon.styl
, line 1
2.7 Loading
Description
Loading animation is inspired from Tobias Ahlin's Spinkit animations.
Example
Markup
- Compiled HTML
- Template
<div class="loading"></div>
<div class="loading loading-small"></div>
<div class="loading"></div>
<div class="loading loading-small"></div>
Source: src/styl/_elements/_loading.styl
, line 1
2.8 Media
Description
A media is either an image or a video, displayed with caption and/or credit mention.
- Video: videos are made responsive, on the basis of a 16/9 ratio
- Empty media: if the media (image or video) is not available for any reason, the block display a default N/A image instead
Example
Markup
- Compiled HTML
- Template
<figure class="media " role="group">
<div class="media-wrap">
<img class="" width="648" height="415" src="./img/648x415_article-preview.jpg" alt="The media caption — by someone" />
</div>
<figcaption class="media-caption">
The media caption — <em>by someone</em> </figcaption>
</figure>
{##
# Base for media blocks
#
# @param array media
# -> src
# -> caption
# -> credit
# @param string defaultFormat (optional) Images sizes format ( width x height )
# @param array mediaFormats (optional) Images sizes formats ( width x height )
# @param array sizes (optional) Images sizes attritute
# @param array classes (optional) Additional classes
# @param bool displayCaption (optional) default false
# @param bool lazyloadImg (optional) default false
#
# @block media (optional)
# @block media_img (optional)
# @block media_caption (optional)
# @block block_classes (optional)
# @block block_attributes (optional)
# @block block_title_classes (optional)
# @block block_title_attributes (optional)
#}
{%- set mediaFormats = mediaFormats is defined ? mediaFormats : [] -%}
{%- set sizes = sizes is defined ? sizes : [] -%}
{%- set classes = classes is defined ? classes : [] -%}
{%- set displayCaption = displayCaption == true -%}
{%- import '../../twig/macros/_img.twig' as _img -%}
{%- set alt = media.caption -%}
{%- if media.credit is not empty %}
{% set alt = alt ~ ' — ' ~ media.credit %}
{% endif -%}
{%- block media -%}
<figure class="media{% block block_classes %} {{ classes|join(' ') }}{% endblock %}" role="group"{% block block_attributes '' %}>
{% block media_figure %}
<div class="media-wrap">
{{ _img.img(
media.src,
defaultFormat,
mediaFormats,
alt,
lazyloadImg|default(false),
[],
'',
sizes
) }}
{% block media_rank '' %}
</div>
{% endblock %}
{% block media_caption -%}
{% if displayCaption %}
<figcaption class="media-caption">
{{ media.caption }}
{%- if media.credit is not empty %} — <em>{{ media.credit }}</em>{% endif %}
</figcaption>
{% endif %}
{%- endblock %}
</figure>
{%- endblock -%}
Source: src/styl/_elements/_media.styl
, line 1
2.8.1 Media Empty
Description
If the media (image or video) is not available for any reason, the block display a default N/A image instead
Example
Markup
- Compiled HTML
- Template
<figure class="media " role="group">
<div class="media-wrap">
<img class="" width="648" height="415" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='648'%20height='415'%3E%3C/svg%3E" alt="Missing image — by someone" />
</div>
<figcaption class="media-caption">
Missing image — <em>by someone</em> </figcaption>
</figure>
{% extends 'media.twig' %}
Source: src/styl/_elements/_media.styl
, line 23
2.8.2 Media Video
Description
Videos are made responsive, on the basis of a 16/9 ratio
Default styling
Modifiers
.media-wrap-video-1_1
1/1 video ratio
.media-wrap-video-4_3
4/3 video ratio
.media-wrap-video-5_3
5/3 video ratio
Markup
- Compiled HTML
- Template
<figure class="media " role="group">
<div class="media-wrap media-wrap-video "><iframe width="640" height="360" src="https://www.youtube.com/embed/9NC3S2eRXdo" frameborder="0" allowfullscreen></iframe></div>
</figure>
{##
# Display media with video
#
# @param string media
# -> html
# @param array classes Additional classes
#}
{% extends 'media.twig' %}
{% block media_figure %}
<div class="media-wrap media-wrap-video {{ modifier_class }}">{{ media.html|raw }}</div>
{% endblock %}
Source: src/styl/_elements/_media.styl
, line 11
2.9 Pagers
Description
Colette comes with basic styles for paginations.
The default Pager is showing no list. It's a counter that's giving you the number of the page you're on, versus the total number of pages.
Example
Markup
- Compiled HTML
- Template
<div class="pager " role="navigation" aria-label="Pagination">
<button class="pager-prev" disabled="disabled">
<svg height="13" width="13">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-left"></use>
</svg>
<span class="mask">Previous</span>
</button>
<span class="pager-count">
<span class="pager-current">1</span> on <span class="pager-max">5</span>
</span>
<button class="pager-next">
<svg height="13" width="13">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-right"></use>
</svg>
<span class="mask">Next</span>
</button>
</div>
{%- set classes = classes|default([]) -%}
{%- if modifier_class -%}{% set classes = classes|merge([modifier_class]) %}{% endif -%}
{%- set firstPage = 1 -%}
{%- set lastPage = (nbItems / nbItemsPerPage)|round(0, 'ceil') -%}
<div class="{% block classes %}pager{{ ' ' ~ classes|join(' ') }}{% endblock %}" role="navigation" aria-label="Pagination">
{% block prev %}
{% if js %}
<button class="pager-prev" {{ (currentPage <= firstPage) ? ' disabled="disabled"'|raw }}>
<svg height="13" width="13"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-left"></use></svg>
<span class="mask">Previous</span>
</button>
{% elseif (currentPage <= firstPage) %}
<span class="pager-prev" aria-hidden="true">
<svg height="13" width="13"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-left"></use></svg>
</span>
{% else %}
<a href="#" class="pager-prev">
<svg height="13" width="13"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-left"></use></svg>
<span class="mask">Previous page</span>
</a>
{% endif %}
{% endblock %}
{% block count %}
<span class="pager-count">
<span class="pager-current">{{ currentPage }}</span> on <span class="pager-max">{{ lastPage }}</span>
</span>
{% endblock %}
{% block next %}
{% if js %}
<button class="pager-next" {{ (currentPage >= lastPage) ? ' disabled="disabled"'|raw }}>
<svg height="13" width="13"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-right"></use></svg>
<span class="mask">Next</span>
</button>
{% elseif (currentPage >= lastPage) %}
<span class="pager-next" aria-hidden="true">
<svg height="13" width="13"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-right"></use></svg>
</span>
{% else %}
<a href="#" class="pager-next">
<svg height="13" width="13"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-right"></use></svg>
<span class="mask">Next page</span>
</a>
{% endif %}
{% endblock %}
{% block list '' %}
</div>
Source: src/styl/_elements/_pager.styl
, line 1
2.9.1 Pager with a list
Description
This is the list version of the Pager.
Example
Markup
- Compiled HTML
- Template
<div class="pager pager-withlist" role="navigation" aria-label="Pagination">
<span class="pager-prev" aria-hidden="true">
<svg height="13" width="13">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-left"></use>
</svg>
</span>
<a href="#" class="pager-next">
<svg height="13" width="13">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#symbol-arrow-right"></use>
</svg>
<span class="mask">Next page</span>
</a>
<ul class="pager-list">
<li><strong><span class="mask">Current page: </span>1</strong></li>
<li><a href="#"><span class="mask">Page </span>2</a></li>
<li><a href="#"><span class="mask">Page </span>3</a></li>
<li><a href="#"><span class="mask">Page </span>4</a></li>
<li><a href="#"><span class="mask">Page </span>5</a></li>
</ul>
</div>
{% extends 'pager.twig' %}
{% block classes parent() ~ ' pager-withlist' %}
{% block count '' %}
{% block list %}
<ul class="pager-list">
{%- for i in firstPage..lastPage -%}
<li>
{%- if i == currentPage -%}
<strong><span class="mask">Current page: </span>{{ i }}</strong>
{%- else -%}
<a href="#"><span class="mask">Page </span>{{ i }}</a>
{%- endif -%}
</li>
{%- endfor -%}
</ul>
{% endblock %}
Source: src/styl/_elements/_pager.styl
, line 11
2.10 Switch
Description
Switch to improve UI of a natural checkbox.
It’s possible to use a button with role="switch"
(WAI-aria switch role).
In this case it need some javascript to change aria-checked
attribute to true or false to switch it.
It can be modified by .color-*
helpers but constrast with white text must be correct.
Default styling
Checkbox version:
Button version:
Modifiers
.color-default
theme default
Checkbox version:
Button version:
Markup
- Compiled HTML
- Template
<p>Checkbox version:</p>
<label for="checkbox-switch-default">
<input id="checkbox-switch-default" type="checkbox" class="mask" />
<span class="switch " aria-hidden="true">
<span class="switch-wrap">
<span class="switch-on">Yes</span>
<svg class="switch-thumb" height="11" width="11">
<use xlink:href="#symbol-tick"></use>
</svg>
<span class="switch-off">No</span>
</span>
</span>
checkbox label
</label>
<p>Button version:</p>
<button role="switch" aria-checked="false" class="switch ">
<span class="switch-wrap">
<span class="switch-on">Yes</span>
<svg class="switch-thumb" height="11" width="11">
<use xlink:href="#symbol-tick"></use>
</svg>
<span class="switch-off">No</span>
</span>
</button>
{% set id = 'checkbox-switch-' ~ modifier_class|default('default')|replace({' ': '_'}) %}
<p>Checkbox version:</p>
<label for="{{ id }}">
<input id="{{ id }}" type="checkbox" class="mask" />
<span class="switch {{ modifier_class }}" aria-hidden="true">
<span class="switch-wrap">
<span class="switch-on">Yes</span>
<svg class="switch-thumb" height="11" width="11"><use xlink:href="#symbol-tick"></use></svg>
<span class="switch-off">No</span>
</span>
</span>
checkbox label
</label>
<p>Button version:</p>
<button role="switch" aria-checked="false" class="switch {{ modifier_class }}">
<span class="switch-wrap">
<span class="switch-on">Yes</span>
<svg class="switch-thumb" height="11" width="11"><use xlink:href="#symbol-tick"></use></svg>
<span class="switch-off">No</span>
</span>
</button>
Source: src/styl/_elements/_switch.styl
, line 1