mirror of https://github.com/gabehf/Koito.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
import React, { useState } from "react";
|
|
import Popup from "../Popup";
|
|
import { Link } from "react-router";
|
|
|
|
interface Props {
|
|
name: string;
|
|
to?: string;
|
|
onClick: Function;
|
|
children: React.ReactNode;
|
|
modal: React.ReactNode;
|
|
keyHint?: React.ReactNode;
|
|
space?: number
|
|
externalLink?: boolean
|
|
/* true if the keyhint is an icon and not text */
|
|
icon?: boolean
|
|
}
|
|
|
|
export default function SidebarItem({ externalLink, space, keyHint, name, to, children, modal, onClick, icon }: Props) {
|
|
const classes = "hover:cursor-pointer hover:bg-(--color-bg-tertiary) transition duration-100 rounded-md p-2 inline-block";
|
|
|
|
const popupInner = keyHint ? (
|
|
<div className="flex items-center gap-2">
|
|
<span>{name}</span>
|
|
{icon ?
|
|
<div>
|
|
{keyHint}
|
|
</div>
|
|
:
|
|
<kbd className="px-1 text-sm rounded bg-(--color-bg-tertiary) text-(--color-fg) border border-[var(--color-fg)]">
|
|
{keyHint}
|
|
</kbd>
|
|
}
|
|
</div>
|
|
) : name;
|
|
|
|
return (
|
|
<>
|
|
<Popup position="right" space={space ?? 20} inner={popupInner}>
|
|
{to ? (
|
|
<Link target={externalLink ? "_blank" : ""} className={classes} to={to}>{children}</Link>
|
|
) : (
|
|
<a className={classes} onClick={() => onClick()}>{children}</a>
|
|
)}
|
|
</Popup>
|
|
{modal}
|
|
</>
|
|
);
|
|
}
|