11// @ts -nocheck
2- import React , { useEffect } from 'react' ;
2+ import React , { useEffect , useState } from 'react' ;
33
4+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
5+ import {
6+ faToggleOff ,
7+ faToggleOn ,
8+ } from '@fortawesome/free-solid-svg-icons' ;
49import Action from '../components/Action' ;
510import SwitchAppDropdown from '../components/SwitchApp' ;
611import { emptySnapshots , changeView , changeSlider } from '../actions/actions' ;
@@ -14,13 +19,15 @@ const resetSlider = () => {
1419} ;
1520
1621function ActionContainer ( props ) : JSX . Element {
17- const [ { tabs, currentTab } , dispatch ] = useStoreContext ( ) ;
22+ const [ { tabs, currentTab, port } , dispatch ] = useStoreContext ( ) ;
1823 const {
1924 currLocation, hierarchy, sliderIndex, viewIndex, snapshots,
2025 } = tabs [ currentTab ] ;
2126 const {
22- toggleActionContainer, actionView, setActionView
27+ toggleActionContainer, actionView, setActionView,
2328 } = props ;
29+ const [ recordingActions , setRecordingActions ] = useState ( true ) ;
30+
2431 let actionsArr = [ ] ;
2532 const hierarchyArr : any [ ] = [ ] ;
2633
@@ -125,24 +132,41 @@ function ActionContainer(props): JSX.Element {
125132 setActionView ( true ) ;
126133 } , [ setActionView ] ) ;
127134
135+ // Function sends message to background.js which sends message to the content script
128136 const toggleRecord = ( ) => {
129137 port . postMessage ( {
130138 action : 'toggleRecord' ,
139+ tabId : currentTab ,
131140 } ) ;
132- // change color of record button or switch svg/img file
141+ // Record button's icon is being togggled on click
142+ setRecordingActions ( ! recordingActions ) ;
133143 } ;
134144
135145 // the conditional logic below will cause ActionContainer.test.tsx to fail as it cannot find the Empty button
136146 // UNLESS actionView={true} is passed into <ActionContainer /> in the beforeEach() call in ActionContainer.test.tsx
137147 return (
138148 < div id = "action-id" className = "action-container" >
139- < div id = "arrow" >
140- < aside className = "aside" >
141- < a onClick = { toggleActionContainer } className = "toggle" >
142- < i />
143- </ a >
144- </ aside >
145- { /* <button className="recordBtn" onClick={toggleRecord}>Record</button> */ }
149+ < div className = "actionToolContainer" >
150+ < div id = "arrow" >
151+ < aside className = "aside" >
152+ < a onClick = { toggleActionContainer } className = "toggle" >
153+ < i />
154+ </ a >
155+ </ aside >
156+
157+ </ div >
158+ < a
159+ type = "button"
160+ id = "recordBtn"
161+ onClick = { toggleRecord }
162+ >
163+ < i />
164+ { recordingActions ? (
165+ < FontAwesomeIcon className = "fa-regular" icon = { faToggleOn } />
166+ ) : (
167+ < FontAwesomeIcon className = "fa-regular" icon = { faToggleOff } />
168+ ) }
169+ </ a >
146170 </ div >
147171 { actionView ? (
148172 < div className = "action-button-wrapper" >
0 commit comments