-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
see all civs at once with hover over for descriptions
- Loading branch information
1 parent
05dc54a
commit 35d15c4
Showing
4 changed files
with
70 additions
and
17 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,29 +1,50 @@ | ||
import { HTMLAttributes } from "react"; | ||
import { ICivData } from "../../../data/model"; | ||
import { getCivImgUrl } from "../../../helpers/tools"; | ||
import { ContentWithTooltip } from "../ContentWithTooltip"; | ||
import { SingleCivIconWrap } from "./styles"; | ||
|
||
interface SingleCivIconProps { | ||
highlight: boolean; | ||
disablePopup?: boolean; | ||
civData: ICivData; | ||
} | ||
|
||
const SingleCivIcon = ({ highlight, civData }: SingleCivIconProps) => { | ||
const SingleCivIcon = ( | ||
{ highlight, civData, disablePopup, ...props }: SingleCivIconProps | ||
& HTMLAttributes<HTMLDivElement>) => { | ||
const imgClassName = highlight ? undefined : "opacity-20"; | ||
return ( | ||
<SingleCivIconWrap> | ||
<ContentWithTooltip | ||
tooltip={ | ||
<> | ||
<span className="font-bold leading-6">{civData.value}</span> | ||
<span dangerouslySetInnerHTML={{ __html: civData.help }} /> | ||
</> | ||
} | ||
> | ||
<img src={getCivImgUrl(civData.key)} className={imgClassName} /> | ||
</ContentWithTooltip> | ||
<SingleCivIconWrap {...props}> | ||
{disablePopup && <img src={getCivImgUrl(civData.key)} className={imgClassName} />} | ||
{!disablePopup && | ||
<ContentWithTooltip | ||
tooltip={ | ||
<TooltipContent civData={civData} /> | ||
} | ||
> | ||
|
||
<img src={getCivImgUrl(civData.key)} className={imgClassName} /> | ||
</ContentWithTooltip> | ||
} | ||
</SingleCivIconWrap> | ||
); | ||
}; | ||
|
||
export default SingleCivIcon; | ||
|
||
export const TooltipContent = ({ civData }: { civData: ICivData }) => { | ||
return (<div className="flex flex-col gap-1"> | ||
<div className="flex flex-row items-start"> | ||
<span className="font-bold leading-6 grow">{civData.value}</span> | ||
<SingleCivIcon | ||
highlight | ||
disablePopup | ||
civData={civData} | ||
className="place-self-end" | ||
/> | ||
</div> | ||
<span className="text-wrap" dangerouslySetInnerHTML={{ __html: civData.help }} /> | ||
</div> | ||
) | ||
} |
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,6 +1,6 @@ | ||
import { styled } from "styled-components"; | ||
|
||
export const SingleCivIconWrap = styled.span` | ||
export const SingleCivIconWrap = styled.div` | ||
max-width: 1.75rem; | ||
max-height: 1.75rem; | ||
`; |
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