Skip to content

Commit

Permalink
feat(DownloadFiles): add icon to the button
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Oct 26, 2023
1 parent 52e4f07 commit dc952a6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.icon {
margin-right: 0.3rem;
margin-bottom: 0.2rem;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { File } from '../../../../../../files/domain/models/File'
import { useDataset } from '../../../../DatasetContext'
import { Button, DropdownButton, DropdownButtonItem } from '@iqss/dataverse-design-system'
import { Download } from 'react-bootstrap-icons'
import styles from './DownloadFilesButton.module.scss'

interface DownloadFilesButtonProps {
files: File[]
Expand All @@ -19,45 +21,20 @@ export function DownloadFilesButton({ files }: DownloadFilesButtonProps) {

if (files.some((file) => file.isTabularData)) {
return (
<DropdownButton id="download-files" title="Download" variant="secondary">
<DropdownButton
id="download-files"
icon={<Download className={styles.icon} />}
title="Download"
variant="secondary">
<DropdownButtonItem>Original Format</DropdownButtonItem>
<DropdownButtonItem>Archival Format (.tab)</DropdownButtonItem>
</DropdownButton>
)
}

return <Button variant="secondary">Download</Button>
return (
<Button variant="secondary" icon={<Download className={styles.icon} />}>
Download
</Button>
)
}

// Original:
// < div
// jsf:id = "downloadButtonBlockNormal"
// className = "btn-group"
// jsf:rendered = "#{(!(empty DatasetPage.workingVersion.fileMetadatas)
// and
// DatasetPage.workingVersion.fileMetadatas.size() > 1
// )
// and
// DatasetPage.downloadButtonAvailable
// and !
// DatasetPage.isVersionHasTabular()
// }
// ">
// < p
// :
// commandLink
// styleClass = "btn btn-default btn-download"
// disabled = "#{false and DatasetPage.lockedFromDownload}"
// onclick = "if (!testFilesSelected()) return false;"
// action = "#{DatasetPage.startDownloadSelectedOriginal()}"
// update = "@form"
// oncomplete = "showPopup();" >
// < f
// :
// setPropertyActionListener
// target = "#{DatasetPage.fileMetadataForAction}"
// value = "#{null}" / >
// < span
// className = "glyphicon glyphicon-download-alt" / > #{bundle.download}
// < /p:commandLink>
// </div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,19 @@ export default meta
type Story = StoryObj<typeof EditFilesMenu>

export const NonTabularFiles: Story = {
render: () => <DownloadFilesButton files={FileMother.createMany(2)} />
render: () => <DownloadFilesButton files={FileMother.createMany(2, { tabularData: undefined })} />
}

export const TabularFiles: Story = {
render: () => (
<DownloadFilesButton
files={FileMother.createMany(2, {
tabularData: {
variablesCount: 2,
observationsCount: 3,
unf: 'some-unf'
}
})}
/>
)
}

0 comments on commit dc952a6

Please sign in to comment.