Skip to content

Commit f419df6

Browse files
Merge branch 'dev' of https://github.com/oslabs-beta/Reactime into dev
2 parents 78c60e1 + 70a6728 commit f419df6

File tree

6 files changed

+77
-14
lines changed

6 files changed

+77
-14
lines changed

demo-app/src/client/Components/Board.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Board extends Component<{}, BoardState> {
3030

3131
//added void
3232
componentDidUpdate(): void {
33-
this.checkForWinner();
33+
this.checkForWinner()
3434
}
3535

3636
/**
@@ -116,8 +116,8 @@ class Board extends Component<{}, BoardState> {
116116
}
117117

118118
//added type for render
119-
render(): JSX.Element {
120-
const rows: Array<JSX.Element> = [];
119+
render(): JSX.Element {
120+
const rows: Array<JSX.Element> = [];
121121
for (let i = 0; i < 3; i++) {
122122
rows.push(
123123
<Row key={i} row={i} handleBoxClick={this.handleBoxClick} values={this.state.board[i]} />,

reactime-website

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ const nodeParentFill = '#161521'; //#161521 original
2828
const nodeChildFill = '#62d6fb'; //#62d6fb original
2929
const nodeParentStroke = '#F00008'; //#F00008 original
3030
const nodeChildStroke = '#4D4D4D'; //#4D4D4D original
31+
let stroke = '';
32+
33+
/* Heat Map Colors (for links) */
34+
const lightOrange = '#F1B476';
35+
const darkOrange = '#E4765B';
36+
const red = '#C64442';
37+
const plum = '#8C2743';
3138

3239
const defaultMargin: DefaultMargin = {
3340
top: 30,
@@ -189,7 +196,7 @@ export default function ComponentMap({
189196
linkType,
190197
orientation,
191198
});
192-
return totalWidth < 10 ? null : (
199+
return totalWidth < 10 ? null : (
193200
<div>
194201
<LinkControls
195202
layout={layout}
@@ -224,19 +231,66 @@ export default function ComponentMap({
224231
size={[sizeWidth / aspect, sizeHeight / aspect]}
225232
separation={(a, b) => (a.parent === b.parent ? 0.5 : 0.5) / a.depth}
226233
>
234+
227235
{(tree) => (
228236
<Group top={origin.y + 35} left={origin.x + 50 / aspect}>
229-
{tree.links().map((link, i) => (
237+
{tree.links().map((link, i) => {
238+
const linkName = link.source.data.name;
239+
const propsObj = link.source.data.componentData.props;
240+
const childPropsObj = link.target.data.componentData.props;
241+
let propsLength;
242+
let childPropsLength;
243+
console.log(`------------------------------${i}:`);
244+
245+
246+
console.log(`LINK: ${linkName}`, link);
247+
console.log('>PROPS: ', propsObj);
248+
if (propsObj) {
249+
propsLength = Object.keys(propsObj).length;
250+
console.log('>> props_length: ', propsLength);
251+
}
252+
if (childPropsObj) {
253+
childPropsLength = Object.keys(childPropsObj).length;
254+
console.log('>> child_props_length: ', childPropsLength);
255+
}
256+
// go to https://en.wikipedia.org/wiki/Logistic_function
257+
// for an explanation of Logistic functions and parameters used
258+
const yshift = -3;
259+
const x0 = 5;
260+
const L = 25;
261+
const k = .4;
262+
const strokeWidthIndex = yshift + L / (1 + Math.exp(-k * (childPropsLength - x0)));
263+
// const strokeWidthIndex = childPropsLength * 2.5 + 1;
264+
console.log('strokeWidthIndex: ', strokeWidthIndex);
265+
266+
if (strokeWidthIndex <= 1) {
267+
stroke = '#808080';
268+
} else {
269+
if (childPropsLength <= 1) {
270+
stroke = lightOrange;
271+
} else if (childPropsLength <= 2) {
272+
stroke = darkOrange;
273+
} else if (childPropsLength <= 3) {
274+
stroke = red;
275+
} else {
276+
stroke = plum;
277+
}
278+
// stroke = '#df6f37'
279+
}
280+
281+
return (
230282
<LinkComponent
231283
className='compMapLink'
232284
key={i}
233285
data={link}
234286
percent={stepPercent}
235-
//stroke={linkStroke}
236-
strokeWidth='1'
287+
stroke={stroke} // color of the link --not used--
288+
strokeWidth= {strokeWidthIndex} /* strokeWidth */ // width of the link
237289
fill='none'
238290
/>
239-
))}
291+
)
292+
})
293+
}
240294

241295
{tree.descendants().map((node, key) => {
242296
const widthFunc: number = (name) => {

src/app/components/StateRoute/StateRoute.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useDispatch, useSelector } from 'react-redux';
1515
import PerformanceVisx from './PerformanceVisx/PerformanceVisx';
1616
import WebMetricsContainer from './WebMetrics/WebMetricsContainer';
1717
import { MainState, RootState, StateRouteProps } from '../../FrontendTypes';
18-
import AxContainer from './AxMap/AxMap';
18+
import type AxContainer from './AxMap/AxMap';
1919

2020
/*
2121
Loads the appropriate StateRoute view and renders the Map, Performance, History, Webmetrics, and Tree navbar buttons after clicking on the 'State' button located near the top rightmost corner.

src/app/styles/components/_componentMap.scss

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
.compMapLink {
2-
stroke: $map-link;
3-
}
1+
// .compMapLink {
2+
// // stroke: $map-link;
3+
// stroke: $secondary-color;
4+
// }
5+
.compMapLink:hover {
6+
box-shadow: 10px 10px rgb(163, 205, 24);
7+
};
48

59
.comp-map-options {
610
color: $map-options-label;
@@ -38,4 +42,6 @@
3842

3943
.compMapRootText {
4044
fill: $map-root-text;
41-
}
45+
}
46+
47+

src/app/styles/layout/_stateContainer.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
background-color: $navbar-unselected;
9494
text-decoration: none;
9595
color: $navbar-unselected-text;
96+
97+
border-top-right-radius: 10px;
98+
border-top-left-radius: 10px;
9699
}
97100

98101
.router-link:hover {

0 commit comments

Comments
 (0)