Skip to content

Commit c4152b0

Browse files
committed
fix: displaying rss cards on mobile
1 parent 9e0fc1a commit c4152b0

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

src/components/Elements/BottomNavigation/BottomNavigation.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { AiOutlineMenu } from 'react-icons/ai'
2+
import { BsRssFill } from 'react-icons/bs'
13
import { SUPPORTED_CARDS } from 'src/config'
2-
import { SelectedCard } from 'src/types'
34
import { useUserPreferences } from 'src/stores/preferences'
4-
import { AiOutlineMenu } from 'react-icons/ai'
5+
import { SelectedCard } from 'src/types'
56

67
type BottomNavigationProps = {
78
selectedCard: SelectedCard
@@ -14,31 +15,33 @@ export const BottomNavigation = ({
1415
setSelectedCard,
1516
setShowSettings,
1617
}: BottomNavigationProps) => {
17-
const { cards } = useUserPreferences()
18+
const { cards, userCustomCards } = useUserPreferences()
19+
const AVAILABLE_CARDS = [...SUPPORTED_CARDS, ...userCustomCards]
1820

1921
return (
2022
<div className="bottomNavigation">
2123
{cards.map((card) => {
22-
const constantCard = SUPPORTED_CARDS.find((c) => c.value === card.name)
24+
const constantCard = AVAILABLE_CARDS.find((c) => c.value === card.name)
25+
2326
return (
24-
<a
27+
<button
2528
key={card.name}
2629
className={
2730
'navigationItem ' + (selectedCard && selectedCard.name === card.name ? 'active' : '')
2831
}
29-
href="/#"
30-
onClick={(e) => setSelectedCard(card)}>
31-
{constantCard?.icon}
32-
</a>
32+
onClick={() => setSelectedCard(card)}>
33+
{card.type === 'supported'
34+
? constantCard?.icon
35+
: <img src={constantCard?.icon as string} alt="" /> || <BsRssFill className="rss" />}
36+
</button>
3337
)
3438
})}
3539
{
36-
<a
40+
<button
3741
className={'navigationItem '}
38-
href="/#"
39-
onClick={(e) => setShowSettings((prev: boolean) => !prev)}>
42+
onClick={() => setShowSettings((prev: boolean) => !prev)}>
4043
{<AiOutlineMenu />}
41-
</a>
44+
</button>
4245
}
4346
</div>
4447
)

src/components/Layout/MobileCards.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import React from 'react'
22
import { SUPPORTED_CARDS } from 'src/config'
33
import { CustomRssCard } from 'src/features/cards'
4+
import { useUserPreferences } from 'src/stores/preferences'
45
import { SelectedCard } from 'src/types'
56

67
export const MobileCards = ({ selectedCard }: { selectedCard: SelectedCard }) => {
7-
const currentCard = SUPPORTED_CARDS.find((c) => c.value === selectedCard.name)
8+
const { userCustomCards } = useUserPreferences()
9+
const currentCard = [...SUPPORTED_CARDS, ...userCustomCards].find(
10+
(c) => c.value === selectedCard.name
11+
)
12+
813
return currentCard
914
? React.createElement(currentCard?.component || CustomRssCard, {
1015
key: currentCard.value,

0 commit comments

Comments
 (0)