Skip to content

Commit

Permalink
feat(SinglePublication.tsx): add a 'Read More' button to allow users …
Browse files Browse the repository at this point in the history
…to access the full publication details

The styles in the SinglePublication component have been updated to improve readability and maintain consistency. Additionally, a 'Read More' button has been added to provide users with the ability to access the full details of a publication by clicking on the button.
  • Loading branch information
ktun95 committed Nov 21, 2024
1 parent 587404d commit cf3a184
Showing 1 changed file with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Link } from "react-router-dom"
import {
makeStyles,
Button,
Card,
CardContent,
CardActions,
Chip,
Grid,
Typography,
} from "@material-ui/core"
import { pipe } from "fp-ts/function"
import { map as Amap } from "fp-ts/Array"
import { parseISO, format } from "date-fns/fp"
import { grey, lightBlue } from "@material-ui/core/colors"
import { grey, blueGrey, lightBlue } from "@material-ui/core/colors"
import { type PublicationItem } from "../../common/hooks/useFetchPublications"
import { formatTitle, shortenAllNames } from "../../common/utils/citation"

Expand All @@ -33,6 +34,10 @@ const useStyles = makeStyles((theme) => ({
borderLeft: `10px solid ${theme.palette.primary.main}`,
boxShadow: theme.shadows[4],
paddingLeft: "1rem",
paddingRight: "1rem",
},
cardActions: {
// justifyContent: "flex-end",
},
title: {
fontWeight: 600,
Expand All @@ -45,12 +50,13 @@ const useStyles = makeStyles((theme) => ({
},
identifiers: {
color: theme.palette.primary.main,
marginBottom: theme.spacing(2),
marginBottom: theme.spacing(1),
},
authors: {
marginBottom: theme.spacing(1),
},
chip: {
color: blueGrey[800],
border: `1px solid ${grey[200]}`,
backgroundColor: lightBlue[50],
},
Expand All @@ -61,7 +67,14 @@ const useStyles = makeStyles((theme) => ({
},
abstract: {
fontSize: "16px",
fontFamily:
"ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'",
marginBottom: theme.spacing(2),
color: blueGrey[900],
},
button: {
width: "12rem",
borderRadius: "1rem",
},
}))

Expand All @@ -75,6 +88,11 @@ const SinglePublication = ({ data }: SinglePublicationProperties) => {
const formattedAuthors = shortenAllNames(authors)
const title = formatTitle(data.title).full
const formattedDate = pipe(publishDate, parseISO, format("PPP"))
const onClick = () => {
window.location.assign(
`${import.meta.env.VITE_APP_PUBLICATION_URL}/${pubmedId}`,
)
}
return (
<Card className={classes.card}>
<CardContent>
Expand Down Expand Up @@ -102,6 +120,11 @@ const SinglePublication = ({ data }: SinglePublicationProperties) => {
<Typography variant="body2" className={classes.abstract}>
{abstract}
</Typography>
<CardActions className={classes.cardActions} onClick={onClick}>
<Button className={classes.button} variant="contained">
Read More
</Button>
</CardActions>
</CardContent>
</Card>
)
Expand Down

0 comments on commit cf3a184

Please sign in to comment.