2021-06-28 05:25:51 -04:00
|
|
|
import { Text } from "preact-i18n";
|
|
|
|
import styled from "styled-components";
|
2021-06-19 13:46:05 -04:00
|
|
|
import { Children } from "../../types/Preact";
|
2021-06-27 16:54:31 -04:00
|
|
|
import Tippy, { TippyProps } from '@tippyjs/react';
|
2021-06-19 13:46:05 -04:00
|
|
|
|
2021-06-27 16:54:31 -04:00
|
|
|
type Props = Omit<TippyProps, 'children'> & {
|
2021-06-19 13:46:05 -04:00
|
|
|
children: Children;
|
|
|
|
content: Children;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Tooltip(props: Props) {
|
2021-06-27 16:54:31 -04:00
|
|
|
const { children, content, ...tippyProps } = props;
|
|
|
|
|
2021-06-19 13:46:05 -04:00
|
|
|
return (
|
2021-06-27 16:54:31 -04:00
|
|
|
<Tippy content={content} {...tippyProps}>
|
|
|
|
{/*
|
|
|
|
// @ts-expect-error */}
|
|
|
|
<div>{ children }</div>
|
|
|
|
</Tippy>
|
2021-06-19 13:46:05 -04:00
|
|
|
);
|
|
|
|
}
|
2021-06-28 05:25:51 -04:00
|
|
|
|
|
|
|
const PermissionTooltipBase = styled.div`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
code {
|
|
|
|
font-family: 'Fira Mono';
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export function PermissionTooltip(props: Omit<Props, 'content'> & { permission: string }) {
|
|
|
|
const { permission, ...tooltipProps } = props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Tooltip content={<PermissionTooltipBase>
|
|
|
|
<Text id="app.permissions.required" />
|
|
|
|
<code>{ permission }</code>
|
|
|
|
</PermissionTooltipBase>} {...tooltipProps} />
|
|
|
|
)
|
|
|
|
}
|