Skip to content

Commit ad52a3c

Browse files
committed
style: improve DatasetCard layout and visual styling
1 parent c64c154 commit ad52a3c

File tree

1 file changed

+70
-41
lines changed

1 file changed

+70
-41
lines changed

src/components/SearchPage/DatasetCard.tsx

Lines changed: 70 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import {
2-
Box,
3-
Typography,
4-
Card,
5-
CardContent,
6-
Stack,
7-
Chip,
8-
Grid,
9-
Link,
10-
} from "@mui/material";
1+
import { Typography, Card, CardContent, Stack, Chip } from "@mui/material";
112
import { Colors } from "design/theme";
123
import React from "react";
4+
import { Link } from "react-router-dom";
5+
import RoutesEnum from "types/routes.enum";
136

147
interface DatasetCardProps {
158
dbname: string;
@@ -35,6 +28,7 @@ const DatasetCard: React.FC<DatasetCardProps> = ({
3528
parsedJson,
3629
}) => {
3730
const { name, readme, modality, subj, info } = parsedJson.value;
31+
const datasetLink = `${RoutesEnum.DATABASES}/${dbname}/${dsname}`;
3832

3933
// prepare DOI URL
4034
const rawDOI = info?.DatasetDOI?.replace(/^doi:/, "");
@@ -43,46 +37,81 @@ const DatasetCard: React.FC<DatasetCardProps> = ({
4337
return (
4438
<Card sx={{ mb: 3 }}>
4539
<CardContent>
46-
<Typography variant="h6" sx={{ color: "#6C6C8E", fontWeight: 600 }}>
40+
<Typography
41+
variant="h6"
42+
sx={{
43+
fontWeight: 600,
44+
color: Colors.darkPurple,
45+
textDecoration: "none",
46+
":hover": { textDecoration: "underline" },
47+
}}
48+
component={Link}
49+
to={datasetLink}
50+
target="_blank"
51+
>
4752
{name || "Untitled Dataset"}
4853
</Typography>
4954

5055
<Typography variant="body2" color="text.secondary" gutterBottom>
51-
ID: {dsname}
56+
Dataset Number: {dsname}
5257
</Typography>
5358

54-
<Stack>
55-
{subj && <Chip label={`${subj.length} subjects`} color="primary" />}
56-
{modality?.map((mod, idx) => (
57-
<Chip key={idx} label={mod} color="info" />
58-
))}
59-
</Stack>
60-
61-
{readme && (
62-
<Typography variant="body2" paragraph>
63-
<strong>Summary:</strong> {readme}
64-
</Typography>
65-
)}
59+
<Stack spacing={2} margin={1}>
60+
<Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
61+
<Typography variant="body2" mt={1}>
62+
<strong>Modalities:</strong>
63+
</Typography>
64+
{modality?.map((mod, idx) => (
65+
<Chip
66+
key={idx}
67+
label={mod}
68+
variant="outlined"
69+
sx={{
70+
color: Colors.darkPurple,
71+
border: `1px solid ${Colors.darkPurple}`,
72+
fontWeight: "bold",
73+
}}
74+
/>
75+
))}
76+
</Stack>
6677

67-
{info?.Authors?.length && (
68-
<Typography>
69-
<strong>Authors:</strong> {info?.Authors?.join(", ")}
70-
</Typography>
71-
)}
78+
<Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
79+
<Typography variant="body2" mt={1}>
80+
<strong>Subjects:</strong> {subj && `${subj.length} subjects`}
81+
</Typography>
82+
{/* {subj && <Chip label={`${subj.length} subjects`} color="primary" />} */}
83+
</Stack>
84+
<Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
85+
{readme && (
86+
<Typography variant="body2" paragraph>
87+
<strong>Summary:</strong> {readme}
88+
</Typography>
89+
)}
90+
</Stack>
91+
<Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
92+
{info?.Authors?.length && (
93+
<Typography variant="body2" mt={1}>
94+
<strong>Authors:</strong> {info?.Authors?.join(", ")}
95+
</Typography>
96+
)}
97+
</Stack>
7298

73-
{doiLink && (
74-
<Stack mt={1}>
75-
<Chip
76-
label="DOI"
77-
component="a"
78-
href={doiLink}
79-
target="_blank"
80-
rel="noopener noreferrer"
81-
clickable
82-
sx={{ backgroundColor: "#c9a636", color: "white" }}
83-
/>
99+
<Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
100+
{doiLink && (
101+
<Stack mt={1}>
102+
<Chip
103+
label="DOI"
104+
component="a"
105+
href={doiLink}
106+
target="_blank"
107+
rel="noopener noreferrer"
108+
clickable
109+
sx={{ backgroundColor: Colors.accent, color: "white" }}
110+
/>
111+
</Stack>
112+
)}
84113
</Stack>
85-
)}
114+
</Stack>
86115
</CardContent>
87116
</Card>
88117
);

0 commit comments

Comments
 (0)