-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add term details for HRAO and Rome Consul (#290)
- Loading branch information
Showing
26 changed files
with
227 additions
and
213 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.icon { | ||
margin-top: -5px; | ||
vertical-align: middle; | ||
user-select: none; | ||
margin-right: 2px; | ||
} |
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,53 @@ | ||
import Image, { StaticImageData } from 'next/image' | ||
import { Link } from "@mui/material" | ||
|
||
import { Tooltip } from '@mui/material' | ||
import HraoIcon from '@/images/icons/hrao.svg' | ||
import RomeConsulIcon from '@/images/icons/romeConsul.svg' | ||
import styles from './TermLink.module.css' | ||
import { useGameContext } from '@/contexts/GameContext' | ||
import SelectedDetail from '@/types/selectedDetail' | ||
|
||
// Map of term names to images | ||
const termImages: { [key: string]: StaticImageData } = { | ||
"HRAO": HraoIcon, | ||
"Rome Consul": RomeConsulIcon | ||
} | ||
|
||
interface TermLinkProps { | ||
name: string, | ||
displayName?: string, | ||
tooltipTitle?: string, | ||
includeIcon?: boolean | ||
} | ||
|
||
// Icon link for a game term | ||
const TermLink = ({ name, displayName, tooltipTitle, includeIcon }: TermLinkProps) => { | ||
const { setSelectedDetail } = useGameContext() | ||
|
||
// Use the name to get the correct image | ||
const getIcon = (): StaticImageData | string => { | ||
if (termImages.hasOwnProperty(name)) return termImages[name] | ||
else return "" | ||
} | ||
|
||
const handleClick = () => { | ||
setSelectedDetail({type: "Term", name: name} as SelectedDetail) | ||
} | ||
|
||
// Get the JSX for the link | ||
const getLink = () => ( | ||
<Link onClick={handleClick} sx={{ verticalAlign: "baseline", userSelect: 'auto', cursor: 'pointer' }}> | ||
{includeIcon && <Image src={getIcon()} height={28} width={28} alt={`${name} Icon`} className={styles.icon} />} | ||
{displayName ?? name} | ||
</Link> | ||
) | ||
|
||
if (tooltipTitle) { | ||
return <Tooltip title={tooltipTitle} enterDelay={500} arrow>{getLink()}</Tooltip> | ||
} else { | ||
return getLink() | ||
} | ||
} | ||
|
||
export default TermLink |
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
Oops, something went wrong.