From f58f127cd5bffe97feedbf9ef1082f7e28dfa822 Mon Sep 17 00:00:00 2001 From: Rue Turner Date: Wed, 25 Nov 2020 16:10:13 +0000 Subject: [PATCH 1/2] Add nutritional thresholds Gives useful traffic light colours to nutritional information. --- _data/nutrients.yml | 8 ++++++++ _includes/nutritional-information.html | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/_data/nutrients.yml b/_data/nutrients.yml index f1e72cc82..01a0f9bfe 100644 --- a/_data/nutrients.yml +++ b/_data/nutrients.yml @@ -24,6 +24,8 @@ fatContent: type: Mass description: The number of grams of fat. unit: g + low: 3 + high: 17.5 fiberContent: name: fiber type: Mass @@ -39,16 +41,22 @@ saturatedFatContent: type: Mass description: The number of grams of saturated fat. unit: g + low: 1.5 + high: 5 sodiumContent: name: sodium type: Mass description: The number of milligrams of sodium. unit: mg + low: 140 + high: 400 sugarContent: name: sugar type: Mass description: The number of grams of sugar. unit: g + low: 5 + high: 22.5 transFatContent: name: trans fat type: Mass diff --git a/_includes/nutritional-information.html b/_includes/nutritional-information.html index 6477cf75f..e7bb1cd09 100644 --- a/_includes/nutritional-information.html +++ b/_includes/nutritional-information.html @@ -12,8 +12,13 @@

Nutritional Information {% assign name = site.data.nutrients[itemprop].name %} {% assign value = nutrient.last %} {% assign unit = site.data.nutrients[itemprop].unit %} -
-
{{ name }}
+ {% assign low = site.data.nutrients[itemprop].low %} + {% assign high = site.data.nutrients[itemprop].high %} + {% assign colour = 'gray' %} + {% if value <= low %}{% assign colour = 'olive' %}{% endif %} + {% if value >= high %}{% assign colour = 'orange' %}{% endif %} +
+
{{ name }}

{{ value }}{{ unit }}

{% endfor %} From cb5a276ea0bf929412c03b8fefa39b01a86f8e76 Mon Sep 17 00:00:00 2001 From: Rue Turner Date: Wed, 25 Nov 2020 16:22:21 +0000 Subject: [PATCH 2/2] fix typo --- _includes/nutritional-information.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/nutritional-information.html b/_includes/nutritional-information.html index e7bb1cd09..fd7e0a114 100644 --- a/_includes/nutritional-information.html +++ b/_includes/nutritional-information.html @@ -17,7 +17,7 @@

Nutritional Information {% assign colour = 'gray' %} {% if value <= low %}{% assign colour = 'olive' %}{% endif %} {% if value >= high %}{% assign colour = 'orange' %}{% endif %} -
+
{{ name }}

{{ value }}{{ unit }}