Skip to content

Commit 5424815

Browse files
Merge pull request #7 from oslabs-beta/toggleRecordState
Created button to toggle whether to record state or ignore state changes. Added styling to the toggle record button. Updated Time Jump Sidebar view where toggle record button is hidden. Added comments for toggle record button
2 parents 2955889 + c111ea4 commit 5424815

File tree

10 files changed

+82
-27
lines changed

10 files changed

+82
-27
lines changed

README.fr.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ Après avoir cloné ce référentiel, les développeurs peuvent simplement exéc
131131

132132
## <b>Auteurs</b>
133133

134+
- **Kris Sorensen** - [@kris-sorensen](https://github.com/kris-sorensen)
135+
- **Daljit Gill** - [@dgill05](https://github.com/dgill05)
136+
- **Ben Michareune** - [@bmichare](https://github.com/bmichare)
137+
- **Dane Corpion** - [@danecorpion](https://github.com/danecorpion)
134138
- **Becca Viner** - [@rtviner](https://github.com/rtviner)
135139
- **Caitlin Chan** - [@caitlinchan23](https://github.com/caitlinchan23)
136140
- **Kim Mai Nguyen** - [@Nkmai](https://github.com/Nkmai)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ After cloning this repository, developers can simply run `npm run docs` at the r
156156
- [What time is it? Reactime!](https://medium.com/@liuedar/what-time-is-it-reactime-fd7267b9eb89)
157157

158158
## <b>Authors</b>
159+
160+
- **Kris Sorensen** - [@kris-sorensen](https://github.com/kris-sorensen)
161+
- **Daljit Gill** - [@dgill05](https://github.com/dgill05)
162+
- **Ben Michareune** - [@bmichare](https://github.com/bmichare)
163+
- **Dane Corpion** - [@danecorpion](https://github.com/danecorpion)
159164
- **Harry Fox** - [@StackOverFlowWhereArtThou](https://github.com/StackOverFlowWhereArtThou)
160165
- **Nathan Richardson** - [@BagelEnthusiast](https://github.com/BagelEnthusiast)
161166
- **David Bernstein** - [@dangitbobbeh](https://github.com/dangitbobbeh)

README.rus.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ Reactime beta поддерживает приложения, написанны
107107

108108
## <b>Авторы</b>
109109

110+
- **Kris Sorensen** - [@kris-sorensen](https://github.com/kris-sorensen)
111+
- **Daljit Gill** - [@dgill05](https://github.com/dgill05)
112+
- **Ben Michareune** - [@bmichare](https://github.com/bmichare)
113+
- **Dane Corpion** - [@danecorpion](https://github.com/danecorpion)
110114
- **Becca Viner** - [@rtviner](https://github.com/rtviner)
111115
- **Caitlin Chan** - [@caitlinchan23](https://github.com/caitlinchan23)
112116
- **Kim Mai Nguyen** - [@Nkmai](https://github.com/Nkmai)

src/app/components/ComponentMap.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ export default function ComponentMap({
188188
// }
189189
// };
190190
// inner(state);
191-
192191
// return result;
193192
// --------------------------------------------------------------------------------------------
194193
return ['stateful'];

src/app/containers/ActionContainer.tsx

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
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';
49
import Action from '../components/Action';
510
import SwitchAppDropdown from '../components/SwitchApp';
611
import { emptySnapshots, changeView, changeSlider } from '../actions/actions';
@@ -14,13 +19,15 @@ const resetSlider = () => {
1419
};
1520

1621
function 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">

src/app/containers/MainContainer.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,21 @@ function MainContainer(): any {
3030
setActionView(!actionView);
3131
const toggleElem = document.querySelector('aside');
3232
toggleElem.classList.toggle('no-aside');
33+
// hides the record toggle button from Actions Container in Time Jump sidebar view
34+
const recordBtn = document.getElementById('recordBtn');
35+
if (recordBtn.style.display === 'none') {
36+
recordBtn.style.display = 'flex';
37+
} else {
38+
recordBtn.style.display = 'none';
39+
}
3340
};
34-
41+
// let port;
3542
useEffect(() => {
3643
// only open port once
3744
if (currentPort) return;
3845

3946
// open long-lived connection with background script
4047
const port = chrome.runtime.connect();
41-
4248
// listen for a message containing snapshots from the background script
4349
port.onMessage.addListener(
4450
(message: {
@@ -209,4 +215,4 @@ function MainContainer(): any {
209215
);
210216
}
211217

212-
export default MainContainer;
218+
export default MainContainer;

src/app/styles/components/_buttons.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,15 @@
321321

322322
/* sidebar button open and closing functionality */
323323
aside {
324-
width: 250px;
324+
// width: 250px;
325325
background: #242529;
326326
color: #fff;
327327
transition: width 1s;
328328
}
329329

330330
.no-aside {
331331
width: 30px;
332+
margin-right: 15px;
332333
}
333334

334335
.toggle {
@@ -352,8 +353,8 @@ aside {
352353
}
353354

354355
.toggle i {
355-
top: 46%;
356-
left: 4%;
356+
top: 8px;
357+
left: 9px;
357358
display: block;
358359
background: $blue-brand;
359360
}

src/app/styles/layout/_actionContainer.scss

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,18 @@
99
color: #fffeff;
1010
}
1111

12-
.recordBtn{
13-
position: relative;
14-
left: 80%;
15-
// visibility: hidden;
12+
#recordBtn{
13+
height: 100%;
14+
display:flex;
15+
}
16+
17+
.actionToolContainer{
18+
display: flex;
19+
justify-content: space-between;
20+
align-items: center;
21+
}
22+
23+
#recordBtn .fa-regular{
24+
height: 100%;
25+
width: 28px;
1626
}

src/extension/background.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ chrome.runtime.onConnect.addListener(port => {
209209
case 'jumpToSnap':
210210
chrome.tabs.sendMessage(tabId, msg);
211211
return true; // attempt to fix message port closing error, consider return Promise
212+
case 'toggleRecord':
213+
chrome.tabs.sendMessage(tabId, msg);
214+
return true;
212215
default:
213216
return true;
214217
}

src/extension/contentScript.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
let firstMessage = true;
1212
// Listens for window messages (from the injected script on the DOM)
1313
let isRecording = true;
14+
1415
window.addEventListener('message', msg => {
1516
// Event listener runs constantly based on actions
1617
// recorded on the test application from backend files (linkFiber.ts).
@@ -40,16 +41,14 @@ window.addEventListener('message', msg => {
4041
// Listening for messages from the UI of the Reactime extension.
4142
chrome.runtime.onMessage.addListener(request => {
4243
const { action }: { action: string; } = request;
43-
// this is only listening for Jump toSnap
44-
4544
if (action) {
45+
// Message being sent from background.js
46+
// This is toggling the record button on Reactime when clicked
4647
if (action === 'toggleRecord') {
4748
isRecording = !isRecording;
4849
}
49-
50+
// this is only listening for Jump toSnap
5051
if (action === 'jumpToSnap') {
51-
//
52-
//
5352
chrome.runtime.sendMessage(request);
5453
}
5554
// After the jumpToSnap action has been sent back to background js,

0 commit comments

Comments
 (0)