Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion assets/less/cds-rdm/views/item.overrides
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,55 @@
.description{
font-size: 1rem;
}
}
}

#cds-linked-records {

.linked-record-grid-card {
height: 100%;

.content {
flex-grow: 1;
}
}

.linked-record-grid-image {
display: block;
width: 100%;
height: 180px;
object-fit: contain;
background-color: @white;
}

.ui.cards {
margin-left: -0.75em;
margin-right: -0.75em;

> .card {
width: calc(33.333333% - 1.5em);
margin: 0.75em;
}
}

@media all and (max-width: @largestTabletScreen) {
.ui.cards > .card {
width: calc(50% - 1.5em);
}
}

@media all and (max-width: @largestMobileScreen) {
.ui.cards {
margin-left: 0;
margin-right: 0;

> .card {
width: 100%;
margin: 0 0 1em;
}
}

.linked-record-grid-image {
height: 150px;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
InvenioSearchApi,
ResultsLoader,
ResultsMultiLayout,
LayoutSwitcher,
Error,
EmptyResults,
Pagination,
Expand All @@ -23,7 +24,7 @@ import { OverridableContext } from "react-overridable";
import { apiConfig } from "./api/config";
import { Segment, Container, Grid } from "semantic-ui-react";
import { ResultsListLayout } from "./components/ResultsLayout";
import { RecordListItem } from "./components/RecordItem";
import { RecordGridItem, RecordListItem } from "./components/RecordItem";
import { FilterContainer, Filter, FilterValues } from "./components/Filter";
import { NoResults } from "./components/NoResults";
import { RelatedRecordsResultsLoader } from "./components/RelatedRecordsResultsLoader";
Expand All @@ -33,6 +34,7 @@ const linkedRecordsSearchAppID = "linkedRecordsSearch";
const overriddenComponents = {
[`${linkedRecordsSearchAppID}.ResultsList.container`]: ResultsListLayout,
[`${linkedRecordsSearchAppID}.ResultsList.item`]: RecordListItem,
[`${linkedRecordsSearchAppID}.ResultsGrid.item`]: RecordGridItem,
[`${linkedRecordsSearchAppID}.BucketAggregation.element`]: FilterContainer,
[`${linkedRecordsSearchAppID}.BucketAggregationContainer.element`]: Filter,
[`${linkedRecordsSearchAppID}.BucketAggregationValues.element`]: FilterValues,
Expand Down Expand Up @@ -70,6 +72,9 @@ const SearchControls = withState(({ currentResultsState }) => {
<BucketAggregation
agg={{ field: "resource_type", aggName: "resource_type" }}
/>
<div className="rel-ml-1">
<LayoutSwitcher />
</div>
</div>
</Grid.Column>
</Grid.Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from "react";
import PropTypes from "prop-types";
import { Item, Label } from "semantic-ui-react";
import { Card, Image, Item, Label } from "semantic-ui-react";
import _get from "lodash/get";
import { SearchItemCreators } from "@js/invenio_app_rdm/utils";

Expand All @@ -27,6 +27,73 @@ const layoutProps = (result) => {
};
};

const MetadataLabels = ({
resourceType,
publicationDate,
accessStatusId,
accessStatus,
}) => (
<div className="mb-10">
<Label size="small">{resourceType}</Label>

<Label size="small">{publicationDate}</Label>

<Label size="small" className={`access-status ${accessStatusId}`}>
{accessStatus}
</Label>
</div>
);

MetadataLabels.propTypes = {
resourceType: PropTypes.string.isRequired,
publicationDate: PropTypes.string.isRequired,
accessStatusId: PropTypes.string.isRequired,
accessStatus: PropTypes.string.isRequired,
};

export const RecordGridItem = ({ result }) => {
const {
accessStatusId,
accessStatus,
publicationDate,
creators,
resourceType,
title,
link,
thumbnail,
} = layoutProps(result);

return (
<Card className="linked-record-grid-card">
<Image
src={thumbnail || THUMBNAIL_PLACEHOLDER}
alt=""
className="linked-record-grid-image"
/>
<Card.Content>
<MetadataLabels
resourceType={resourceType}
publicationDate={publicationDate}
accessStatusId={accessStatusId}
accessStatus={accessStatus}
/>

<Card.Header as="a" href={link} className="truncate-lines-2">
{title}
</Card.Header>

<Card.Description className="truncate-lines-2">
<SearchItemCreators creators={creators} />
</Card.Description>
</Card.Content>
</Card>
);
};

RecordGridItem.propTypes = {
result: PropTypes.object.isRequired,
};

export const RecordListItem = ({ result }) => {
const {
accessStatusId,
Expand All @@ -44,15 +111,12 @@ export const RecordListItem = ({ result }) => {
<Item.Image src={thumbnail || THUMBNAIL_PLACEHOLDER} size="tiny" alt="" />
<Item.Content>
{/* Metadata badges */}
<div className="mb-10">
<Label size="small">{resourceType}</Label>

<Label size="small">{publicationDate}</Label>

<Label size="small" className={`access-status ${accessStatusId}`}>
{accessStatus}
</Label>
</div>
<MetadataLabels
resourceType={resourceType}
publicationDate={publicationDate}
accessStatusId={accessStatusId}
accessStatus={accessStatus}
/>

{/* Title */}
<Item.Header className="truncate-lines-2" href={link}>
Expand Down
Loading