-
Notifications
You must be signed in to change notification settings - Fork 5
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
17 changed files
with
843 additions
and
158 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
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,23 @@ | ||
import { FC } from 'react'; | ||
import { IconButton, Typography, ButtonProps } from '@mui/material'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import ArrowBackIcon from '@mui/icons-material/ArrowBack'; | ||
|
||
interface BackButtonProps extends ButtonProps { | ||
onClick?: () => void; | ||
} | ||
|
||
export const BackButton: FC<BackButtonProps> = ({ ...props }) => { | ||
const { onClick } = props; | ||
const navigate = useNavigate(); | ||
return ( | ||
<IconButton | ||
{...props} | ||
style={{ left: -10 }} | ||
onClick={() => (onClick ? onClick() : navigate(-1))} | ||
> | ||
<ArrowBackIcon /> | ||
<Typography variant="caption" /> | ||
</IconButton> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,19 +1,52 @@ | ||
import Box from '@mui/material/Box'; | ||
import { BoxProps } from '@mui/material'; | ||
import { CompactItem } from './CompactItem'; | ||
import { useCallback } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
interface EvoStashProps extends BoxProps { | ||
itemIds: string[]; | ||
onItemClick?: (index: number) => void; | ||
playerItems?: string[] | null; | ||
} | ||
|
||
export function EvoStash(props: EvoStashProps) { | ||
const { itemIds, ...rest } = props; | ||
const { itemIds, onItemClick, playerItems, ...rest } = props; | ||
const navigate = useNavigate(); | ||
|
||
const handleItemClick = useCallback( | ||
(id: string, index: number) => { | ||
if (playerItems) { | ||
navigate(`/item/${id}`, { | ||
state: { playerItems: [...(playerItems || [])] }, | ||
}); | ||
} else if (onItemClick) { | ||
onItemClick(index); | ||
} | ||
}, | ||
[onItemClick], | ||
); | ||
|
||
const getOnClickHandler = useCallback( | ||
(id: string, index: number) => { | ||
if (playerItems || onItemClick) { | ||
return () => handleItemClick(id, index); | ||
} | ||
return undefined; | ||
}, | ||
[handleItemClick, playerItems, onItemClick], | ||
); | ||
|
||
return ( | ||
<Box {...rest}> | ||
{itemIds.map((id, index) => ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<CompactItem key={id + index} id={id} /> | ||
<CompactItem | ||
key={id + index} | ||
id={id} | ||
onClick={getOnClickHandler(id, index)} | ||
/> | ||
))} | ||
</Box> | ||
); | ||
}; | ||
} |
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,65 @@ | ||
import Card from '@mui/material/Card'; | ||
import Box from '@mui/material/Box'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import Typography from '@mui/material/Typography'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { EvoStash } from '../../../components/Stash'; | ||
import StarIcon from '@mui/icons-material/Star'; | ||
import StarBorderIcon from '@mui/icons-material/StarBorder'; | ||
import { useSettingsContext } from '../../../contexts/settingsContext'; | ||
import { TBuild } from '../../../contexts/buildsContext'; | ||
import { ExportBuildButton } from './ExportBuildButton'; | ||
|
||
interface BuildCardProps { | ||
build: TBuild; | ||
playerItems?: string[] | null; | ||
} | ||
|
||
export function BuildCard({ build, playerItems }: BuildCardProps) { | ||
const navigate = useNavigate(); | ||
const { addFavouriteClass, removeFavouriteClass } = useSettingsContext(); | ||
|
||
const handleNavigate = () => { | ||
navigate(`/builds/${build.id}`, { | ||
state: { playerItems: [...(playerItems || [])] }, | ||
}); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ padding: '10px' }}> | ||
<Card | ||
sx={{ width: 280, padding: '15px', cursor: 'pointer' }} | ||
onClick={handleNavigate} | ||
> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
paddingBottom: '10px', | ||
}} | ||
> | ||
<Typography variant="body1">{build.name}</Typography> | ||
<IconButton onClick={() => console.log('favourite')}> | ||
{true ? <StarIcon /> : <StarBorderIcon />} | ||
</IconButton> | ||
</Box> | ||
<Box sx={{ paddingBottom: '10px' }}> | ||
<EvoStash | ||
sx={{ display: 'flex', flexDirection: 'row', gap: '2px' }} | ||
itemIds={build.items} | ||
playerItems={playerItems} | ||
/> | ||
</Box> | ||
<Box> | ||
<ExportBuildButton | ||
name={build.name} | ||
items={build.items} | ||
tooltipTitle="Export build (copy to clipboard)" | ||
/> | ||
</Box> | ||
</Card> | ||
</Box> | ||
); | ||
} |
Oops, something went wrong.