ActivityCalendar
composantActivity over time: a cell per day, each read through its label, the colour never standing alone. Wider than the screen, it scrolls by itself and takes the focus to do so.
Aperçu
- No contribution on 1 March
- 4 contributions on 2 March
LessMore
Code
<twig:ActivityCalendar label="Contributions" :offset="2" :days="[{level: 0, label: 'No contribution on 1 March'}, {level: 3, label: '4 contributions on 2 March'}]" lessLabel="Less" moreLabel="More" />
- No contribution on 1 March
- 4 contributions on 2 March
LessMore
Code
<twig:ActivityCalendar label="Contributions" :offset="2" :days="[{level: 0, label: 'No contribution on 1 March'}, {level: 3, label: '4 contributions on 2 March'}]" lessLabel="Less" moreLabel="More" />
Installation
php bin/console ux:install activity-calendar --kit=github.com/parler-haut-interagir-librement/ux-kit
Propriétés
| Propriété | Type | Par défaut | Description |
|---|---|---|---|
offset |
int |
0 |
The empty cells before the first day, from 0 to 6, so that it sits on its weekday. |
lessLabel |
string|null |
null |
The word at the low end of the legend, which needs both ends. |
moreLabel |
string|null |
null |
The word at the high end of the legend, which needs both ends. |
Accessibility
The list is named by label and each day read through its own. Levels run from 0 to 4 and two levels apart reach 3:1, under forced colours each cell keeps a border.
Fichiers à copier
templates/components/ActivityCalendar.html.twig
{#-
# Activity over time: a cell per day, seven rows, as many columns as there are weeks. Each day is read through its
# label, the colour never standing alone; the calendar scrolls by itself and takes the focus to do so.
#}
{%- props
## array The days in order, each a map of `level`, from 0 to 4, and `label`.
days,
## string What screen readers call the calendar.
label,
## int The empty cells before the first day, from 0 to 6, so that it sits on its weekday.
offset = 0,
## string|null The word at the low end of the legend, which needs both ends.
lessLabel = null,
## string|null The word at the high end of the legend, which needs both ends.
moreLabel = null
-%}
<div{{ attributes.defaults({class: 'hasActivityCalendar'}) }}>
<ol class="isActivityCalendar" aria-label="{{ label }}" tabindex="0">
{%- if offset > 0 -%}{%- for blank in 1..min(offset, 6) -%}<li class="isActivityCalendarBlank" aria-hidden="true"></li>{%- endfor -%}{%- endif -%}
{%- for day in days -%}<li class="isActivityCalendarDay" data-level="{{ max(0, min(4, day.level)) }}" title="{{ day.label }}"><span class="isVisuallyHidden">{{ day.label }}</span></li>{%- endfor -%}
</ol>
{%- if lessLabel is not null and moreLabel is not null -%}
<p class="isActivityLegend"><span>{{ lessLabel }}</span>{%- for level in 0..4 -%}<span class="isActivityCalendarDay" data-level="{{ level }}" aria-hidden="true"></span>{%- endfor -%}<span>{{ moreLabel }}</span></p>
{%- endif -%}
</div>