Skip to content

Commit 469c0a1

Browse files
authored
Fix layout and stylings (#152)
* spinner blue, resizing fix * improve fetching file * update test snapshot and jest config for ResizeObserver * lower case Fetching * set peerDeps * update snapshots * table header width
1 parent 5468da5 commit 469c0a1

File tree

20 files changed

+92
-84
lines changed

20 files changed

+92
-84
lines changed

config/jest/jest.setup.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ global.IntersectionObserver = class IntersectionObserver {
1515
return null;
1616
}
1717
};
18+
19+
global.ResizeObserver = class ResizeObserver {
20+
disconnect() {
21+
return null;
22+
}
23+
24+
observe() {
25+
return null;
26+
}
27+
28+
unobserve() {
29+
return null;
30+
}
31+
};

examples/package-lock.json

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/src/App.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const App = () => {
2828
<div className={networkContainerClassName}>
2929
<NetworkViewer
3030
onDataLoaded={() => setIsDataLoaded(true)}
31+
onReset={() => setIsDataLoaded(false)}
3132
{...fileOptions}
3233
/>
3334
</div>

examples/src/App.module.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
@import './../../src/styles/variables';
22

33
.app-container {
4+
display: flex;
5+
flex-direction: column;
46
height: 100%;
57

68
.network-container {
7-
height: auto;
9+
flex: 1 1 auto;
810

911
&.network-container-data-loaded {
1012
height: 100%;

examples/src/Components/Footer.module.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
@import './../../../src/styles/variables';
22

33
.footer {
4-
position: absolute;
5-
bottom: 0;
6-
left: 0;
7-
width: 100%;
84
padding: 1rem;
95
background-color: $white-97;
106
border-top: 1px solid $white-80;

package-lock.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@
5757
"recharts": ">=1.8.5"
5858
},
5959
"peerDependencies": {
60-
"react": "^16.13.1",
61-
"react-dom": "^16.13.1"
60+
"react": "^16.13.1"
6261
},
6362
"devDependencies": {
6463
"@babel/core": "^7.24.8",

src/Components/Actions/ResetButton.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ import IconReset from '../../icons/IconReset';
55
import Styles from './IconButton.styles.scss';
66
import { useNetwork } from '../../state/network/Context';
77
import Tooltip from '../Common/Tooltip/Tooltip';
8+
import { useTheme } from '../../state/theme/Context';
89

910
const ResetButton = () => {
10-
const {
11-
actions,
12-
callbacks,
13-
} = useNetwork();
11+
const { actions, callbacks } = useNetwork();
12+
const { showImportHar } = useTheme();
1413

1514
const handleReset = () => {
1615
actions.resetState();
1716
callbacks.onReset();
17+
18+
if (showImportHar) {
19+
window.history.pushState({}, document.title, '/');
20+
}
1821
};
1922

2023
return (

src/Components/Import/InputHAR.jsx

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,26 @@ import URLInput from './URLInput';
66

77
const SAMPLE_HAR_URL = 'https://raw.githubusercontent.com/saucelabs/network-viewer/main/examples/src/data/network.har';
88

9-
const InputHAR = () => {
10-
const handleURLSubmit = (fetchInfo) => {
11-
const { origin, pathname } = document.location;
12-
const newURL = `${origin}${pathname}?${stringify(fetchInfo)}`;
13-
document.location.href = newURL;
14-
};
15-
16-
return (
17-
<div className={Styles['input-har-container']}>
18-
<h4 className={Styles['input-har-text']}>
19-
OR add HAR file URL in the below input box
20-
</h4>
21-
<URLInput onSubmit={handleURLSubmit} />
22-
<p>
23-
<span>
24-
For Example use this har file
25-
</span>
26-
<a
27-
className={Styles['example-url']}
28-
href={SAMPLE_HAR_URL}
29-
rel="noopener noreferrer"
30-
target="_blank"
31-
>
32-
{SAMPLE_HAR_URL}
33-
</a>
34-
</p>
35-
</div>
36-
);
37-
};
9+
const InputHAR = () => (
10+
<div className={Styles['input-har-container']}>
11+
<h4 className={Styles['input-har-text']}>
12+
OR add HAR file URL in the below input box
13+
</h4>
14+
<URLInput />
15+
<p>
16+
<span>
17+
For Example use this har file
18+
</span>
19+
<a
20+
className={Styles['example-url']}
21+
href={SAMPLE_HAR_URL}
22+
rel="noopener noreferrer"
23+
target="_blank"
24+
>
25+
{SAMPLE_HAR_URL}
26+
</a>
27+
</p>
28+
</div>
29+
);
3830

3931
export default InputHAR;

src/Components/Import/URLInput.jsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import React, { useState } from 'react';
2-
import PropTypes from 'prop-types';
32

43
import Styles from './URLInput.styles.scss';
54
import Button from './../../../src/Components/Common/Button';
65
import CORSCheckbox from './CORSCheckbox';
6+
import { useNetwork } from '../../state/network/Context';
77

8-
const URLInput = ({ onSubmit }) => {
8+
const URLInput = () => {
9+
const { actions } = useNetwork();
910
const [url, setURL] = useState('');
1011
const [isCORSEnabled, setCORS] = useState(false);
1112
const handleInputChange = ({ target }) => {
1213
setURL(target.value);
1314
};
1415

1516
const handleSubmit = () => {
16-
onSubmit({
17+
actions.fetchFile({
1718
file: url,
1819
isCORSEnabled,
1920
});
@@ -43,8 +44,4 @@ const URLInput = ({ onSubmit }) => {
4344
);
4445
};
4546

46-
URLInput.propTypes = {
47-
onSubmit: PropTypes.func.isRequired,
48-
};
49-
5047
export default URLInput;

0 commit comments

Comments
 (0)