Group components by version released

This commit is contained in:
Robbie Trencheny 2016-10-24 02:33:26 -07:00
parent a420dd20e7
commit bd65e43d08
2 changed files with 23 additions and 3 deletions

View File

@ -398,6 +398,14 @@ p.note {
margin: 12px 0; margin: 12px 0;
} }
.added_in_current_version {
margin-top: 12px;
}
.added_two_versions_ago {
margin-bottom: 12px;
}
.btn { .btn {
display: block; display: block;
background: 0; background: 0;
@ -472,4 +480,4 @@ a code {
twitterwidget { twitterwidget {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
} }

View File

@ -18,17 +18,27 @@ regenerate: true
{% assign tot = count | minus: nocat %} {% assign tot = count | minus: nocat %}
{% assign components = site.components | sort: 'title' %} {% assign components = site.components | sort: 'title' %}
{% assign categories = components | sort: 'ha_category' | map: 'ha_category' | uniq %} {% assign categories = components | sort: 'ha_category' | map: 'ha_category' | uniq %}
{% capture current_version %}{{ site.current_major_version }}.{{ site.current_minor_version }}{% endcapture %}
{% assign added_one_ago_minor_version = site.current_minor_version|minus: 1 %}
{% capture added_one_ago_version %}{{ site.current_major_version }}.{{ added_one_ago_minor_version }}{% endcapture %}
{% assign added_two_ago_minor_version = site.current_minor_version|minus: 2 %}
{% capture added_two_ago_version %}{{ site.current_major_version }}.{{ added_two_ago_minor_version }}{% endcapture %}
{% assign current_version_components_count = site.components | where: 'ha_release', current_version | size %}
{% assign one_ago_version_components_count = site.components | where: 'ha_release', added_one_ago_version | size %}
{% assign two_ago_version_components_count = site.components | where: 'ha_release', added_two_ago_version | size %}
<p class='note'> <p class='note'>
Support for these components is provided by the Home Assistant community. Support for these components is provided by the Home Assistant community.
</p> </p>
<div class="grid"> <div class="grid">
<div class="grid__item one-sixth lap-one-whole palm-one-whole"> <div class="grid__item one-sixth lap-one-whole palm-one-whole">
<div class="filter-button-group"> <div class="filter-button-group">
<a href='#all' class="btn">All ({{tot}})</a> <a href='#all' class="btn">All ({{tot}})</a>
<a href='#featured' class="btn featured">Featured</a> <a href='#featured' class="btn featured">Featured</a>
<a href='#added_in_current_version' class="btn added_in_current_version">Added in {{ current_version }} ({{ current_version_components_count }})</a>
<a href='#added_one_version_ago' class="btn added_one_version_ago">Added in {{ added_one_ago_version }} ({{ one_ago_version_components_count }})</a>
<a href='#added_two_versions_ago' class="btn added_two_versions_ago">Added in {{ added_two_ago_version }} ({{ two_ago_version_components_count }})</a>
{% for category in categories %} {% for category in categories %}
{% if category and category != 'Other' %} {% if category and category != 'Other' %}
@ -45,8 +55,10 @@ Support for these components is provided by the Home Assistant community.
<div class="grid__item five-sixths lap-one-whole palm-one-whole" id="componentContainer"> <div class="grid__item five-sixths lap-one-whole palm-one-whole" id="componentContainer">
{% for component in components %} {% for component in components %}
{% if component.ha_category %} {% if component.ha_category %}
{% assign sliced_version = component.ha_release | split: '.' %}
{% assign minor_version = sliced_version[1]|plus: 0 %}
<a href='{{ component.url }}' <a href='{{ component.url }}'
class='{{ component.ha_category | slugify }}{% if component.featured %} featured{% endif %}' class='{{ component.ha_category | slugify }}{% if minor_version == site.current_minor_version %} added_in_current_version{% elsif minor_version == added_one_ago_minor_version %} added_one_version_ago{% elsif minor_version == added_two_ago_minor_version %} added_two_versions_ago{% endif %}{% if component.featured %} featured{% endif %}'
{% unless component.featured %}style='display: none'{% endunless %}> {% unless component.featured %}style='display: none'{% endunless %}>
<div class='img-container'> <div class='img-container'>
{% if component.logo %} {% if component.logo %}