2021-07-01 12:36:34 -04:00
|
|
|
import { InfoCircle } from "@styled-icons/boxicons-regular";
|
2021-07-05 06:23:23 -04:00
|
|
|
import styled, { css } from "styled-components";
|
|
|
|
|
|
|
|
import { Children } from "../../types/Preact";
|
2021-07-01 12:36:34 -04:00
|
|
|
|
|
|
|
interface Props {
|
2021-07-05 06:25:20 -04:00
|
|
|
warning?: boolean;
|
|
|
|
error?: boolean;
|
2021-07-01 12:36:34 -04:00
|
|
|
}
|
2021-06-18 09:20:57 -04:00
|
|
|
|
2021-07-04 14:15:38 -04:00
|
|
|
export const Separator = styled.div<Props>`
|
2021-07-05 06:25:20 -04:00
|
|
|
height: 1px;
|
|
|
|
width: calc(100% - 10px);
|
|
|
|
background: var(--secondary-header);
|
|
|
|
margin: 18px auto;
|
2021-07-04 14:15:38 -04:00
|
|
|
`;
|
|
|
|
|
2021-07-01 12:36:34 -04:00
|
|
|
export const TipBase = styled.div<Props>`
|
2021-07-05 06:25:20 -04:00
|
|
|
display: flex;
|
|
|
|
padding: 12px;
|
|
|
|
overflow: hidden;
|
|
|
|
align-items: center;
|
2021-06-18 09:20:57 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
font-size: 14px;
|
|
|
|
background: var(--primary-header);
|
2021-07-10 10:42:13 -04:00
|
|
|
border-radius: var(--border-radius);
|
2021-07-05 06:25:20 -04:00
|
|
|
border: 2px solid var(--secondary-header);
|
2021-06-18 09:20:57 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
a {
|
|
|
|
cursor: pointer;
|
|
|
|
&:hover {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
}
|
2021-06-18 10:57:08 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
svg {
|
|
|
|
flex-shrink: 0;
|
|
|
|
margin-inline-end: 10px;
|
|
|
|
}
|
2021-07-01 12:36:34 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
${(props) =>
|
|
|
|
props.warning &&
|
|
|
|
css`
|
|
|
|
color: var(--warning);
|
|
|
|
border: 2px solid var(--warning);
|
|
|
|
background: var(--secondary-header);
|
|
|
|
`}
|
2021-07-01 12:36:34 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
${(props) =>
|
|
|
|
props.error &&
|
|
|
|
css`
|
|
|
|
color: var(--error);
|
|
|
|
border: 2px solid var(--error);
|
|
|
|
background: var(--secondary-header);
|
|
|
|
`}
|
2021-06-18 09:20:57 -04:00
|
|
|
`;
|
|
|
|
|
2021-07-24 14:39:41 -04:00
|
|
|
export default function Tip(
|
|
|
|
props: Props & { children: Children; hideSeparator?: boolean },
|
|
|
|
) {
|
|
|
|
const { children, hideSeparator, ...tipProps } = props;
|
2021-07-05 06:25:20 -04:00
|
|
|
return (
|
|
|
|
<>
|
2021-07-24 14:39:41 -04:00
|
|
|
{!hideSeparator && <Separator />}
|
2021-07-05 06:25:20 -04:00
|
|
|
<TipBase {...tipProps}>
|
|
|
|
<InfoCircle size={20} />
|
2021-08-05 09:47:00 -04:00
|
|
|
<span>{children}</span>
|
2021-07-05 06:25:20 -04:00
|
|
|
</TipBase>
|
|
|
|
</>
|
|
|
|
);
|
2021-06-18 09:20:57 -04:00
|
|
|
}
|