-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
438 additions
and
1,466 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from 'react' | ||
import { number, object } from 'prop-types' | ||
|
||
import Box from '@material-ui/core/Box' | ||
import CircularProgress from '@material-ui/core/CircularProgress' | ||
import Tooltip from '@material-ui/core/Tooltip' | ||
|
||
import FarmhandContext from '../Farmhand/Farmhand.context' | ||
|
||
import { levelAchieved } from '../../utils/levelAchieved' | ||
import { | ||
experienceNeededForLevel, | ||
integerString, | ||
scaleNumber, | ||
} from '../../utils' | ||
|
||
export function DayAndProgressContainer({ dayCount, experience, itemsSold }) { | ||
const currentLevel = levelAchieved(experience) | ||
|
||
const levelPercent = scaleNumber( | ||
experience, | ||
experienceNeededForLevel(currentLevel), | ||
experienceNeededForLevel(currentLevel + 1), | ||
0, | ||
100 | ||
) | ||
|
||
const tooltipText = `${integerString( | ||
experienceNeededForLevel(currentLevel + 1) - experience | ||
)} more experience points needed to reach level ${integerString( | ||
currentLevel + 1 | ||
)}` | ||
|
||
return ( | ||
<h2 className="day-and-progress-container"> | ||
<span>Day {integerString(dayCount)}, level:</span> | ||
<Tooltip | ||
{...{ | ||
arrow: true, | ||
placement: 'top', | ||
title: tooltipText, | ||
}} | ||
> | ||
<Box> | ||
<CircularProgress | ||
{...{ | ||
value: levelPercent, | ||
variant: 'determinate', | ||
}} | ||
/> | ||
<span {...{ className: 'current-level' }}> | ||
{integerString(currentLevel)} | ||
</span> | ||
</Box> | ||
</Tooltip> | ||
</h2> | ||
) | ||
} | ||
|
||
DayAndProgressContainer.propTypes = { | ||
dayCount: number.isRequired, | ||
experience: number.isRequired, | ||
itemsSold: object.isRequired, | ||
} | ||
|
||
export default function Consumer(props) { | ||
return ( | ||
<FarmhandContext.Consumer> | ||
{({ gameState, handlers }) => ( | ||
<DayAndProgressContainer {...{ ...gameState, ...handlers, ...props }} /> | ||
)} | ||
</FarmhandContext.Consumer> | ||
) | ||
} |
Oops, something went wrong.
91a9c63
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
farmhand – ./
farmhand.vercel.app
farmhand-jeremyckahn.vercel.app
farmhand-git-main-jeremyckahn.vercel.app
farmhand.life
www.farmhand.life