@@ -121,6 +121,11 @@ const Table = () => {
121
121
? savedImportant
122
122
: new Array ( questions . length ) . fill ( false ) ,
123
123
) ;
124
+
125
+ // Returns an array of question objects that are starred
126
+ const getStarredQuestions = ( ) => {
127
+ return questions . filter ( ( q , idx ) => important [ idx ] ) ;
128
+ } ;
124
129
useEffect ( ( ) => {
125
130
localStorage . setItem ( 'importantProblems' , JSON . stringify ( important ) ) ;
126
131
} , [ important ] ) ;
@@ -591,10 +596,48 @@ const Table = () => {
591
596
useSortBy ,
592
597
) ;
593
598
599
+ const [ showOnlyStarred , setShowOnlyStarred ] = useState ( false ) ;
600
+
601
+ useEffect ( ( ) => {
602
+ if ( showOnlyStarred ) {
603
+ setData ( getStarredQuestions ( ) ) ;
604
+ } else {
605
+ setData ( filteredByCheckbox ( ) ) ;
606
+ }
607
+ // eslint-disable-next-line
608
+ } , [ showOnlyStarred , important , checked , resetCount ] ) ;
609
+
594
610
return (
595
611
< Container className = "table" >
596
612
< ReactTooltip />
597
613
< PatternFrequencies filters = { filters } rows = { filteredRows } />
614
+
615
+ { /* Minimal Show Only Starred Button */ }
616
+ < div
617
+ style = { {
618
+ display : 'flex' ,
619
+ justifyContent : 'flex-end' ,
620
+ marginBottom : '1rem' ,
621
+ } }
622
+ >
623
+ < Button
624
+ color = { showOnlyStarred ? 'warning' : 'secondary' }
625
+ outline = { ! showOnlyStarred }
626
+ size = "sm"
627
+ style = { {
628
+ fontWeight : 600 ,
629
+ letterSpacing : '0.5px' ,
630
+ boxShadow : showOnlyStarred
631
+ ? '0 0 0 2px #ffd666'
632
+ : '0 0 0 1px #d9d9d9' ,
633
+ transition : 'box-shadow 0.2s' ,
634
+ } }
635
+ onClick = { ( ) => setShowOnlyStarred ( ! showOnlyStarred ) }
636
+ >
637
+ { showOnlyStarred ? 'Show All Questions' : 'Show Only Starred ⭐' }
638
+ </ Button >
639
+ </ div >
640
+
598
641
< ReactTable borderless striped hover { ...getTableProps ( ) } >
599
642
< thead >
600
643
{ headerGroups . map ( headerGroup => (
0 commit comments