-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DatasetThumbnail): add dataset thumbnail to the citation block
- Loading branch information
Showing
8 changed files
with
117 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/sections/dataset/dataset-citation/CitationThumbnail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { DatasetPublishingStatus } from '../../../dataset/domain/models/Dataset' | ||
import styles from './DatasetCitation.module.scss' | ||
import { Icon, IconName } from '@iqss/dataverse-design-system' | ||
|
||
interface CitationThumbnailProps { | ||
thumbnail?: string | ||
title: string | ||
publishingStatus: DatasetPublishingStatus | ||
} | ||
|
||
export function CitationThumbnail({ thumbnail, title, publishingStatus }: CitationThumbnailProps) { | ||
if (thumbnail && publishingStatus !== DatasetPublishingStatus.DEACCESSIONED) { | ||
return <img className={styles['preview-image']} src={thumbnail} alt={title} /> | ||
} | ||
|
||
return ( | ||
<div className={styles.icon}> | ||
<Icon name={IconName.DATASET} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tests/component/sections/dataset/dataset-citation/CitationThumbnail.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { DatasetPublishingStatus } from '../../../../../src/dataset/domain/models/Dataset' | ||
import { CitationThumbnail } from '../../../../../src/sections/dataset/dataset-citation/CitationThumbnail' | ||
|
||
describe('CitationThumbnail', () => { | ||
it('renders the dataset icon when there is no thumbnail', () => { | ||
cy.customMount( | ||
<CitationThumbnail | ||
title="Dataset title" | ||
publishingStatus={DatasetPublishingStatus.RELEASED} | ||
/> | ||
) | ||
|
||
cy.findByLabelText('icon-dataset').should('exist') | ||
}) | ||
|
||
it('renders the dataset icon when the dataset is deaccessioned', () => { | ||
cy.customMount( | ||
<CitationThumbnail | ||
title="Dataset title" | ||
thumbnail="https://example.com/image.png" | ||
publishingStatus={DatasetPublishingStatus.DEACCESSIONED} | ||
/> | ||
) | ||
|
||
cy.findByLabelText('icon-dataset').should('exist') | ||
}) | ||
|
||
it('renders the dataset thumbnail when there is one and the dataset is not deaccessioned', () => { | ||
cy.customMount( | ||
<CitationThumbnail | ||
thumbnail="https://example.com/image.png" | ||
title="Dataset title" | ||
publishingStatus={DatasetPublishingStatus.RELEASED} | ||
/> | ||
) | ||
|
||
cy.findByRole('img', { name: 'Dataset title' }).should('exist') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters