-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openAlex): refactor RorBadge component and add RorName component…
… for improved display
- Loading branch information
Showing
4 changed files
with
151 additions
and
68 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 |
---|---|---|
@@ -1,62 +1,56 @@ | ||
import { Link } from '@dataesr/dsfr-plus'; | ||
import { Link, Tag } from '@dataesr/dsfr-plus'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default function RorBadge({ ror, setFilteredAffiliationName, rorColor }) { | ||
console.log(rorColor, getComputedStyle(document.documentElement).getPropertyValue(`--${rorColor}`)); | ||
|
||
export default function RorBadge({ | ||
isRemoved, | ||
ror, | ||
rorColor, | ||
setFilteredAffiliationName, | ||
}) { | ||
return ( | ||
<div className="wm-ror-badge"> | ||
<span style={{ backgroundColor: getComputedStyle(document.documentElement).getPropertyValue(`--${rorColor}`) }} /> | ||
<div> | ||
<img | ||
alt="ROR logo" | ||
className="vertical-middle fr-mx-1w" | ||
src="https://raw.githubusercontent.com/ror-community/ror-logos/main/ror-icon-rgb.svg" | ||
height="16" | ||
/> | ||
</div> | ||
https://ror.org/ | ||
<Link href={`https://ror.org/${ror.rorId}`} target="_blank"> | ||
{` ${ror.rorId}`} | ||
</Link> | ||
<button | ||
type="button" | ||
aria-label="filter on this ROR id" | ||
className="fr-icon fr-fi-filter-line fr-icon--sm" | ||
onClick={() => setFilteredAffiliationName(ror.rorId)} | ||
/> | ||
|
||
{/* <img | ||
<Tag | ||
color={rorColor} | ||
size="sm" | ||
> | ||
<img | ||
alt="ROR logo" | ||
className="vertical-middle fr-mx-1w" | ||
src="https://raw.githubusercontent.com/ror-community/ror-logos/main/ror-icon-rgb.svg" | ||
src="https://raw.githubusercontent.com/ror-community/ror-logos/0ef82987ac9bf4c9681dacdb3cb78d2a9d81167b/ror-icon-rgb-transparent.svg" | ||
height="16" | ||
/> | ||
https://ror.org/ | ||
<Badge | ||
className="fr-mr-1w" | ||
color={defineRorColor.find((r) => r.ror === ror.rorId)?.color || 'yellow-tournesol'} | ||
size="sm" | ||
> | ||
<Link className="fr-mr-1w" href={`https://ror.org/${ror.rorId}`} target="_blank"> | ||
{` ${ror.rorId}`} | ||
</Link> | ||
</Badge> | ||
<Button | ||
{isRemoved ? ( | ||
<strike> | ||
https://ror.org/ | ||
<Link href={`https://ror.org/${ror.rorId}`} target="_blank"> | ||
{` ${ror.rorId}`} | ||
</Link> | ||
</strike> | ||
) : ( | ||
<> | ||
https://ror.org/ | ||
<Link href={`https://ror.org/${ror.rorId}`} target="_blank"> | ||
{` ${ror.rorId}`} | ||
</Link> | ||
</> | ||
)} | ||
|
||
<button | ||
disabled={isRemoved} | ||
aria-label="filter on this ROR id" | ||
icon="filter-line" | ||
className="fr-icon fr-fi-filter-line fr-icon--sm" | ||
onClick={() => setFilteredAffiliationName(ror.rorId)} | ||
size="sm" | ||
variant="text" | ||
/> */} | ||
</div> | ||
type="button" | ||
/> | ||
</Tag> | ||
|
||
); | ||
} | ||
|
||
RorBadge.propTypes = { | ||
isRemoved: PropTypes.bool.isRequired, | ||
ror: PropTypes.shape({ | ||
rorId: PropTypes.string.isRequired, | ||
}).isRequired, | ||
setFilteredAffiliationName: PropTypes.func.isRequired, | ||
rorColor: PropTypes.string.isRequired, | ||
setFilteredAffiliationName: PropTypes.func.isRequired, | ||
}; |
62 changes: 62 additions & 0 deletions
62
client/src/pages/openalex-ror/components/ror-badge_old.jsx
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,62 @@ | ||
import { Link } from '@dataesr/dsfr-plus'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default function RorBadge({ ror, setFilteredAffiliationName, rorColor }) { | ||
console.log(rorColor, getComputedStyle(document.documentElement).getPropertyValue(`--${rorColor}`)); | ||
|
||
return ( | ||
<div className="wm-ror-badge"> | ||
<span style={{ backgroundColor: getComputedStyle(document.documentElement).getPropertyValue(`--${rorColor}`) }} /> | ||
<div> | ||
<img | ||
alt="ROR logo" | ||
className="vertical-middle fr-mx-1w" | ||
src="https://raw.githubusercontent.com/ror-community/ror-logos/main/ror-icon-rgb.svg" | ||
height="16" | ||
/> | ||
</div> | ||
https://ror.org/ | ||
<Link href={`https://ror.org/${ror.rorId}`} target="_blank"> | ||
{` ${ror.rorId}`} | ||
</Link> | ||
<button | ||
type="button" | ||
aria-label="filter on this ROR id" | ||
className="fr-icon fr-fi-filter-line fr-icon--sm" | ||
onClick={() => setFilteredAffiliationName(ror.rorId)} | ||
/> | ||
|
||
{/* <img | ||
alt="ROR logo" | ||
className="vertical-middle fr-mx-1w" | ||
src="https://raw.githubusercontent.com/ror-community/ror-logos/main/ror-icon-rgb.svg" | ||
height="16" | ||
/> | ||
https://ror.org/ | ||
<Badge | ||
className="fr-mr-1w" | ||
color={defineRorColor.find((r) => r.ror === ror.rorId)?.color || 'yellow-tournesol'} | ||
size="sm" | ||
> | ||
<Link className="fr-mr-1w" href={`https://ror.org/${ror.rorId}`} target="_blank"> | ||
{` ${ror.rorId}`} | ||
</Link> | ||
</Badge> | ||
<Button | ||
aria-label="filter on this ROR id" | ||
icon="filter-line" | ||
onClick={() => setFilteredAffiliationName(ror.rorId)} | ||
size="sm" | ||
variant="text" | ||
/> */} | ||
</div> | ||
); | ||
} | ||
|
||
RorBadge.propTypes = { | ||
ror: PropTypes.shape({ | ||
rorId: PropTypes.string.isRequired, | ||
}).isRequired, | ||
setFilteredAffiliationName: PropTypes.func.isRequired, | ||
rorColor: PropTypes.string.isRequired, | ||
}; |
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,38 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
export default function RorName({ isRemoved, ror }) { | ||
return ( | ||
<div style={{ display: 'inline-flex', justifyContent: 'center', alignItems: 'center' }}> | ||
<img | ||
alt={`${ror.rorCountry} flag`} | ||
src={`https://flagsapi.com/${ror.rorCountry}/flat/16.png`} | ||
/> | ||
<span | ||
className="fr-ml-1w" | ||
style={{ | ||
width: '300px', | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
display: 'inline-block', | ||
}} | ||
> | ||
{isRemoved ? ( | ||
<strike> | ||
{ror.rorName} | ||
</strike> | ||
) : ( | ||
ror.rorName | ||
)} | ||
</span> | ||
</div> | ||
); | ||
} | ||
|
||
RorName.propTypes = { | ||
isRemoved: PropTypes.bool.isRequired, | ||
ror: PropTypes.shape({ | ||
rorCountry: PropTypes.string.isRequired, | ||
rorName: PropTypes.string.isRequired, | ||
}).isRequired, | ||
}; |
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