2022-10-16 02:33:33 +00:00
|
|
|
import {IconProp} from "@fortawesome/fontawesome-svg-core"
|
|
|
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
|
|
|
import {default as Link} from "next/link"
|
|
|
|
import {default as cn} from "classnames"
|
2022-10-16 23:58:17 +00:00
|
|
|
import {default as style} from "./LinkPanel.module.css"
|
2022-10-16 02:33:33 +00:00
|
|
|
import React from "react"
|
|
|
|
|
|
|
|
|
|
|
|
export type LinkPanelProps = {
|
|
|
|
href?: string,
|
|
|
|
icon: IconProp,
|
2022-10-16 23:58:17 +00:00
|
|
|
text: React.ReactNode,
|
2023-05-28 02:37:00 +00:00
|
|
|
description?: React.ReactNode,
|
2023-05-29 01:24:24 +00:00
|
|
|
extraTop?: React.ReactNode,
|
|
|
|
extraBtm?: React.ReactNode,
|
2022-10-16 02:33:33 +00:00
|
|
|
me?: boolean,
|
|
|
|
fade?: boolean,
|
2023-12-19 03:07:47 +00:00
|
|
|
onMouseOver?: React.EventHandler<React.SyntheticEvent<HTMLElement>>
|
2023-05-28 23:18:24 +00:00
|
|
|
onPress?: React.EventHandler<React.SyntheticEvent<HTMLElement>>
|
2022-10-16 02:33:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 03:07:47 +00:00
|
|
|
export const LinkPanel = ({href, icon, text, description, extraTop, extraBtm, me, fade, onMouseOver, onPress}: LinkPanelProps) => {
|
2022-10-16 02:33:33 +00:00
|
|
|
const panel = (
|
2023-02-28 12:01:43 +00:00
|
|
|
<>
|
|
|
|
<FontAwesomeIcon className={style.linkPanelIcon} icon={icon}/>
|
|
|
|
<span className={style.linkPanelText}>
|
|
|
|
{text}
|
|
|
|
</span>
|
2023-12-19 03:07:47 +00:00
|
|
|
<span className={"lynx-only"}>
|
|
|
|
|
|
|
|
</span>
|
2023-05-29 01:24:24 +00:00
|
|
|
{extraTop &&
|
2023-12-19 03:07:47 +00:00
|
|
|
<>
|
|
|
|
<span className={style.linkPanelExtraTop}>
|
|
|
|
{extraTop}
|
|
|
|
</span>
|
|
|
|
</>
|
2023-05-29 01:24:24 +00:00
|
|
|
}
|
2023-05-28 02:37:00 +00:00
|
|
|
{description &&
|
2023-12-19 03:07:47 +00:00
|
|
|
<>
|
|
|
|
<small className={style.linkPanelDescription}>
|
|
|
|
{description}
|
|
|
|
</small>
|
|
|
|
</>
|
2023-05-28 02:37:00 +00:00
|
|
|
}
|
2023-05-29 01:24:24 +00:00
|
|
|
{extraBtm !== undefined &&
|
2023-12-19 03:07:47 +00:00
|
|
|
<>
|
|
|
|
<small className={style.linkPanelExtraBtm}>
|
|
|
|
{extraBtm}
|
|
|
|
</small>
|
|
|
|
</>
|
2023-05-29 01:24:24 +00:00
|
|
|
}
|
2023-12-19 03:07:47 +00:00
|
|
|
<span className={"lynx-only"}>
|
|
|
|
|
|
|
|
</span>
|
2023-02-28 12:01:43 +00:00
|
|
|
</>
|
2022-10-16 02:33:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if(href) {
|
|
|
|
return (
|
2023-12-19 04:07:44 +00:00
|
|
|
<Link legacyBehavior={true} href={href}>
|
2023-12-19 03:07:47 +00:00
|
|
|
<a className={cn({panel: true, [style.linkPanel]: true, fade: fade})} rel={me ? "me" : ""} onClick={onPress} onKeyPress={onPress} onMouseOver={onMouseOver}>
|
2023-01-16 15:50:50 +00:00
|
|
|
{panel}
|
2023-01-16 15:51:41 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
2022-10-16 02:33:33 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
else {
|
2023-01-16 15:50:50 +00:00
|
|
|
return (
|
2023-12-19 03:07:47 +00:00
|
|
|
<div className={cn({panel: true, [style.linkPanel]: true, fade: fade})} onClick={onPress} onKeyPress={onPress} onMouseOver={onMouseOver}>
|
2023-01-16 15:50:50 +00:00
|
|
|
{panel}
|
|
|
|
</div>
|
|
|
|
)
|
2022-10-16 02:33:33 +00:00
|
|
|
}
|
|
|
|
}
|