Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nutritional thresholds #52

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions _data/nutrients.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 7 additions & 2 deletions _includes/nutritional-information.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ <h4 class="blue mt0 mb2 xs-center">Nutritional Information
{% assign name = site.data.nutrients[itemprop].name %}
{% assign value = nutrient.last %}
{% assign unit = site.data.nutrients[itemprop].unit %}
<div class="rounded center border border-1 border-gray sm-col sm-col-2 lg-col-1 mr1 mb1">
<h5 class="bg-gray white m0 p1 capitalize">{{ name }}</h5>
{% 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 %}
<div class="rounded center border border-1 border-{{ colour }} sm-col sm-col-2 lg-col-2 mr1 mb1">
<h5 class="bg-{{ colour }} white m0 p1 capitalize">{{ name }}</h5>
<p itemprop="{{ itemprop }}">{{ value }}{{ unit }}</p>
</div>
{% endfor %}
Expand Down