@@ -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 { 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,
@@ -153,6 +158,15 @@ export const SettingsModal = ({ showSettings, setShowSettings }: SettingsModalPr
153158 } , 250 )
154159 }
155160
161+ const onMaxVisibleCardsChange = ( selectedChips : Option [ ] ) => {
162+ if ( selectedChips . length ) {
163+ const maxVisibleCards = parseInt ( selectedChips [ 0 ] . value )
164+ setMaxVisibleCards ( maxVisibleCards )
165+ identifyUserMaxVisibleCards ( maxVisibleCards )
166+ trackMaxVisibleCardsChange ( maxVisibleCards )
167+ }
168+ }
169+
156170 return (
157171 < ReactModal
158172 isOpen = { showSettings }
@@ -226,6 +240,43 @@ export const SettingsModal = ({ showSettings, setShowSettings }: SettingsModalPr
226240
227241 < PauseSettings onSubmit = { onPauseSubmit } />
228242
243+ < div className = "settingRow" >
244+ < p className = "settingTitle" > Max number of cards to display</ p >
245+ < div className = "settingContent" >
246+ < ChipsSet
247+ className = { 'noMargin alternative-color' }
248+ canSelectMultiple = { false }
249+ options = { [
250+ {
251+ label : '3 cards' ,
252+ value : '3' ,
253+ } ,
254+ {
255+ label : '4 cards' ,
256+ value : '4' ,
257+ } ,
258+ {
259+ label : '5 cards' ,
260+ value : '5' ,
261+ } ,
262+ {
263+ label : '6 cards' ,
264+ value : '6' ,
265+ } ,
266+ ] }
267+ defaultValues = { [ maxVisibleCards . toString ( ) ] }
268+ onChange = { ( _ , selectedChips ) => {
269+ onMaxVisibleCardsChange ( selectedChips )
270+ } }
271+ />
272+
273+ < p className = "settingHint" >
274+ To ensure a seamless experience, we may adjust the selected number to align with the
275+ resolution of your screen.
276+ </ p >
277+ </ div >
278+ </ div >
279+
229280 < div className = "settingRow" >
230281 < p className = "settingTitle" > Dark Mode</ p >
231282 < div className = "settingContent" >
0 commit comments