Skip to content

Commit 5f006a0

Browse files
authored
Merge pull request #127 from medyo/feat/add-rss
Implement Adding Rss Feeds as sources
2 parents bbac80a + a3de22d commit 5f006a0

37 files changed

Lines changed: 645 additions & 143 deletions

File tree

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"country-emoji": "^1.5.4",
1717
"dompurify": "^2.2.7",
1818
"eslint-plugin-react": "^7.28.0",
19+
"htmlparser2": "^8.0.1",
1920
"jsonpath": "^1.1.1",
2021
"localforage": "^1.9.0",
2122
"normalize.css": "^8.0.1",
@@ -35,6 +36,7 @@
3536
"react-spring-bottom-sheet": "^3.4.1",
3637
"react-toggle": "^4.1.1",
3738
"react-tooltip": "^4.2.21",
39+
"rss-to-json": "^2.1.1",
3840
"styled-components": "2",
3941
"timeago.js": "^4.0.2",
4042
"type-fest": "^1.2.0",

src/assets/App.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ a {
272272
width: 18px;
273273
height: 18px;
274274
}
275-
275+
.blockHeaderIcon .rss {
276+
color:#ee802f;
277+
}
276278
.blockRow {
277279
scroll-snap-align: start;
278280
padding: 8px 16px;

src/assets/variables.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ html.dark {
8484
--tab-neutral-button-text: #a2a7ad;
8585
--tab-positive-button-background: #0366d6;
8686
--tab-positive-button-text: white;
87+
88+
--settings-input-background-color: #0d1116;
89+
--settings-input-border-color: #3a4553;
90+
--settings-input-border-focus-color: #6b7b90;
91+
--settings-input-placeholder-color: #42474e;
92+
--settings-input-text-color: #fff
8793
}
8894

8995
html.light {
@@ -160,4 +166,11 @@ html.light {
160166
--tab-neutral-button-text: #3c5065;
161167
--tab-positive-button-background: #0366d6;
162168
--tab-positive-button-text: white;
169+
170+
--settings-input-background-color: #ffffff;
171+
--settings-input-border-color: #e9ebec;
172+
--settings-input-border-focus-color: #c4d6df;
173+
--settings-input-placeholder-color: #97a6ad;
174+
--settings-input-text-color: #253b53
175+
163176
}

src/components/Elements/Card/Card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import React from 'react'
22
import { BsBoxArrowInUpRight } from 'react-icons/bs'
33
import { ref } from 'src/config'
44
import { useUserPreferences } from 'src/stores/preferences'
5-
import { SupportedCard } from 'src/config'
5+
import { SupportedCardType } from 'src/types'
66

77
type CardProps = {
88
children: React.ReactNode
9-
card: SupportedCard
9+
card: SupportedCardType
1010
titleComponent?: React.ReactNode
1111
fullBlock?: boolean
1212
}

src/components/Elements/CardWithActions/CardItemWithActions.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
import React, { useState, useEffect } from 'react'
1+
import React, { useEffect, useState } from 'react'
2+
import { BiBookmarkMinus, BiBookmarkPlus } from 'react-icons/bi'
3+
import { Attributes, trackLinkBookmark, trackLinkUnBookmark } from 'src/lib/analytics'
24
import { useBookmarks } from 'src/stores/bookmarks'
3-
import { BiBookmarkPlus } from 'react-icons/bi'
4-
import { BiBookmarkMinus } from 'react-icons/bi'
5-
import { trackLinkBookmark, trackLinkUnBookmark, Attributes } from 'src/lib/analytics'
65
import { BaseEntry } from 'src/types'
76

87
type CardItemWithActionsProps = {
98
item: BaseEntry
109
index: number
1110
source: string
1211
cardItem: React.ReactNode
12+
sourceType?: 'rss' | 'supported'
1313
}
1414

1515
export const CardItemWithActions = ({
1616
cardItem,
1717
item,
1818
index,
1919
source,
20+
sourceType = 'supported',
2021
}: CardItemWithActionsProps) => {
2122
const { bookmarkPost, unbookmarkPost, userBookmarks } = useBookmarks()
2223
const [isBookmarked, setIsBookmarked] = useState(
@@ -27,6 +28,7 @@ export const CardItemWithActions = ({
2728
title: item.title,
2829
url: item.url,
2930
source,
31+
sourceType: sourceType ?? 'rss',
3032
}
3133
if (isBookmarked) {
3234
unbookmarkPost(itemToBookmark)

src/components/Elements/FloatingFilter/FloatingFilter.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { FiFilter } from 'react-icons/fi'
33
import { BottomSheet } from 'react-spring-bottom-sheet'
44
import 'react-spring-bottom-sheet/dist/style.css'
55
import { ChipsSet } from 'src/components/Elements'
6-
import { dateRanges, GLOBAL_TAG, MY_LANGUAGES_TAG, SupportedCard } from 'src/config'
6+
import { dateRanges, GLOBAL_TAG, MY_LANGUAGES_TAG } from 'src/config'
77
import { trackCardDateRangeSelect, trackCardLanguageSelect } from 'src/lib/analytics'
88
import { useUserPreferences } from 'src/stores/preferences'
9+
import { SupportedCardType } from 'src/types'
910

1011
type ListingFilterMobileProps = {
11-
card: SupportedCard
12+
card: SupportedCardType
1213
filters?: ('datesRange' | 'language')[]
1314
}
1415

src/components/Layout/AppContentLayout.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import { useState } from 'react'
2-
import { BottomNavigation } from '../Elements'
32
import { isDesktop } from 'react-device-detect'
43
import { useUserPreferences } from 'src/stores/preferences'
5-
import { MobileCards } from './MobileCards'
4+
import { BottomNavigation } from '../Elements'
65
import { DesktopCards } from './DesktopCards'
6+
import { MobileCards } from './MobileCards'
77

88
export const AppContentLayout = ({
99
setShowSettings,
1010
}: {
1111
setShowSettings: (value: boolean | ((prevVar: boolean) => boolean)) => void
1212
}) => {
13-
const { cards } = useUserPreferences()
13+
const { cards, userCustomCards } = useUserPreferences()
1414
const [selectedCard, setSelectedCard] = useState(cards[0])
1515

1616
return (
1717
<>
1818
<main className="AppContent HorizontalScroll">
19-
{isDesktop ? <DesktopCards cards={cards} /> : <MobileCards selectedCard={selectedCard} />}
19+
{isDesktop ? (
20+
<DesktopCards cards={cards} userCustomCards={userCustomCards} />
21+
) : (
22+
<MobileCards selectedCard={selectedCard} />
23+
)}
2024
</main>
2125

2226
<BottomNavigation

src/components/Layout/DesktopCards.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import React from 'react'
22
import { SUPPORTED_CARDS } from 'src/config'
3-
import { SelectedCard } from 'src/types'
3+
import { CustomRssCard } from 'src/features/cards'
4+
import { SelectedCard, SupportedCardType } from 'src/types'
45

5-
export const DesktopCards = ({ cards }: { cards: SelectedCard[] }) => {
6+
export const DesktopCards = ({
7+
cards,
8+
userCustomCards,
9+
}: {
10+
cards: SelectedCard[]
11+
userCustomCards: SupportedCardType[]
12+
}) => {
13+
const AVAILABLE_CARDS = [...SUPPORTED_CARDS, ...userCustomCards]
614
return (
715
<>
816
{cards.map((card, index) => {
9-
const constantCard = SUPPORTED_CARDS.find((c) => c.value === card.name)
17+
const constantCard = AVAILABLE_CARDS.find((c) => c.value === card.name)
1018
if (!constantCard) {
1119
return null
1220
}
1321

14-
return React.createElement(constantCard.component, {
22+
return React.createElement(constantCard?.component || CustomRssCard, {
1523
key: card.name,
1624
meta: constantCard,
1725
withAds: index === 0,

src/components/Layout/Header.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import React, { useEffect, useRef, useState } from 'react'
2-
import { BsFillGearFill } from 'react-icons/bs'
1+
import { useEffect, useRef, useState } from 'react'
2+
import { BsFillBookmarksFill, BsFillGearFill, BsMoon } from 'react-icons/bs'
33
import { CgTab } from 'react-icons/cg'
4-
import { BsFillBookmarksFill } from 'react-icons/bs'
4+
import { IoMdSunny } from 'react-icons/io'
55
import { ReactComponent as HackertabLogo } from 'src/assets/logo.svg'
6+
import { SearchBar } from 'src/components/Elements/SearchBar'
67
import { UserTags } from 'src/components/Elements/UserTags'
7-
import { SettingsModal } from 'src/features/settings'
8-
import { BsMoon } from 'react-icons/bs'
9-
import { IoMdSunny } from 'react-icons/io'
108
import { Changelog } from 'src/features/changelog'
11-
import { SearchBar } from 'src/components/Elements/SearchBar'
12-
import { useUserPreferences } from 'src/stores/preferences'
9+
import { SettingsModal } from 'src/features/settings'
10+
import { identifyUserTheme, trackThemeSelect } from 'src/lib/analytics'
1311
import { useBookmarks } from 'src/stores/bookmarks'
14-
import { trackThemeSelect, identifyUserTheme } from 'src/lib/analytics'
12+
import { useUserPreferences } from 'src/stores/preferences'
1513

1614
type HeaderProps = {
1715
showSideBar: boolean

src/components/Layout/MobileCards.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React from 'react'
22
import { SUPPORTED_CARDS } from 'src/config'
3+
import { CustomRssCard } from 'src/features/cards'
34
import { SelectedCard } from 'src/types'
45

56
export const MobileCards = ({ selectedCard }: { selectedCard: SelectedCard }) => {
67
const currentCard = SUPPORTED_CARDS.find((c) => c.value === selectedCard.name)
78
return currentCard
8-
? React.createElement(currentCard.component, {
9+
? React.createElement(currentCard?.component || CustomRssCard, {
910
key: currentCard.value,
1011
meta: currentCard,
1112
withAds: true,

0 commit comments

Comments
 (0)