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

50 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-09-13 18:33:13 +02:00
/*
This file is part of GNU Taler
(C) 2019 Taler Systems SA
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
import { h, VNode } from "preact";
2021-07-12 19:47:13 +02:00
import { useState } from "preact/hooks";
2022-03-24 20:02:38 +01:00
import arrowDown from "../svg/chevron-down.svg";
2022-03-29 04:41:07 +02:00
import { ErrorBox } from "./styled/index.js";
2021-07-12 19:47:13 +02:00
2021-11-15 15:18:58 +01:00
export function ErrorMessage({
title,
description,
}: {
2022-02-23 19:18:37 +01:00
title: VNode;
2021-11-15 15:18:58 +01:00
description?: string;
2021-11-29 18:11:32 +01:00
}): VNode | null {
2021-07-12 19:47:13 +02:00
const [showErrorDetail, setShowErrorDetail] = useState(false);
2021-11-15 15:18:58 +01:00
return (
<ErrorBox style={{ paddingTop: 0, paddingBottom: 0 }}>
<div>
<p>{title}</p>
{description && (
<button
onClick={() => {
setShowErrorDetail((v) => !v);
}}
>
2022-03-24 20:02:38 +01:00
<div
style={{ height: "1.5em" }}
dangerouslySetInnerHTML={{ __html: arrowDown }}
/>
2021-11-15 15:18:58 +01:00
</button>
)}
</div>
{showErrorDetail && <p>{description}</p>}
</ErrorBox>
);
2021-07-12 19:47:13 +02:00
}