diff --git a/src/bootstrap/DownloadButton.js b/src/bootstrap/DownloadButton.js new file mode 100644 index 0000000..8b3d043 --- /dev/null +++ b/src/bootstrap/DownloadButton.js @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) + * + * This is free software, licensed under the GNU General Public License v3. + * See /LICENSE for more information. + */ + +import React from "react"; +import PropTypes from "prop-types"; + +DownloadButton.propTypes = { + href: PropTypes.string.isRequired, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node, + ]), +}; + +export function DownloadButton({ href, children }) { + return {children}; +} diff --git a/src/bootstrap/DownloadButton.md b/src/bootstrap/DownloadButton.md new file mode 100644 index 0000000..f96deef --- /dev/null +++ b/src/bootstrap/DownloadButton.md @@ -0,0 +1,7 @@ +Hyperlink with apperance of a button. + +It has `download` attribute, which prevents closing WebSocket connection on Firefox. See [related issue](https://bugzilla.mozilla.org/show_bug.cgi?id=858538) for more details. + +```js +Download +``` diff --git a/src/bootstrap/__tests__/DownloadButton.test.js b/src/bootstrap/__tests__/DownloadButton.test.js new file mode 100644 index 0000000..5f9108a --- /dev/null +++ b/src/bootstrap/__tests__/DownloadButton.test.js @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) + * + * This is free software, licensed under the GNU General Public License v3. + * See /LICENSE for more information. + */ + +import React from "react"; + +import { render } from "customTestRender"; + +import { DownloadButton } from "../DownloadButton"; + +describe("", () => { + it("should have download attribute", () => { + const { container } = render(Test Button); + expect(container.firstChild.getAttribute("download")).not.toBeNull(); + }); +}); diff --git a/src/index.js b/src/index.js index ab4987c..9561621 100644 --- a/src/index.js +++ b/src/index.js @@ -15,6 +15,7 @@ export { useAPIPatch } from "api/patch"; export { Alert } from "bootstrap/Alert"; export { Button } from "bootstrap/Button"; export { CheckBox } from "bootstrap/CheckBox"; +export { DownloadButton } from "bootstrap/DownloadButton"; export { DataTimeInput } from "bootstrap/DataTimeInput"; export { EmailInput } from "bootstrap/EmailInput"; export { FileInput } from "bootstrap/FileInput";