From afd04c902999b97d0e7c528e4d40995601ea261e Mon Sep 17 00:00:00 2001 From: jerem Date: Tue, 19 Nov 2024 15:30:00 +0100 Subject: [PATCH] feat(openAlex): add RorBadge component and integrate it into ListView --- .../openalex-ror/components/ror-badge.jsx | 62 ++++++++++++++++ .../pages/openalex-ror/results/list-view.jsx | 70 +++++++------------ client/src/styles/index.scss | 29 ++++++++ 3 files changed, 115 insertions(+), 46 deletions(-) create mode 100644 client/src/pages/openalex-ror/components/ror-badge.jsx diff --git a/client/src/pages/openalex-ror/components/ror-badge.jsx b/client/src/pages/openalex-ror/components/ror-badge.jsx new file mode 100644 index 0000000..a73dadd --- /dev/null +++ b/client/src/pages/openalex-ror/components/ror-badge.jsx @@ -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 ( +
+ +
+ ROR logo +
+ https://ror.org/ + + {` ${ror.rorId}`} + +
+ ); +} + +RorBadge.propTypes = { + ror: PropTypes.shape({ + rorId: PropTypes.string.isRequired, + }).isRequired, + setFilteredAffiliationName: PropTypes.func.isRequired, + rorColor: PropTypes.string.isRequired, +}; diff --git a/client/src/pages/openalex-ror/results/list-view.jsx b/client/src/pages/openalex-ror/results/list-view.jsx index 0b33f7c..1c5e237 100644 --- a/client/src/pages/openalex-ror/results/list-view.jsx +++ b/client/src/pages/openalex-ror/results/list-view.jsx @@ -2,6 +2,7 @@ import { Badge, Button, Col, Link, Row, Text } from '@dataesr/dsfr-plus'; import PropTypes from 'prop-types'; import WorksList from '../components/works-list'; +import RorBadge from '../components/ror-badge'; export default function ListView({ onRowEditComplete, @@ -11,12 +12,7 @@ export default function ListView({ setFilteredAffiliationName, }) { const defineRorColor = []; - const dsColors = ['green-archipel', 'blue-ecume', 'blue-cumulus', 'purple-glycine', 'pink-macaron', - 'pink-tuile', 'orange-terre-battue', - 'brown-cafe-creme', 'brown-caramel', 'brown-opera', 'beige-gris-galet']; - // tri des ror mar nombre - // creation d'un tableau de ror avec un index pour chaque ror et son nombre d'occurences - // ajout des couleurs pour chaque ror + const dsColors = ['ror-1', 'ror-2', 'ror-3', 'ror-4', 'ror-5']; const rorCount = {}; allAffiliations.forEach((affiliation) => { affiliation.rors.forEach((ror) => { @@ -29,6 +25,7 @@ export default function ListView({ }); const sortedRor = Object.keys(rorCount).sort((a, b) => rorCount[b] - rorCount[a]); defineRorColor.push(...sortedRor.slice(0, 5).map((ror, index) => ({ ror, color: dsColors[index % dsColors.length] }))); + console.log('defineRorColor', defineRorColor); return (