Skip to content

Commit accc6b1

Browse files
committed
implement add to calendar feature for events
1 parent d6f7cf8 commit accc6b1

File tree

10 files changed

+314
-14
lines changed

10 files changed

+314
-14
lines changed

src/assets/App.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,9 @@ a {
458458
box-shadow: 0 0 15px 2px var(--card-actions-background-shadow);
459459
color: var(--card-action-button-color);
460460
cursor: pointer;
461-
display: block;
461+
display: inline-flex;
462+
align-items: center;
463+
justify-content: center;
462464
font-size: 18px;
463465
height: 28px;
464466
line-height: 12px;
@@ -1127,6 +1129,13 @@ Producthunt item
11271129
opacity: 1;
11281130
}
11291131

1132+
.calendarProviderIcon {
1133+
width: 16px;
1134+
height: 16px;
1135+
border-radius: 4px;
1136+
vertical-align: sub;
1137+
margin-right: 6px;
1138+
}
11301139
/*****************
11311140
*** BREAKPOINTS
11321141
*******************/
Lines changed: 60 additions & 0 deletions
Loading
Lines changed: 28 additions & 0 deletions
Loading
Lines changed: 35 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

src/components/Elements/CardWithActions/CardItemWithActions.tsx

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react'
1+
import React, { useCallback, useEffect, useState } from 'react'
22
import { BiBookmarkMinus, BiBookmarkPlus, BiShareAlt } from 'react-icons/bi'
33
import { MdBugReport } from 'react-icons/md'
44
import { reportLink } from 'src/config'
@@ -14,15 +14,22 @@ type CardItemWithActionsProps = {
1414
url: string
1515
id: string
1616
}
17+
showBookmarkAction?: boolean
1718
source: string
1819
cardItem: React.ReactNode
20+
customActions?: Array<{
21+
label: string
22+
Component: React.ReactNode
23+
}>
1924
sourceType?: 'rss' | 'supported'
2025
}
2126

2227
export const CardItemWithActions = ({
2328
cardItem,
2429
item,
2530
source,
31+
showBookmarkAction = true,
32+
customActions,
2633
sourceType = 'supported',
2734
}: CardItemWithActionsProps) => {
2835
const [shareModalData, setShareModalData] = useState<ShareModalData>()
@@ -32,7 +39,7 @@ export const CardItemWithActions = ({
3239
userBookmarks.some((bm) => bm.source === source && bm.url === item.url)
3340
)
3441

35-
const onBookmarkClick = () => {
42+
const onBookmarkClick = useCallback(() => {
3643
const itemToBookmark = {
3744
title: item.title,
3845
url: item.url,
@@ -56,22 +63,22 @@ export const CardItemWithActions = ({
5663
} else {
5764
trackLinkBookmark(analyticsAttrs)
5865
}
59-
}
66+
}, [isBookmarked, item, source, sourceType, bookmarkPost, unbookmarkPost])
6067

6168
useEffect(() => {
6269
setIsBookmarked(userBookmarks.some((bm) => bm.source === source && bm.url === item.url))
6370
}, [userBookmarks, source, item])
6471

65-
const onShareModalClicked = () => {
72+
const onShareModalClicked = useCallback(() => {
6673
setShareModalData({ title: item.title, link: item.url, source: source })
67-
}
74+
}, [item.title, item.url, source])
6875

69-
const onReportClicked = () => {
76+
const onReportClicked = useCallback(() => {
7077
const tags = useUserPreferences
7178
.getState()
7279
.userSelectedTags.map((tag) => tag.label.toLocaleLowerCase())
7380
window.open(`${reportLink}?tags=${tags.join(',')}&url=${item.url}`, '_blank')
74-
}
81+
}, [item.url])
7582

7683
return (
7784
<div key={item.id} className="blockRow">
@@ -96,12 +103,22 @@ export const CardItemWithActions = ({
96103
aria-label="Open share modal">
97104
<BiShareAlt />
98105
</button>
99-
<button
100-
className={`blockActionButton ${isBookmarked ? 'active' : ''}`}
101-
onClick={onBookmarkClick}
102-
aria-label="Bookmark item">
103-
{!isBookmarked ? <BiBookmarkPlus /> : <BiBookmarkMinus />}
104-
</button>
106+
107+
{customActions &&
108+
customActions.map((action) => (
109+
<div key={action.label} aria-label={action.label}>
110+
{action.Component}
111+
</div>
112+
))}
113+
114+
{showBookmarkAction && (
115+
<button
116+
className={`blockActionButton ${isBookmarked ? 'active' : ''}`}
117+
onClick={onBookmarkClick}
118+
aria-label="Bookmark item">
119+
{!isBookmarked ? <BiBookmarkPlus /> : <BiBookmarkMinus />}
120+
</button>
121+
)}
105122
</div>
106123
</div>
107124
)

0 commit comments

Comments
 (0)