-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: added OrganizationsList component
- Loading branch information
1 parent
05537f3
commit d4828aa
Showing
5 changed files
with
112 additions
and
85 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
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
96 changes: 96 additions & 0 deletions
96
..._communities/assets/semantic-ui/js/invenio_communities/organizations/OrganizationsList.js
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,96 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { Popup } from "semantic-ui-react"; | ||
|
||
const OrganizationsList = ({ organizations }) => { | ||
const handleClick = (e) => { | ||
e.preventDefault(); | ||
}; | ||
|
||
return ( | ||
<div> | ||
{organizations && organizations.length > 0 && ( | ||
<div> | ||
<span className="org-list-inline"> | ||
<i className="building outline icon" aria-hidden="true" /> | ||
{organizations[0].id ? ( | ||
<a | ||
href={`https://ror.org/${organizations[0].id}`} | ||
aria-label={`${organizations[0].name}'s ROR profile`} | ||
title={`${organizations[0].name}'s ROR profile`} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
{organizations[0].name} | ||
<span> </span> | ||
<img | ||
className="inline-id-icon" | ||
src="/static/images/ror-icon.svg" | ||
alt={`${organizations[0].name}'s ROR profile`} | ||
/> | ||
</a> | ||
) : ( | ||
organizations[0].name | ||
)} | ||
</span> | ||
{organizations.length > 1 && ( | ||
<span className="ml-1"> | ||
and | ||
<Popup | ||
trigger={ | ||
<a href="#!" onClick={handleClick}> | ||
{`${organizations.length - 1} more organizations`} | ||
</a> | ||
} | ||
size="small" | ||
wide="very" | ||
content={ | ||
<div className="expanded-orgs"> | ||
{organizations.slice(1).map((org, index) => ( | ||
<div key={org.id || org.name} className="inline-computer mt-5"> | ||
{org.id ? ( | ||
<a | ||
href={`https://ror.org/${org.id}`} | ||
aria-label={`${org.name}'s ROR profile`} | ||
title={`${org.name}'s ROR profile`} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
{org.name} | ||
<span> </span> | ||
<img | ||
className="inline-id-icon" | ||
src="/static/images/ror-icon.svg" | ||
alt={`${organizations[0].name}'s ROR profile`} | ||
/> | ||
</a> | ||
) : ( | ||
org.name | ||
)} | ||
{index < organizations.length - 2 && <span>{", "} </span>} | ||
</div> | ||
))} | ||
</div> | ||
} | ||
on="click" | ||
position="bottom left" | ||
positionFixed | ||
/> | ||
</span> | ||
)} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
OrganizationsList.propTypes = { | ||
organizations: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
id: PropTypes.string, | ||
name: PropTypes.string.isRequired, | ||
}) | ||
).isRequired, | ||
}; | ||
|
||
export default OrganizationsList; |
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