@@ -9,6 +9,9 @@ import TimeSlider from '../container/TimeSlider.jsx';
99import Events from '../container/Events.jsx' ;
1010import Details from '../container/Details.jsx' ;
1111
12+ // styled components
13+ import { Wrapper } from '../styles/SplitPane.jsx' ;
14+
1215// import from styled components to create global styles
1316const GlobalStyle = createGlobalStyle `
1417 html {
@@ -37,9 +40,10 @@ class App extends Component {
3740
3841 this . state = {
3942 data : [ ] ,
43+ searchField : '' ,
44+ filteredData : [ ] ,
4045 isPlaying : false ,
4146 isRecording : false ,
42- isSearching : false ,
4347 isPlayingIndex : 0 ,
4448 } ;
4549
@@ -55,6 +59,11 @@ class App extends Component {
5559 }
5660
5761 componentDidMount ( ) {
62+ // *******************************************************
63+ // need to impletement setState for filteredData to same value as data
64+ // this.setState({ data, filteredData: data });
65+ // *******************************************************
66+
5867 // adds listener to the effects that are gonna be sent from
5968 // our edited useReducer from the 'react' library.
6069 chrome . runtime . onConnect . addListener ( ( portFromExtension ) => {
@@ -79,7 +88,6 @@ class App extends Component {
7988 this . setState ( { isPlayingIndex : 0 } ) ;
8089 }
8190
82- console . log ( 'isplaying' ) ;
8391 let { isPlaying } = this . state ;
8492 isPlaying = ! isPlaying ;
8593 this . setState ( { isPlaying } ) ;
@@ -130,10 +138,21 @@ class App extends Component {
130138 }
131139
132140 // filter search bar results
133- // *** NOT FINISHED ***
134141 searchChange ( e ) {
135142 const { data } = this . state ;
136- console . log ( data ) ;
143+
144+ // grab user entry from filter bar
145+ const compareSearchValue = e . target . value ;
146+
147+ // set state with compare value
148+ this . setState ( { searchField : compareSearchValue } )
149+
150+ // match results from our filter entry to data
151+ const actions = data . filter ( function ( item ) {
152+ const type = item . action . type . toLowerCase ( ) ;
153+ return type . includes ( compareSearchValue . toLowerCase ( ) ) ;
154+ } ) ;
155+ this . setState ( { filteredData : actions } ) ;
137156 }
138157
139158 // time travel bar change
@@ -178,42 +197,45 @@ class App extends Component {
178197 isPlaying,
179198 setIsRecording,
180199 isRecording,
200+ filteredData,
181201 } = this . state ;
182202
183203 return (
184204 < >
185205 < GlobalStyle />
186- < SplitPane
187- left = {
188- (
189- < Events
190- data = { data }
191- addAction = { this . addActionToView }
192- toTheFuture = { this . toTheFuture }
193- toThePast = { this . toThePast }
194- activeEventId = { id }
195- />
196- ) }
197- right = {
198- (
199- < Details
200- action = { action }
201- id = { id }
202- actionState = { state }
203- />
204- ) }
205- />
206- < TimeSlider
207- data = { data }
208- toTheFuture = { this . toTheFuture }
209- toThePast = { this . toThePast }
210- isPlaying = { isPlaying }
211- isPlayingIndex = { this . state . isPlayingIndex }
212- isRecording = { isRecording }
213- setIsPlaying = { this . setIsPlaying }
214- setIsRecording = { this . setIsRecording }
215- handleBarChange = { this . handleBarChange }
216- />
206+ < Wrapper >
207+ < SplitPane
208+ left = {
209+ (
210+ < Events
211+ data = { data }
212+ addAction = { this . addActionToView }
213+ activeEventId = { id }
214+ searchChange = { this . searchChange }
215+ filteredData = { filteredData }
216+ />
217+ ) }
218+ right = {
219+ (
220+ < Details
221+ action = { action }
222+ id = { id }
223+ actionState = { state }
224+ />
225+ ) }
226+ />
227+ < TimeSlider
228+ data = { data }
229+ toTheFuture = { this . toTheFuture }
230+ toThePast = { this . toThePast }
231+ isPlaying = { isPlaying }
232+ isPlayingIndex = { this . state . isPlayingIndex }
233+ isRecording = { isRecording }
234+ setIsPlaying = { this . setIsPlaying }
235+ setIsRecording = { this . setIsRecording }
236+ handleBarChange = { this . handleBarChange }
237+ />
238+ </ Wrapper >
217239 </ >
218240 ) ;
219241 }
0 commit comments