Skip to content

Commit 2b9c8ea

Browse files
committed
Some minor refactoring
1 parent f8f75cd commit 2b9c8ea

File tree

15 files changed

+254
-161
lines changed

15 files changed

+254
-161
lines changed

packages/diffhtml-devtools/shared/scripts/bridge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export default function devTools(Internals) {
244244
await setExtension(true);
245245

246246
// Start keep-alive in case we disconnect.
247-
//keepAlive();
247+
keepAlive();
248248

249249
// Call existing cached tasks.
250250
if (cacheTask.length) {

packages/diffhtml-devtools/shared/scripts/components/split-view.js

+2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ class DevtoolsSplitView extends WebComponent {
1818
display: flex;
1919
flex: 1;
2020
flex-direction: row;
21+
height: 100%;
2122
}
2223
2324
.split-view {
2425
display: flex;
2526
width: 100%;
27+
height: 100%;
2628
}
2729
`;
2830
}

packages/diffhtml-devtools/shared/scripts/components/transaction-detail.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ import PropTypes from 'prop-types';
44

55
const { keys } = Object;
66

7-
class DevtoolsTransactionRow extends WebComponent {
7+
class DevtoolsTransactionDetail extends WebComponent {
88
static propTypes = {
9-
index: PropTypes.number,
109
transaction: PropTypes.object,
11-
stateName: PropTypes.string,
12-
startTime: PropTypes.number,
13-
endTime: PropTypes.number,
1410
}
1511

1612
render() {
@@ -291,4 +287,4 @@ class DevtoolsTransactionRow extends WebComponent {
291287
}
292288
}
293289

294-
customElements.define('devtools-transaction-row', DevtoolsTransactionRow);
290+
customElements.define('devtools-transaction-detail', DevtoolsTransactionDetail);

packages/diffhtml-devtools/shared/scripts/components/transaction-row.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class DevtoolsTransactionRow extends WebComponent {
2828

2929
const {
3030
domNode = '',
31-
markup = {},
3231
aborted = false,
3332
promises = [],
3433
surpressedCount,
@@ -43,18 +42,18 @@ class DevtoolsTransactionRow extends WebComponent {
4342
}
4443
});
4544

46-
const fps = endTime ? 1000 / (endTime - startTime) : Infinity;
47-
4845
return html`
4946
<link rel="stylesheet" href="/styles/theme.css">
5047
<style>${this.styles()}</style>
5148
5249
<td class="center aligned">
53-
${surpressedCount}
50+
${Boolean(surpressedCount) && html`
51+
<i class="icon plus" />
52+
`}
53+
5454
${unnecessaryRender && transaction.completed && html`
5555
<div
5656
data-tooltip="Nothing changed, unnecessary render!"
57-
data-position="right center"
5857
>
5958
<i class="icon warning sign yellow" />
6059
</div>

packages/diffhtml-devtools/shared/scripts/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ const inspect = selector => chrome.devtools.inspectedWindow.eval(
7373
`inspect($$('${selector}')[0])`
7474
);
7575

76-
const refresh = () => location.reload();
77-
7876
const clearEntries = () => {
7977
assign(state, {
8078
inProgress: [],
@@ -88,7 +86,7 @@ const fadeIn = el => {
8886
return new Promise(resolve => el.animate([
8987
{ opacity: 0 },
9088
{ opacity: 1 },
91-
], { duration: 240 }).onfinish = resolve)
89+
], { duration: 140 }).onfinish = resolve)
9290
.then(() => {
9391
el.style.opacity = 1;
9492
});

packages/diffhtml-devtools/shared/scripts/panels/mounts.js

+14-15
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,23 @@ class DevtoolsMountsPanel extends WebComponent {
125125
}
126126

127127
addedElement(domNode) {
128-
console.log(domNode);
129-
//return new Promise(resolve => {
130-
// domNode.animate([
131-
// { background: 'transparent' },
132-
// { background: 'green' },
133-
// { background: 'transparent' },
134-
// ], { duration: 200 }).onfinish = resolve;
135-
//});
128+
return new Promise(resolve => {
129+
domNode.animate([
130+
{ background: 'transparent' },
131+
{ background: '#E1FFE1' },
132+
{ background: 'transparent' },
133+
], { duration: 200 }).onfinish = resolve;
134+
});
136135
}
137136

138137
removedElement(domNode) {
139-
//return new Promise(resolve => {
140-
// domNode.animate([
141-
// { background: 'transparent' },
142-
// { background: 'red' },
143-
// { background: 'transparent' },
144-
// ], { duration: 200 }).onfinish = resolve;
145-
//});
138+
return new Promise(resolve => {
139+
domNode.animate([
140+
{ background: 'transparent' },
141+
{ background: '#FFE1E1' },
142+
{ background: 'transparent' },
143+
], { duration: 200 }).onfinish = resolve;
144+
});
146145
}
147146

148147
renderVTree(vTree) {

packages/diffhtml-devtools/shared/scripts/panels/transactions.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DevtoolsTransactionsPanel extends WebComponent {
2626
}
2727

2828
render() {
29-
const { inspect, clearEntries, inProgress, completed } = this.props;
29+
const { clearEntries, inProgress, completed } = this.props;
3030
const { expandedIndex, isExpanded, autoScroll } = this.state;
3131
const { toggleAutoscroll } = this;
3232

@@ -124,13 +124,17 @@ class DevtoolsTransactionsPanel extends WebComponent {
124124
<tbody>
125125
<tr class="missing">
126126
<td colspan="11">
127-
No transactions
127+
No renders
128128
</td>
129129
</tr>
130130
</tbody>
131131
`}
132132
</table>
133133
`}
134+
135+
${expandedIndex !== -1 && html`
136+
<i class="icon close" onClick=${this.toggleExpanded(-1)}></i>
137+
`}
134138
</div>
135139
</div>
136140
`;

packages/diffhtml-devtools/shared/styles/index.css

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "/styles/theme.css";
2+
@import "/styles/tooltip.css";
23

34
body, main {
45
color: #333;
@@ -20,13 +21,13 @@ body::-webkit-scrollbar {
2021
width: 5px;
2122
position: absolute;
2223
}
23-
24+
2425
body::-webkit-scrollbar-track {
2526
background: #ddd;
2627
}
27-
28+
2829
body::-webkit-scrollbar-thumb {
29-
background: #666;
30+
background: #666;
3031
}
3132

3233
h1:first-child {

packages/diffhtml-devtools/shared/styles/theme.css

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import '/node_modules/semantic-ui-css/semantic.min.css';
22
@import '/node_modules/semantic-ui-icon/icon.min.css';
3+
@import "/styles/tooltip.css";
34

45
.ui.inverted.input > input {
56
background: #3E3E3E;

packages/diffhtml/lib/tasks/sync-trees.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ export default function syncTrees(/** @type {Transaction} */ transaction) {
5151
StateCache.delete(domNode);
5252
StateCache.set(createNode(newTree), transaction.state);
5353
}
54-
// Otherwise only diff the children.
55-
else if (newTree) {
56-
transaction.patches = syncTree(oldTree || null, newTree, []);
54+
// Synchronize the top level elements.
55+
else {
56+
transaction.patches = syncTree(oldTree || null, newTree || null, []);
5757
}
5858

5959
measure('sync trees');

0 commit comments

Comments
 (0)