-
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(DatasetCard): refactor component
- Loading branch information
Showing
17 changed files
with
224 additions
and
103 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
21 changes: 21 additions & 0 deletions
21
src/sections/home/datasets-list/dataset-card/DatasetCard.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 { DatasetPreview } from '../../../../dataset/domain/models/DatasetPreview' | ||
import styles from './DatasetCard.module.scss' | ||
import { DatasetCardHeader } from './DatasetCardHeader' | ||
import { DatasetCardThumbnail } from './DatasetCardThumbnail' | ||
import { DatasetCardInfo } from './DatasetCardInfo' | ||
|
||
interface DatasetCardProps { | ||
dataset: DatasetPreview | ||
} | ||
|
||
export function DatasetCard({ dataset }: DatasetCardProps) { | ||
return ( | ||
<article className={styles.container}> | ||
<DatasetCardHeader dataset={dataset} /> | ||
<div className={styles.info}> | ||
<DatasetCardThumbnail dataset={dataset} /> | ||
<DatasetCardInfo dataset={dataset} /> | ||
</div> | ||
</article> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
src/sections/home/datasets-list/dataset-card/DatasetCardHeader.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,19 @@ | ||
import styles from './DatasetCard.module.scss' | ||
import { LinkToPage } from '../../../shared/link-to-page/LinkToPage' | ||
import { Route } from '../../../Route.enum' | ||
import { DatasetLabels } from '../../../dataset/dataset-labels/DatasetLabels' | ||
import { DatasetPreview } from '../../../../dataset/domain/models/DatasetPreview' | ||
|
||
interface DatasetCardHeaderProps { | ||
dataset: DatasetPreview | ||
} | ||
export function DatasetCardHeader({ dataset }: DatasetCardHeaderProps) { | ||
return ( | ||
<div className={styles.header}> | ||
<LinkToPage page={Route.DATASETS} searchParams={{ persistentId: dataset.persistentId }}> | ||
{dataset.title} | ||
</LinkToPage> | ||
<DatasetLabels labels={dataset.labels} /> | ||
</div> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
src/sections/home/datasets-list/dataset-card/DatasetCardInfo.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,23 @@ | ||
import styles from './DatasetCard.module.scss' | ||
import { DateHelper } from '../../../../shared/domain/helpers/DateHelper' | ||
import { CitationDescription } from '../../../dataset/dataset-citation/DatasetCitation' | ||
import { DatasetPreview } from '../../../../dataset/domain/models/DatasetPreview' | ||
|
||
interface DatasetCardInfoProps { | ||
dataset: DatasetPreview | ||
} | ||
|
||
export function DatasetCardInfo({ dataset }: DatasetCardInfoProps) { | ||
return ( | ||
<div className={styles.description}> | ||
<span className={styles.date}>{DateHelper.toDisplayFormat(dataset.releaseOrCreateDate)}</span> | ||
<span | ||
className={ | ||
dataset.isDeaccessioned ? styles['citation-box-deaccessioned'] : styles['citation-box'] | ||
}> | ||
<CitationDescription citation={dataset.citation} version={dataset.version} /> | ||
</span> | ||
<span>{dataset.abbreviatedDescription}</span> | ||
</div> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
src/sections/home/datasets-list/dataset-card/DatasetCardThumbnail.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,23 @@ | ||
import styles from './DatasetCard.module.scss' | ||
import { DatasetPreview } from '../../../../dataset/domain/models/DatasetPreview' | ||
import { LinkToPage } from '../../../shared/link-to-page/LinkToPage' | ||
import { Route } from '../../../Route.enum' | ||
import { DatasetThumbnail } from '../../../dataset/dataset-citation/DatasetThumbnail' | ||
|
||
interface DatasetCardThumbnailProps { | ||
dataset: DatasetPreview | ||
} | ||
|
||
export function DatasetCardThumbnail({ dataset }: DatasetCardThumbnailProps) { | ||
return ( | ||
<div className={styles.thumbnail}> | ||
<LinkToPage page={Route.DATASETS} searchParams={{ persistentId: dataset.persistentId }}> | ||
<DatasetThumbnail | ||
title={dataset.title} | ||
thumbnail={dataset.thumbnail} | ||
isDeaccessioned={dataset.isDeaccessioned} | ||
/> | ||
</LinkToPage> | ||
</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
38 changes: 0 additions & 38 deletions
38
tests/component/sections/home/datasets-list/DatasetCard.spec.tsx
This file was deleted.
Oops, something went wrong.
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
tests/component/sections/home/datasets-list/dataset-card/DatasetCard.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,21 @@ | ||
import { DatasetPreviewMother } from '../../../../dataset/domain/models/DatasetPreviewMother' | ||
import { DatasetCard } from '../../../../../../src/sections/home/datasets-list/dataset-card/DatasetCard' | ||
import { DateHelper } from '../../../../../../src/shared/domain/helpers/DateHelper' | ||
import styles from '../../../../../../src/sections/home/datasets-list/dataset-card/DatasetCard.module.scss' | ||
|
||
describe('DatasetCard', () => { | ||
it('should render the card', () => { | ||
const dataset = DatasetPreviewMother.create() | ||
cy.customMount(<DatasetCard dataset={dataset} />) | ||
|
||
cy.findByText(dataset.title).should('exist') | ||
|
||
cy.findByRole('img').should('exist') | ||
cy.findByText(DateHelper.toDisplayFormat(dataset.releaseOrCreateDate)).should('exist') | ||
cy.findByText(/Finch, Fiona, 2023, "Darwin's Finches"/) | ||
.should('exist') | ||
.parent() | ||
.should('have.class', styles['citation-box']) | ||
cy.findByText(dataset.abbreviatedDescription).should('exist') | ||
}) | ||
}) |
16 changes: 16 additions & 0 deletions
16
tests/component/sections/home/datasets-list/dataset-card/DatasetCardHeader.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,16 @@ | ||
import { DatasetCardHeader } from '../../../../../../src/sections/home/datasets-list/dataset-card/DatasetCardHeader' | ||
import { DatasetPreviewMother } from '../../../../dataset/domain/models/DatasetPreviewMother' | ||
|
||
describe('DatasetCardHeader', () => { | ||
it('should render the header', () => { | ||
const dataset = DatasetPreviewMother.create() | ||
cy.customMount(<DatasetCardHeader dataset={dataset} />) | ||
|
||
cy.findByText(dataset.title) | ||
.should('exist') | ||
.should('have.attr', 'href', `/datasets?persistentId=${dataset.persistentId}`) | ||
dataset.labels.forEach((label) => { | ||
cy.findByText(label.value).should('exist') | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.