Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Add extra button for increment (minor)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Cuadra committed Sep 22, 2018
1 parent d83b719 commit 3c740c3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 25 deletions.
59 changes: 42 additions & 17 deletions src/plan/Macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,64 @@ const { className, styles } = css.resolve`span {
}`;

class Macro extends Component {
state = {};
render() {
const { decrement, increment, onAction, name, target, total } = this.props;
const percent = numeral(total / target).format('0%');
const {
decrement,
incrementLow,
incrementHigh,
onAction,
name,
target,
total,
} = this.props;
return (
<div>
<Typography use="overline" className="pl-4">
{upperFirst(name)}
</Typography>{' '}
<Typography use="body1">
{formatNumber(target - total)} to {formatNumber(target)}g
</Typography>
<div className="mb-4">
<div className="title px-4">
<div>
<Typography use="headline6">
{formatNumber(target - total)}g
</Typography>
<Typography use="caption"> to {formatNumber(target)}g</Typography>
</div>
<Typography use="overline" className="pl-4">
{upperFirst(name)}
</Typography>
</div>

<ListDivider />
<div className="macro">

<div className="macro mt-4">
<div className="chart">
<MacroRing name={name} total={total} target={target} />

<Typography className={className} use="caption">
{percent}
{formatNumber(total)}g
</Typography>
</div>

<div>
<Fab
className="mr-4"
className="mr-2"
onClick={function handleMacroActionRemove() {
onAction({ action: 'subtract', macro: name, value: decrement });
}}
label={`${decrement}`}
icon="remove"
/>
<Fab
className="mr-4"
onClick={function handleMacroActionAdd() {
onAction({ action: 'add', macro: name, value: increment });
className="mr-2"
onClick={function handleMacroActionAddLow() {
onAction({ action: 'add', macro: name, value: incrementLow });
}}
label={`${increment}`}
label={`${incrementLow}`}
icon="add"
/>
<Fab
className="mr-2"
onClick={function handleMacroActionAddHigh() {
onAction({ action: 'add', macro: name, value: incrementHigh });
}}
label={`${incrementHigh}`}
icon="add"
/>
</div>
Expand All @@ -75,6 +96,10 @@ class Macro extends Component {
align-items: center;
justify-content: space-between;
}
.title {
display: flex;
justify-content: space-between;
}
`}</style>
</div>
);
Expand Down
19 changes: 11 additions & 8 deletions src/plan/Plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ class Plan extends React.Component {

const hasRecipesMinimum = recipes.size < RECIPES_MINIMUM;

const styleBanner = isWorkoutDay ? { style: { display: 'none' } } : {};
return (
<div className="plan">
<div
className="banner text-center"
style={isWorkoutDay ? { display: 'none' } : {}}
>
<div className="banner text-center" {...styleBanner}>
<Typography use="subtitle1" theme="onSecondary">
Workout Day
</Typography>
Expand All @@ -64,7 +62,9 @@ class Plan extends React.Component {
<div className="flex justify-between px-4 py-6 items-center">
<Typography use="headline5">
{numeral(macros.calories - tracker.calories).format('0,0')}{' '}
to {numeral(macros.calories).format('0,0')} cal
<Typography use="subtitle1">
to {numeral(macros.calories).format('0,0')} cal
</Typography>
</Typography>
<Button onClick={() => handleTracker({ action: 'reset' })}>
Reset
Expand All @@ -84,23 +84,26 @@ class Plan extends React.Component {

<Macro
decrement={1}
increment={10}
incrementLow={5}
incrementHigh={10}
name="carbs"
target={macros.carbs}
total={tracker.carbs}
onAction={handleTracker}
/>
<Macro
decrement={1}
increment={5}
incrementLow={5}
incrementHigh={10}
name="protein"
target={macros.protein}
total={tracker.protein}
onAction={handleTracker}
/>
<Macro
decrement={1}
increment={5}
incrementLow={5}
incrementHigh={10}
name="fat"
target={macros.fat}
total={tracker.fat}
Expand Down

0 comments on commit 3c740c3

Please sign in to comment.