@@ -4,6 +4,7 @@ import ReactModal from 'react-modal'
44import Select , { ActionMeta , MultiValue , SingleValue } from 'react-select'
55import Toggle from 'react-toggle'
66import 'react-toggle/style.css'
7+ import { ChipsSet } from 'src/components/Elements'
78import { Footer } from 'src/components/Layout'
89import { SUPPORTED_CARDS , SUPPORTED_SEARCH_ENGINES , supportLink } from 'src/config'
910import { Tag , useRemoteConfigStore } from 'src/features/remoteConfig'
@@ -12,19 +13,21 @@ import {
1213 identifyUserLanguages ,
1314 identifyUserLinksInNewTab ,
1415 identifyUserListingMode ,
16+ identifyUserMaxVisibleCards ,
1517 identifyUserSearchEngine ,
1618 identifyUserTheme ,
1719 trackLanguageAdd ,
1820 trackLanguageRemove ,
1921 trackListingModeSelect ,
22+ trackMaxVisibleCardsChange ,
2023 trackSearchEngineSelect ,
2124 trackSourceAdd ,
2225 trackSourceRemove ,
2326 trackTabTarget ,
2427 trackThemeSelect ,
2528} from 'src/lib/analytics'
2629import { useUserPreferences } from 'src/stores/preferences'
27- import { SearchEngineType , SelectedCard } from 'src/types'
30+ import { Option , SearchEngineType , SelectedCard } from 'src/types'
2831import { RssSetting } from './RssSetting'
2932import './settings.css'
3033
@@ -48,8 +51,10 @@ export const SettingsModal = ({ showSettings, setShowSettings }: SettingsModalPr
4851 listingMode,
4952 theme,
5053 searchEngine,
54+ maxVisibleCards,
5155 setTheme,
5256 setListingMode,
57+ setMaxVisibleCards,
5358 setSearchEngine,
5459 setOpenLinksNewTab,
5560 setCards,
@@ -144,6 +149,15 @@ export const SettingsModal = ({ showSettings, setShowSettings }: SettingsModalPr
144149 identifyUserTheme ( newTheme )
145150 }
146151
152+ const onMaxVisibleCardsChange = ( selectedChips : Option [ ] ) => {
153+ if ( selectedChips . length ) {
154+ const maxVisibleCards = parseInt ( selectedChips [ 0 ] . value )
155+ setMaxVisibleCards ( maxVisibleCards )
156+ identifyUserMaxVisibleCards ( maxVisibleCards )
157+ trackMaxVisibleCardsChange ( maxVisibleCards )
158+ }
159+ }
160+
147161 return (
148162 < ReactModal
149163 isOpen = { showSettings }
@@ -215,6 +229,43 @@ export const SettingsModal = ({ showSettings, setShowSettings }: SettingsModalPr
215229
216230 < RssSetting setSelectedCards = { setSelectedCards } />
217231
232+ < div className = "settingRow" >
233+ < p className = "settingTitle" > Max number of cards to display</ p >
234+ < div className = "settingContent" >
235+ < ChipsSet
236+ className = { 'noMargin alternative-color' }
237+ canSelectMultiple = { false }
238+ options = { [
239+ {
240+ label : '3 cards' ,
241+ value : '3' ,
242+ } ,
243+ {
244+ label : '4 cards' ,
245+ value : '4' ,
246+ } ,
247+ {
248+ label : '5 cards' ,
249+ value : '5' ,
250+ } ,
251+ {
252+ label : '6 cards' ,
253+ value : '6' ,
254+ } ,
255+ ] }
256+ defaultValues = { [ maxVisibleCards . toString ( ) ] }
257+ onChange = { ( _ , selectedChips ) => {
258+ onMaxVisibleCardsChange ( selectedChips )
259+ } }
260+ />
261+
262+ < p className = "settingHint" >
263+ To ensure a seamless experience, we may adjust the selected number to align with the
264+ resolution of your screen.
265+ </ p >
266+ </ div >
267+ </ div >
268+
218269 < div className = "settingRow" >
219270 < p className = "settingTitle" > Dark Mode</ p >
220271 < div className = "settingContent" >
0 commit comments