diff --git a/package-lock.json b/package-lock.json index 9c216594..f2878bf9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "diet-diary", - "version": "2.28.0", + "version": "2.29.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "diet-diary", - "version": "2.28.0", + "version": "2.29.0", "workspaces": [ "packages/parser" ], diff --git a/package.json b/package.json index 34898cbd..225597f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "diet-diary", - "version": "2.28.0", + "version": "2.29.0", "private": true, "homepage": ".", "dependencies": { diff --git a/src/components/FoodGroupLegend.tsx b/src/components/FoodGroupLegend.tsx index ca89839b..907a8289 100644 --- a/src/components/FoodGroupLegend.tsx +++ b/src/components/FoodGroupLegend.tsx @@ -5,7 +5,7 @@ import { Legend } from "./Legend"; export const FoodGroupLegend = (props: { foodGroup: FoodGroup; }) => { const { foodGroup } = props; return ( - + {displayName(foodGroup)} ); diff --git a/src/components/Legend.tsx b/src/components/Legend.tsx index 954af0bc..4d27ad23 100644 --- a/src/components/Legend.tsx +++ b/src/components/Legend.tsx @@ -1,5 +1,11 @@ -export const Legend = (props: React.PropsWithChildren) => ( -
+import _ from "lodash"; + +interface Props extends React.PropsWithChildren { + className?: string; +} + +export const Legend = (props: Props) => ( +
{props.children}
); diff --git a/src/components/day-page/DayPage.tsx b/src/components/day-page/DayPage.tsx index e366679b..b8b4821d 100644 --- a/src/components/day-page/DayPage.tsx +++ b/src/components/day-page/DayPage.tsx @@ -14,7 +14,7 @@ interface Props { function DayPage(props: Props) { return ( - +
diff --git a/src/components/summary/BestChoiceComparisonChart.tsx b/src/components/summary/BestChoiceComparisonChart.tsx index a801b591..722bead1 100644 --- a/src/components/summary/BestChoiceComparisonChart.tsx +++ b/src/components/summary/BestChoiceComparisonChart.tsx @@ -4,10 +4,12 @@ import numeral from "numeral"; interface Props { bestChoice: number; others: number; + canvasHeight: number; + columnHeight: number; } -function height(value: number, max: number) { - return value / max * 100; +function height(value: number, max: number, columnHeight: number) { + return value / max * columnHeight; } function format(val: number) { @@ -18,28 +20,27 @@ function offset(s: string) { return _.size(s) == 1 ? 5 : 0; } -const CANVAS_HEIGHT = 120; -const TEXT_HEIGHT = 5; +const Y_TEXT_OFFSET = 2; export const BestChoiceComparisonChart = (props: Props) => { - const { bestChoice, others } = props; + const { bestChoice, others, canvasHeight, columnHeight } = props; const maxHeight = _.defaultTo(_.max([bestChoice, others, 10]), 10); - const bcHeight = height(bestChoice, maxHeight); - const bcY = CANVAS_HEIGHT - bcHeight; + const bcHeight = height(bestChoice, maxHeight, columnHeight); + const bcY = canvasHeight - bcHeight; const bcVal = format(bestChoice); - const othersHight = height(others, maxHeight); - const othersY = CANVAS_HEIGHT - othersHight; + const othersHight = height(others, maxHeight, columnHeight); + const othersY = canvasHeight - othersHight; const othersVal = format(others); return ( - + - {bcVal} + {bcVal} - {othersVal} - + {othersVal} + ); } \ No newline at end of file diff --git a/src/components/summary/BestChoiceComparisonSummary.tsx b/src/components/summary/BestChoiceComparisonSummary.tsx index b2271f61..f7941590 100644 --- a/src/components/summary/BestChoiceComparisonSummary.tsx +++ b/src/components/summary/BestChoiceComparisonSummary.tsx @@ -10,7 +10,23 @@ interface Props { const ServingComparison = (props: { foodGroup: FoodGroup; bestChoice: number; others: number }) => (
- +
+ +
+
+ +
+
) diff --git a/src/components/summary/CalorieSummary.tsx b/src/components/summary/CalorieSummary.tsx index ed5f3827..d06b26ec 100644 --- a/src/components/summary/CalorieSummary.tsx +++ b/src/components/summary/CalorieSummary.tsx @@ -2,7 +2,7 @@ import { toIntString } from "../../model/calorieFunction"; export const CalorieSummary = (props: { calories: number; }) => (
-
{toIntString(props.calories)}
+
{toIntString(props.calories)}
calories
); diff --git a/src/components/summary/ServingCell.tsx b/src/components/summary/ServingCell.tsx index 715cb4a3..500e0cb8 100644 --- a/src/components/summary/ServingCell.tsx +++ b/src/components/summary/ServingCell.tsx @@ -19,7 +19,7 @@ interface Props { } export const ServingCell = (props: Props) => ( -
+
{} diff --git a/src/components/summary/ServingSummary.tsx b/src/components/summary/ServingSummary.tsx index 0ba6344d..e2f22a03 100644 --- a/src/components/summary/ServingSummary.tsx +++ b/src/components/summary/ServingSummary.tsx @@ -1,13 +1,33 @@ +import Col from "react-bootstrap/Col"; +import Row from "react-bootstrap/Row"; import { Serving } from "../../model/Food"; import { ServingCell } from "./ServingCell"; export const ServingSummary = (props: { serving: Serving; }) => ( -
- - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + ) \ No newline at end of file diff --git a/src/index.css b/src/index.css index 39bedae3..5f2faac7 100644 --- a/src/index.css +++ b/src/index.css @@ -48,8 +48,8 @@ code { font-size: smaller; } -.dd-summary-total-width { - min-width: 110px; +.dd-calorie-summary { + min-width: 90px; } .dd-blue-color {