This repository has been archived on 2025-03-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
gardev-startpage/src/components/Pill.tsx
Georgi Gardev 8fd3d97cd1 Initial commit
2023-11-17 18:24:36 +02:00

27 lines
913 B
TypeScript

import { getAppIcon } from '~/api/get-app-icon';
import { AppDefinition } from '~/types';
import { Box } from './Box';
import { useSettings } from '~/state/SettingsProvider';
import style from './Pill.module.css';
export type PillProps = AppDefinition;
export function Pill({ url, name, icon, shortcut, location }: PillProps) {
const { appSettings } = useSettings();
return (
<Box className={style.Pill}>
<a href={url} target="_blank" rel="noopener noreferrer">
<div class={style.Text}>
<span class={style.Name}>{name}</span>
<span class={style.Url}>{url.split('://')[1].split('/')[0]}</span>
{appSettings.showLocations && location && <span class={style.Url}>{location}</span>}
</div>
<img class={style.Icon} src={getAppIcon(icon)} alt={name} />
{shortcut && <span class={style.Index}>{shortcut}</span>}
</a>
</Box>
);
}