wallet-core/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx

20 lines
654 B
TypeScript
Raw Normal View History

import { VNode } from "preact";
2021-07-12 19:47:13 +02:00
import { useState } from "preact/hooks";
import arrowDown from '../../static/img/chevron-down.svg';
import { ErrorBox } from "./styled";
export function ErrorMessage({ title, description }: { title?: string|VNode; description?: string; }) {
2021-07-12 19:47:13 +02:00
const [showErrorDetail, setShowErrorDetail] = useState(false);
if (!title)
return null;
return <ErrorBox>
<div>
<p>{title}</p>
{ description && <button onClick={() => { setShowErrorDetail(v => !v); }}>
<img style={{ height: '1.5em' }} src={arrowDown} />
</button> }
</div>
{showErrorDetail && <p>{description}</p>}
</ErrorBox>;
}