Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | import { Card, CardActionArea, CardContent, CardMedia, useMediaQuery, useTheme, } from "@mui/material"; import Link from "next/link"; import { Page } from "proto/pages_pb"; import React, { useMemo } from "react"; import LinesEllipsis from "react-lines-ellipsis"; import { routeToPlace } from "routes"; import makeStyles from "utils/makeStyles"; import stripMarkdown from "utils/stripMarkdown"; const useStyles = makeStyles((theme) => ({ image: { backgroundColor: theme.palette.grey[200], height: 80, objectFit: "contain", [theme.breakpoints.up("sm")]: { height: 100, }, [theme.breakpoints.up("md")]: { height: 120, }, }, placePreview: { ...theme.typography.caption, marginTop: theme.spacing(0.5), [theme.breakpoints.down("md")]: { height: `calc(2 * calc(${theme.typography.caption.lineHeight} * ${theme.typography.caption.fontSize}))`, }, }, title: { ...theme.typography.h3, height: `calc(2 * calc(${theme.typography.h3.lineHeight} * ${theme.typography.h3.fontSize}))`, marginBottom: theme.spacing(0.5), marginTop: 0, }, })); export default function PlaceCard({ place, className, }: { place: Page.AsObject; className?: string; }) { const classes = useStyles(); const theme = useTheme(); const isMdUp = useMediaQuery(theme.breakpoints.up("md")); const contentPreview = useMemo( () => stripMarkdown(place.content.substr(0, 300).replace("\n", " ")), [place.content] ); return ( <Card className={className}> <Link href={routeToPlace(place.pageId, place.slug)}> <CardActionArea> <CardMedia src={ place.photoUrl ? place.photoUrl : "/img/placeImagePlaceholder.svg" } className={classes.image} component="img" /> <CardContent> <LinesEllipsis text={place.title} maxLine={2} component="h3" className={classes.title} /> <LinesEllipsis text={place.address} maxLine={isMdUp ? 4 : 2} component="p" className={classes.placePreview} /> {contentPreview && ( <LinesEllipsis text={contentPreview} maxLine={isMdUp ? 6 : 2} component="p" className={classes.placePreview} /> )} </CardContent> </CardActionArea> </Link> </Card> ); } |