Skip to content

Commit

Permalink
CORE-1967 Update LocalContexts details dialog and icon display
Browse files Browse the repository at this point in the history
Improved the LocalContexts label/notice icon sizing.
Added a link to the LocalContextsHub project in the details dialog.
  • Loading branch information
psarando committed Feb 15, 2024
1 parent 7095bc3 commit 3fac779
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
3 changes: 3 additions & 0 deletions public/static/locales/en/localcontexts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"projectMoreInfoWithLink": "For more information on the <ExternalLink href=\"https://localcontexts.org\">Local Contexts</ExternalLink> project for this data, please visit the project's page: <ProjectLink>{{projectTitle}}</ProjectLink>"
}
60 changes: 46 additions & 14 deletions src/components/metadata/LocalContextsLabelDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import {
useTheme,
} from "@mui/material";

import { Trans, useTranslation } from "i18n";

import DEDialog from "components/utils/DEDialog";
import ExternalLink from "components/utils/ExternalLink";

import {
LOCAL_CONTEXTS_QUERY_KEY,
Expand All @@ -26,7 +29,9 @@ const sizeToSpacing = (size, theme) =>
? theme.spacing(3)
: theme.spacing(5);

const LocalContextsLabel = ({ baseId, label, size = "medium" }) => {
const LocalContextsLabel = ({ baseId, label, project, size = "medium" }) => {
const { t } = useTranslation("localcontexts");

const [dialogOpen, setDialogOpen] = React.useState(false);
const theme = useTheme();
const labelURI = label.svg_url || label.img_url;
Expand All @@ -38,7 +43,8 @@ const LocalContextsLabel = ({ baseId, label, size = "medium" }) => {
<img
alt={label.name}
src={labelURI}
width={sizeToSpacing(size, theme)}
width="auto"
height={sizeToSpacing(size, theme)}
/>
</IconButton>
</Tooltip>
Expand All @@ -48,19 +54,44 @@ const LocalContextsLabel = ({ baseId, label, size = "medium" }) => {
title={label.name}
onClose={() => setDialogOpen(false)}
>
<Card sx={{ display: "flex" }}>
<CardMedia
component="img"
title={label.name}
image={labelURI}
sx={{
width: theme.spacing(16),
height: theme.spacing(16),
}}
/>
<Card>
<Stack direction={"row"}>
<CardMedia
component="img"
title={label.name}
image={labelURI}
sx={{
width: "auto",
height: theme.spacing(16),
}}
/>
<CardContent>
<Typography
sx={{
mb: theme.spacing(2),
textWrap: "balance",
}}
>
{label.label_text || label.default_text}
</Typography>
</CardContent>
</Stack>

<CardContent>
<Typography sx={{ textWrap: "balance" }}>
{label.default_text}
<Typography>
<Trans
t={t}
i18nKey="projectMoreInfoWithLink"
values={{ projectTitle: project.title }}
components={{
ExternalLink: <ExternalLink />,
ProjectLink: (
<ExternalLink
href={project.project_page}
/>
),
}}
/>
</Typography>
</CardContent>
</Card>
Expand Down Expand Up @@ -113,6 +144,7 @@ const LocalContextsLabelDisplay = ({ rightsURI, size = "medium" }) => {
baseId={label.unique_id || label.img_url}
size={size}
label={label}
project={project}
/>
))}
</Stack>
Expand Down
1 change: 1 addition & 0 deletions src/pages/data/ds/[...pathItems].js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export async function getServerSideProps(context) {
title,
...(await serverSideTranslations(locale, [
"data",
"localcontexts",
"metadata",
"upload",
"urlImport",
Expand Down

0 comments on commit 3fac779

Please sign in to comment.