-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
261 - Add File Citation to File Page #269
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9913c27
feat(FilePage): add dataset citation
MellyGray e50bc81
Merge branch 'feature/249-boilerplate-file-page' of https://github.co…
MellyGray d144cff
refactor: DatasetCitation extract components
MellyGray 6d34d58
feat(FileCitation): add FileCitation to File Page
MellyGray 4482c92
feat(FileCitation): add to skeleton
MellyGray 30ae03e
Merge branch 'feature/249-boilerplate-file-page' of https://github.co…
MellyGray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice extraction