From 72ce122880f5347e20bc03c78e9088a494adea0c Mon Sep 17 00:00:00 2001 From: gtitov Date: Fri, 15 Sep 2023 16:26:28 +0300 Subject: [PATCH] sync highlight on map and in list --- src/ArticleCard.tsx | 42 ++++++++++++++++++++++-------------------- src/KartaPage.tsx | 17 ++++++++++------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/ArticleCard.tsx b/src/ArticleCard.tsx index f1d3dba..7c47294 100644 --- a/src/ArticleCard.tsx +++ b/src/ArticleCard.tsx @@ -14,25 +14,36 @@ const useStyles = createStyles((theme) => ({ body: { padding: theme.spacing.md, }, + + address: { + "&:hover": { + color: "red", + cursor: "pointer" + } + } })); interface ArticleCardVerticalProps { + id: number; image: string; category: string; title: string; - date: string; - author: { - name: string; - avatar: string; - }; + address: string; + // author: { + // name: string; + // avatar: string; + // }; } export function ArticleCardVertical({ + id, image, category, title, - date, - author, + address, + // author, + selected, + setSelected }: ArticleCardVerticalProps) { const { classes } = useStyles(); return ( @@ -43,21 +54,12 @@ export function ArticleCardVertical({ {category} - + {title} - - - - {author.name} - - - • - - - {date} - - + setSelected(id)} className={classes.address}> + • {address} + diff --git a/src/KartaPage.tsx b/src/KartaPage.tsx index 6a7fa11..ca45bf6 100644 --- a/src/KartaPage.tsx +++ b/src/KartaPage.tsx @@ -65,8 +65,8 @@ export function KartaPage() { mapStyle={mapstyle} interactiveLayerIds={['points-layer']} onClick={e => e.features[0] ? setSelected(e.features[0].properties.id) : setSelected(-1)} - onMouseEnter={e => setCursor('pointer')} - onMouseLeave={e => setCursor('grab')} + onMouseEnter={() => setCursor('pointer')} + onMouseLeave={() => setCursor('grab')} > {articles !== null && articles.length > 0 && articles.map(article => { const articleInfo = { + "id": article.id, // "image": article.attributes.cover.data !== null ? "http://strapi.wg.gateway.ts" + article.attributes.cover.data.attributes.url : "https://images.unsplash.com/photo-1628890923662-2cb23c2e0cfe?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&q=80", "category": "technology", "title": article.attributes.title, - "date": new Date(article.attributes.publishedAt).toLocaleDateString("ru-RU"), - "author": { - "name": "Elsa Brown", - "avatar": "https://images.unsplash.com/photo-1628890923662-2cb23c2e0cfe?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&q=80" - } + "address": new Date(article.attributes.publishedAt).toLocaleDateString("ru-RU"), + // "author": { + // "name": "Elsa Brown", + // "avatar": "https://images.unsplash.com/photo-1628890923662-2cb23c2e0cfe?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=200&q=80" + // }, + "selected": selected, + "setSelected": setSelected } return