Parameterize download button icon.

master
Icedream 2021-01-03 18:43:50 +01:00
parent f7b67355c4
commit 0184eff590
1 changed files with 11 additions and 2 deletions

View File

@ -1,13 +1,22 @@
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React from 'react'; import React from 'react';
import { Button } from 'react-bootstrap'; import { Button } from 'react-bootstrap';
import { getDownloadURL } from 'util/api'; import { getDownloadURL } from 'util/api';
import { FormattedMessage } from './localization'; import { FormattedMessage } from './localization';
export default function DownloadButton({ id, fileName }: { id: string, fileName: string }) { export default function DownloadButton({
icon = 'download',
id,
fileName,
}: {
icon?: IconProp,
id: string,
fileName: string
}) {
return ( return (
<Button variant="success" href={getDownloadURL(id, fileName)}> <Button variant="success" href={getDownloadURL(id, fileName)}>
<FontAwesomeIcon icon="download" className="mr-2" /> <FontAwesomeIcon icon={icon} className="mr-2" />
<FormattedMessage <FormattedMessage
id="DownloadButton.download" id="DownloadButton.download"
defaultMessage="Download" defaultMessage="Download"