2021-07-05 06:23:23 -04:00
|
|
|
import Tippy, { TippyProps } from "@tippyjs/react";
|
2021-06-28 05:25:51 -04:00
|
|
|
import styled from "styled-components";
|
2021-07-05 06:23:23 -04:00
|
|
|
|
|
|
|
import { Text } from "preact-i18n";
|
|
|
|
|
2021-06-19 13:46:05 -04:00
|
|
|
import { Children } from "../../types/Preact";
|
|
|
|
|
2021-07-05 06:23:23 -04:00
|
|
|
type Props = Omit<TippyProps, "children"> & {
|
2021-07-05 06:25:20 -04:00
|
|
|
children: Children;
|
|
|
|
content: Children;
|
2021-07-05 06:23:23 -04:00
|
|
|
};
|
2021-06-19 13:46:05 -04:00
|
|
|
|
|
|
|
export default function Tooltip(props: Props) {
|
2021-07-05 06:25:20 -04:00
|
|
|
const { children, content, ...tippyProps } = props;
|
2021-06-27 16:54:31 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
return (
|
|
|
|
<Tippy content={content} {...tippyProps}>
|
|
|
|
{/*
|
2021-06-27 16:54:31 -04:00
|
|
|
// @ts-expect-error */}
|
2021-08-04 05:51:53 -04:00
|
|
|
<div style={`display: flex;`}>{children}</div>
|
2021-07-05 06:25:20 -04:00
|
|
|
</Tippy>
|
|
|
|
);
|
2021-06-19 13:46:05 -04:00
|
|
|
}
|
2021-06-28 05:25:51 -04:00
|
|
|
|
|
|
|
const PermissionTooltipBase = styled.div`
|
2021-07-05 06:25:20 -04:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
span {
|
|
|
|
font-weight: 700;
|
|
|
|
text-transform: uppercase;
|
|
|
|
color: var(--secondary-foreground);
|
|
|
|
font-size: 11px;
|
|
|
|
}
|
|
|
|
|
|
|
|
code {
|
2021-07-25 09:26:45 -04:00
|
|
|
font-family: var(--monospace-font);
|
2021-07-05 06:25:20 -04:00
|
|
|
}
|
2021-06-28 05:25:51 -04:00
|
|
|
`;
|
|
|
|
|
2021-07-05 06:23:23 -04:00
|
|
|
export function PermissionTooltip(
|
2021-07-05 06:25:20 -04:00
|
|
|
props: Omit<Props, "content"> & { permission: string },
|
2021-07-05 06:23:23 -04:00
|
|
|
) {
|
2021-07-05 06:25:20 -04:00
|
|
|
const { permission, ...tooltipProps } = props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Tooltip
|
|
|
|
content={
|
|
|
|
<PermissionTooltipBase>
|
|
|
|
<span>
|
|
|
|
<Text id="app.permissions.required" />
|
|
|
|
</span>
|
|
|
|
<code>{permission}</code>
|
|
|
|
</PermissionTooltipBase>
|
|
|
|
}
|
|
|
|
{...tooltipProps}
|
|
|
|
/>
|
|
|
|
);
|
2021-06-28 05:25:51 -04:00
|
|
|
}
|