-
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.
Merge pull request #269 from IQSS/feature/261-file-citation-ui
261 - Add File Citation to File Page
- Loading branch information
Showing
41 changed files
with
305 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "learnAbout": "Learn About", "standards": "Data Citation Standards" } |
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
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
} | ||
|
||
.summary-container { | ||
margin:1em 0; | ||
margin-bottom: 1em; | ||
} | ||
|
||
.tab-container { | ||
|
9 changes: 2 additions & 7 deletions
9
src/sections/dataset/dataset-citation/DatasetCitation.module.scss
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
67 changes: 26 additions & 41 deletions
67
src/sections/dataset/dataset-citation/DatasetCitation.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 |
---|---|---|
@@ -1,56 +1,41 @@ | ||
import { Col, Row } from '@iqss/dataverse-design-system' | ||
import styles from './DatasetCitation.module.scss' | ||
import { useTranslation } from 'react-i18next' | ||
import { DatasetPublishingStatus, DatasetVersion } from '../../../dataset/domain/models/Dataset' | ||
import { DatasetThumbnail } from '../dataset-thumbnail/DatasetThumbnail' | ||
import { CitationDescription } from '../../shared/citation/CitationDescription' | ||
import { DatasetCitationTooltip } from './DatasetCitationTooltip' | ||
import { CitationLearnAbout } from '../../shared/citation/CitationLearnAbout' | ||
|
||
interface DatasetCitationProps { | ||
thumbnail?: string | ||
version: DatasetVersion | ||
withoutThumbnail?: boolean | ||
} | ||
|
||
export function DatasetCitation({ thumbnail, version }: DatasetCitationProps) { | ||
const { t } = useTranslation('dataset') | ||
export function DatasetCitation({ thumbnail, version, withoutThumbnail }: DatasetCitationProps) { | ||
return ( | ||
<> | ||
<Row | ||
className={ | ||
version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED | ||
? styles.deaccessioned | ||
: styles.container | ||
}> | ||
<Row className={styles.row}> | ||
<Col sm={2} className={styles.thumbnail}> | ||
<DatasetThumbnail | ||
thumbnail={thumbnail} | ||
title={version.title} | ||
isDeaccessioned={version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED} | ||
/> | ||
</Col> | ||
<Col> | ||
<Row> | ||
<span className={styles.citation}> | ||
<CitationDescription citation={version.citation} /> | ||
<DatasetCitationTooltip status={version.publishingStatus} /> | ||
</span> | ||
</Row> | ||
<Row> | ||
<div> | ||
{t('citation.learnAbout')}{' '} | ||
<a | ||
className={styles.link} | ||
href="https://dataverse.org/best-practices/data-citation" | ||
target="_blank" | ||
rel="noopener noreferrer"> | ||
{t('citation.standards')}. | ||
</a> | ||
</div> | ||
</Row> | ||
</Col> | ||
</Row> | ||
</Row> | ||
</> | ||
<Row | ||
className={ | ||
version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED | ||
? styles.deaccessioned | ||
: styles.container | ||
}> | ||
{!withoutThumbnail && ( | ||
<Col sm={2} className={styles.thumbnail}> | ||
<DatasetThumbnail | ||
thumbnail={thumbnail} | ||
title={version.title} | ||
isDeaccessioned={version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED} | ||
/> | ||
</Col> | ||
)} | ||
<Col sm={withoutThumbnail ? 12 : 10}> | ||
<CitationDescription | ||
citation={version.citation} | ||
tooltip={<DatasetCitationTooltip status={version.publishingStatus} />} | ||
/> | ||
<CitationLearnAbout /> | ||
</Col> | ||
</Row> | ||
) | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; | ||
|
||
.container { | ||
margin: 0 0 20px; | ||
padding: 10px 0; | ||
border: 1px solid $dv-secondary-color; | ||
} | ||
|
||
.deaccessioned { | ||
margin: 0.5rem 0; | ||
padding: 10px; | ||
border: 1px solid $dv-danger-color; | ||
} |
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,29 @@ | ||
import { DatasetPublishingStatus, DatasetVersion } from '../../../dataset/domain/models/Dataset' | ||
import styles from './FileCitation.module.scss' | ||
import { CitationDescription } from '../../shared/citation/CitationDescription' | ||
import { DatasetCitationTooltip } from '../../dataset/dataset-citation/DatasetCitationTooltip' | ||
import { CitationLearnAbout } from '../../shared/citation/CitationLearnAbout' | ||
import { Col, Row } from '@iqss/dataverse-design-system' | ||
|
||
interface FileCitationProps { | ||
citation: string | ||
datasetVersion: DatasetVersion | ||
} | ||
export function FileCitation({ citation, datasetVersion }: FileCitationProps) { | ||
return ( | ||
<Row | ||
className={ | ||
datasetVersion.publishingStatus === DatasetPublishingStatus.DEACCESSIONED | ||
? styles.deaccessioned | ||
: styles.container | ||
}> | ||
<Col> | ||
<CitationDescription | ||
citation={citation} | ||
tooltip={<DatasetCitationTooltip status={datasetVersion.publishingStatus} />} | ||
/> | ||
<CitationLearnAbout /> | ||
</Col> | ||
</Row> | ||
) | ||
} |
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,9 @@ | ||
@import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; | ||
|
||
.description { | ||
margin-bottom: 1em; | ||
} | ||
|
||
.text { | ||
color: $dv-subtext-color | ||
} |
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 |
---|---|---|
@@ -1,11 +1,20 @@ | ||
import parse from 'html-react-parser' | ||
import styles from './Citation.module.scss' | ||
import { ReactNode } from 'react' | ||
|
||
interface CitationDescriptionProps { | ||
citation: string | ||
tooltip?: ReactNode | ||
} | ||
|
||
export function CitationDescription({ citation }: CitationDescriptionProps) { | ||
export function CitationDescription({ citation, tooltip }: CitationDescriptionProps) { | ||
const citationAsReactElement = parse(citation) | ||
|
||
return <span>{citationAsReactElement}</span> | ||
return ( | ||
<div className={styles.description}> | ||
<span> | ||
{citationAsReactElement} {tooltip} | ||
</span> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import styles from './Citation.module.scss' | ||
|
||
export function CitationLearnAbout() { | ||
const { t } = useTranslation('citationBlock') | ||
return ( | ||
<div> | ||
<span className={styles.text}>{t('learnAbout')}</span>{' '} | ||
<a | ||
href="https://dataverse.org/best-practices/data-citation" | ||
target="_blank" | ||
rel="noopener noreferrer"> | ||
{t('standards')}. | ||
</a> | ||
</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
Oops, something went wrong.