mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-19 07:55:25 +02:00
added AliasTypeIndicator.tsx
This commit is contained in:
parent
3c9918e8b7
commit
1998b430a0
32
src/components/AliasTypeIndicator.tsx
Normal file
32
src/components/AliasTypeIndicator.tsx
Normal file
@ -0,0 +1,32 @@
|
||||
import {ReactElement} from "react"
|
||||
import {FaHashtag, FaRandom} from "react-icons/fa"
|
||||
|
||||
import {Box, Tooltip} from "@mui/material"
|
||||
|
||||
import {AliasType} from "~/server-types"
|
||||
|
||||
export interface AliasTypeIndicatorProps {
|
||||
type: AliasType
|
||||
}
|
||||
|
||||
const ALIAS_TYPE_ICON_MAP: Record<AliasType, ReactElement> = {
|
||||
[AliasType.RANDOM]: <FaRandom />,
|
||||
[AliasType.CUSTOM]: <FaHashtag />,
|
||||
}
|
||||
|
||||
const ALIAS_TYPE_TOOLTIP_MAP: Record<AliasType, string> = {
|
||||
[AliasType.RANDOM]: "This is a randomly generated alias",
|
||||
[AliasType.CUSTOM]: "This is a custom-made alias",
|
||||
}
|
||||
|
||||
export default function AliasTypeIndicator({
|
||||
type,
|
||||
}: AliasTypeIndicatorProps): ReactElement {
|
||||
return (
|
||||
<Tooltip title={ALIAS_TYPE_TOOLTIP_MAP[type]} arrow>
|
||||
<Box display="flex" justifyContent="center" alignItems="center">
|
||||
{ALIAS_TYPE_ICON_MAP[type]}
|
||||
</Box>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
@ -4,6 +4,7 @@ import {FaHashtag, FaRandom} from "react-icons/fa"
|
||||
import {ListItemButton, ListItemIcon, ListItemText} from "@mui/material"
|
||||
|
||||
import {AliasList, AliasType} from "~/server-types"
|
||||
import AliasTypeIndicator from "~/components/AliasTypeIndicator"
|
||||
|
||||
export interface AliasListItemProps {
|
||||
alias: AliasList
|
||||
@ -21,7 +22,9 @@ export default function AliasListItem({
|
||||
|
||||
return (
|
||||
<ListItemButton href={`/aliases/${btoa(address)}`}>
|
||||
<ListItemIcon>{ALIAS_TYPE_ICON_MAP[alias.type]}</ListItemIcon>
|
||||
<ListItemIcon>
|
||||
<AliasTypeIndicator type={alias.type} />
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={address} />
|
||||
</ListItemButton>
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user