@@ -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 ,
24- trackThemeSelect ,
27+ 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 { PauseSettings } from './PauseSettings'
2932import { RssSetting } from './RssSetting'
3033import './settings.css'
@@ -49,8 +52,10 @@ export const SettingsModal = ({ showSettings, setShowSettings }: SettingsModalPr
4952 listingMode,
5053 theme,
5154 searchEngine,
55+ maxVisibleCards,
5256 setTheme,
5357 setListingMode,
58+ setMaxVisibleCards,
5459 setSearchEngine,
5560 setOpenLinksNewTab,
5661 setCards,
@@ -152,6 +157,14 @@ export const SettingsModal = ({ showSettings, setShowSettings }: SettingsModalPr
152157 setPauseTo ( pauseToValue )
153158 } , 250 )
154159 }
160+ const onMaxVisibleCardsChange = ( selectedChips : Option [ ] ) => {
161+ if ( selectedChips . length ) {
162+ const maxVisibleCards = parseInt ( selectedChips [ 0 ] . value )
163+ setMaxVisibleCards ( maxVisibleCards )
164+ identifyUserMaxVisibleCards ( maxVisibleCards )
165+ trackMaxVisibleCardsChange ( maxVisibleCards )
166+ }
167+ }
155168
156169 return (
157170 < ReactModal
@@ -226,6 +239,43 @@ export const SettingsModal = ({ showSettings, setShowSettings }: SettingsModalPr
226239
227240 < PauseSettings onSubmit = { onPauseSubmit } />
228241
242+ < div className = "settingRow" >
243+ < p className = "settingTitle" > Max number of cards to display</ p >
244+ < div className = "settingContent" >
245+ < ChipsSet
246+ className = { 'noMargin alternative-color' }
247+ canSelectMultiple = { false }
248+ options = { [
249+ {
250+ label : '3 cards' ,
251+ value : '3' ,
252+ } ,
253+ {
254+ label : '4 cards' ,
255+ value : '4' ,
256+ } ,
257+ {
258+ label : '5 cards' ,
259+ value : '5' ,
260+ } ,
261+ {
262+ label : '6 cards' ,
263+ value : '6' ,
264+ } ,
265+ ] }
266+ defaultValues = { [ maxVisibleCards . toString ( ) ] }
267+ onChange = { ( _ , selectedChips ) => {
268+ onMaxVisibleCardsChange ( selectedChips )
269+ } }
270+ />
271+
272+ < p className = "settingHint" >
273+ To ensure a seamless experience, we may adjust the selected number to align with the
274+ resolution of your screen.
275+ </ p >
276+ </ div >
277+ </ div >
278+
229279 < div className = "settingRow" >
230280 < p className = "settingTitle" > Dark Mode</ p >
231281 < div className = "settingContent" >
0 commit comments