-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: remove unused setCurrentTab variable * feat: persist purchasedCellar * feat: stand up basic fermentation UI * refactor: destructure propTypes * feat: create fermentation recipe type * test: add missing propType
- Loading branch information
1 parent
1efe8fe
commit de7400d
Showing
12 changed files
with
149 additions
and
39 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,7 +1,47 @@ | ||
import React from 'react' | ||
import React, { useContext, useState } from 'react' | ||
import AppBar from '@material-ui/core/AppBar' | ||
import Tab from '@material-ui/core/Tab' | ||
import Tabs from '@material-ui/core/Tabs' | ||
|
||
import { recipesMap } from '../../data/maps' | ||
import { recipeType } from '../../enums' | ||
|
||
import FarmhandContext from '../Farmhand/Farmhand.context' | ||
|
||
import { FermentationTabPanel } from './FermentationTabPanel' | ||
import { a11yProps } from './TabPanel' | ||
|
||
import './Cellar.sass' | ||
|
||
export const Cellar = () => { | ||
return <div className="Cellar"></div> | ||
const { | ||
gameState: { learnedRecipes }, | ||
} = useContext(FarmhandContext) | ||
|
||
const [currentTab, setCurrentTab] = useState(0) | ||
|
||
const learnedFermentationRecipes = Object.keys(learnedRecipes).filter( | ||
recipeId => recipesMap[recipeId].recipeType === recipeType.FERMENTATION | ||
) | ||
|
||
return ( | ||
<div className="Cellar"> | ||
<AppBar position="static" color="primary"> | ||
<Tabs | ||
value={currentTab} | ||
onChange={(_e, newTab) => setCurrentTab(newTab)} | ||
aria-label="Cellar tabs" | ||
> | ||
<Tab {...{ label: 'Fermentation', ...a11yProps(0) }} /> | ||
</Tabs> | ||
</AppBar> | ||
<FermentationTabPanel | ||
index={0} | ||
currentTab={currentTab} | ||
learnedFermentationRecipes={learnedFermentationRecipes} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
Cellar.propTypes = {} |
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,4 @@ | ||
@import ../../styles/utils.sass | ||
|
||
.Cellar | ||
@include center-tabs |
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,47 @@ | ||
import React from 'react' | ||
import { number, array } from 'prop-types' | ||
import Divider from '@material-ui/core/Divider' | ||
import Card from '@material-ui/core/Card' | ||
import CardContent from '@material-ui/core/CardContent' | ||
import ReactMarkdown from 'react-markdown' | ||
|
||
import { recipeType } from '../../enums' | ||
import { recipeCategories } from '../../data/maps' | ||
import { RecipeList } from '../RecipeList/RecipeList' | ||
|
||
import { TabPanel } from './TabPanel' | ||
|
||
export const FermentationTabPanel = ({ | ||
index, | ||
currentTab, | ||
learnedFermentationRecipes, | ||
}) => ( | ||
<TabPanel value={currentTab} index={index}> | ||
<RecipeList | ||
learnedRecipes={learnedFermentationRecipes} | ||
allRecipes={recipeCategories[recipeType.FERMENTATION]} | ||
/> | ||
<Divider /> | ||
<ul className="card-list"> | ||
<li> | ||
<Card> | ||
<CardContent> | ||
<ReactMarkdown | ||
{...{ | ||
linkTarget: '_blank', | ||
className: 'markdown', | ||
source: `Fermentation recipes are learned by selling crops. Sell as much as you can of a wide variety of items!`, | ||
}} | ||
/> | ||
</CardContent> | ||
</Card> | ||
</li> | ||
</ul> | ||
</TabPanel> | ||
) | ||
|
||
FermentationTabPanel.propTypes = { | ||
currentTab: number.isRequired, | ||
index: number.isRequired, | ||
learnedFermentationRecipes: array.isRequired, | ||
} |
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,29 @@ | ||
import React from 'react' | ||
import { node, number } from 'prop-types' | ||
|
||
export const TabPanel = props => { | ||
const { children, value, index, ...other } = props | ||
|
||
return ( | ||
<section | ||
role="tabpanel" | ||
hidden={value !== index} | ||
id={`cellar-tabpanel-${index}`} | ||
aria-labelledby={`cellar-tab-${index}`} | ||
{...other} | ||
> | ||
{value === index ? children : null} | ||
</section> | ||
) | ||
} | ||
|
||
TabPanel.propTypes = { | ||
children: node, | ||
index: number.isRequired, | ||
value: number.isRequired, | ||
} | ||
|
||
export const a11yProps = index => ({ | ||
id: `cellar-tab-${index}`, | ||
'aria-controls': `cellar-tabpanel-${index}`, | ||
}) |
File renamed without changes.
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
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