Skip to content

Commit e444e62

Browse files
committed
expander fully functional
1 parent cbe97ac commit e444e62

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

src/app/containers/ActionContainer.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function ActionContainer(props) {
1919
const { hierarchy, sliderIndex, viewIndex } = tabs[currentTab];
2020
let actionsArr = [];
2121
const hierarchyArr: any[] = [];
22-
const { seeActionContainer } = props;
22+
const { timeTravel } = props;
23+
// React.useEffect(() => { console.log("component updated"); }, [timeTravel]);
2324

2425
// function to traverse state from hiararchy and also getting information on display name and component name
2526
const displayArray = (obj: {
@@ -113,14 +114,17 @@ function ActionContainer(props) {
113114
}
114115
);
115116

116-
if (!seeActionContainer) {
117+
if (!timeTravel) {
118+
console.log("should be false:", timeTravel)
117119
return (
120+
//returns an empty div when timeTravel is false
121+
118122
<div></div>
119123
)
120124
}
121125
else {
122-
console.log("ActionContainer can see prop updates");
123-
//this is not logging; the prop is not being udpdated...
126+
console.log("Should be true:", timeTravel);
127+
// this is not logging; the prop is not being udpdated or the component is not being re-rendered.
124128
return (
125129
<div className="action-container">
126130
<SwitchAppDropdown />

src/app/containers/MainContainer.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import HeadContainer from './HeadContainer';
33
import ActionContainer from './ActionContainer';
44
import StateContainer from './StateContainer';
@@ -15,22 +15,8 @@ import { useStoreContext } from '../store';
1515
import MPID from '../user_id/user_id';
1616
import useForceUpdate from '../components/useForceUpdate'
1717

18-
//logic for toggling on the action container sidebar
19-
let seeActionContainer: boolean = false;
20-
21-
function toggleActionContainer(): void {
22-
seeActionContainer = !seeActionContainer;
23-
const bodyContainer = document.getElementById("bodyContainer");
2418

25-
if (seeActionContainer) {
26-
bodyContainer.classList.remove("body-container1");
27-
bodyContainer.classList.add("body-container2");
28-
}
29-
else {
30-
bodyContainer.classList.remove("body-container2");
31-
bodyContainer.classList.add("body-container1");
32-
}
33-
}
19+
//logic for toggling on the action container sidebar
3420

3521

3622
const mixpanel = require('mixpanel').init('12fa2800ccbf44a5c36c37bc9776e4c0', {
@@ -39,9 +25,26 @@ const mixpanel = require('mixpanel').init('12fa2800ccbf44a5c36c37bc9776e4c0', {
3925
});
4026

4127
function MainContainer(): any {
28+
const [timeTravel, setTimeTravel] = useState(false);
4229
const [store, dispatch] = useStoreContext();
4330
const { tabs, currentTab, port: currentPort } = store;
4431
// add event listeners to background script
32+
33+
function toggleActionContainer(): void {
34+
setTimeTravel(!timeTravel)
35+
const bodyContainer = document.getElementById("bodyContainer");
36+
37+
if (timeTravel) {
38+
bodyContainer.classList.remove("body-container2");
39+
bodyContainer.classList.add("body-container1");
40+
41+
}
42+
else {
43+
bodyContainer.classList.remove("body-container1");
44+
bodyContainer.classList.add("body-container2");
45+
}
46+
}
47+
4548
useEffect(() => {
4649
// only open port once
4750
if (currentPort) return;
@@ -198,7 +201,7 @@ function MainContainer(): any {
198201
<div className="main-container">
199202
{/* <HeadContainer /> */}
200203
<div id="bodyContainer" className="body-container1">
201-
<ActionContainer seeActionContainer={seeActionContainer}/>
204+
<ActionContainer timeTravel={timeTravel}/>
202205
{snapshots.length ? (
203206
<StateContainer
204207
toggleActionContainer={toggleActionContainer}

src/app/containers/StateContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const StateContainer = (props: StateContainerProps): JSX.Element => {
4242
<div className="main-navbar-container">
4343
<div className="main-navbar-text">{Text}</div>
4444
<div className="main-navbar">
45-
<button className="toggleAC" onClick={()=> toggleActionContainer()}>View ActionContainer</button>
45+
<button className="toggleAC" onClick={()=> toggleActionContainer()}>View Time Travel</button>
4646
<NavLink
4747
className="main-router-link"
4848
activeClassName="is-active"

src/app/styles/layout/_stateContainer.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
border-radius: 5px;
1616
border: 1px solid rgba(184, 196, 194, 0.25);
1717
height: 75%;
18+
text-decoration: none;
19+
}
20+
21+
.toggleAC:focus {
22+
outline: none;
23+
box-shadow: none;
1824
}
1925

2026
.state-container .navbar {

0 commit comments

Comments
 (0)