Skip to content

Commit 009f5c5

Browse files
authored
Merge pull request #17 from oslabs-beta/javi/web-vitals
Javi/web vitals
2 parents 2c0d646 + d5888b6 commit 009f5c5

File tree

6 files changed

+140
-56
lines changed

6 files changed

+140
-56
lines changed

src/CodeEditor/CustomDialog/newDialog.css

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
top: 0px;
1919
z-index: 10;
2020
font-size: .8em;
21+
font-weight: bold;
2122
}
2223

2324
.CodeMirror-advanced-dialog input {
@@ -31,6 +32,7 @@
3132

3233
.CodeMirror-advanced-dialog button {
3334
font-size: 70%;
35+
font-weight: bold;
3436
}
3537

3638
.CodeMirror-advanced-dialog .row {
@@ -57,7 +59,3 @@
5759
background-color: inherit;
5860
color: inherit;
5961
}
60-
61-
.CodeMirror-find-label .CodeMirror-search-count {
62-
text-shadow: white 0 0 0.2em;
63-
}

src/CodeEditor/CustomSearch/newSearch.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
}
104104

105105
function parseQuery(query) {
106+
if (query === null) return;
106107
const isRE = query.match(/^\/(.*)\/([a-z]*)$/);
107108
if (isRE) {
108109
try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
@@ -116,6 +117,7 @@
116117
}
117118

118119
function startSearch(cm, state, query) {
120+
if (query === null) return;
119121
state.queryText = query;
120122
state.query = parseQuery(query);
121123
cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
@@ -156,7 +158,6 @@
156158
cm.operation(() => {
157159
const state = getSearchState(cm);
158160
let cursor = getSearchCursor(cm, state.query, reverse ? state.posFrom : state.posTo);
159-
// console.log(cursor);
160161
if (!cursor.find(reverse)) {
161162
cursor = getSearchCursor(cm, state.query, reverse ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0));
162163
if (!cursor.find(reverse)) return;

src/PerformanceDashboard/RerenderChart.svelte

+44-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</script>
4343

4444
<main>
45-
<h5 class="graph-title">Component Rerender Tracker</h5>
45+
<h5 class="graph-title" data-tooltip='Dynamically track re-render counts of Svelte app components.'>Component Rerender Tracker</h5>
4646
<svg {width} {height} class="chart">
4747
<g transform={`translate(${margin.left},${margin.top})`}>
4848
{#each xScale.ticks() as tickValue}
@@ -82,6 +82,7 @@
8282
margin-top: 0;
8383
padding-top: 50px;
8484
font-size: 12px;
85+
position: relative;
8586
}
8687
8788
.chart {
@@ -114,4 +115,46 @@
114115
fill: #ccc;
115116
}
116117
118+
/* CODE BELOW IS FOR CSS TOOLTIP ON RERENDER CHART TITLE */
119+
.graph-title::before,
120+
.graph-title::after {
121+
--scale: 0;
122+
--arrow-size: 10px;
123+
--tooltip-color: #F3EFEE;
124+
125+
position: absolute;
126+
bottom: -.10rem;
127+
left: 50%;
128+
transform: translateX(-50%) translateY(var(--translate-y, 0)) scale(var(--scale));
129+
transition: 150ms transform;
130+
transform-origin: top center;
131+
}
132+
133+
.graph-title::before {
134+
--translate-y: calc(100% + var(--arrow-size));
135+
136+
content: attr(data-tooltip);
137+
font-size: .9rem;
138+
color: rgb(20, 20, 20);
139+
padding: .5rem;
140+
border-radius: .3rem;
141+
text-align: center;
142+
width: max-content;
143+
max-width: 300%;
144+
background: var(--tooltip-color);
145+
}
146+
147+
.graph-title:hover::before,
148+
.graph-title:hover::after {
149+
--scale: .8;
150+
}
151+
152+
.graph-title::after {
153+
--translate-y: calc(1 * var(--arrow-size));
154+
155+
content: '';
156+
border: var(--arrow-size) solid transparent;
157+
border-bottom-color: var(--tooltip-color);
158+
transform-origin: bottom center;
159+
}
117160
</style>

src/PerformanceDashboard/WebVitals.svelte

+46-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
import { vitals } from "../DataStore/SvelteStormDataStore";
33
const { ipcRenderer } = require('electron');
44
5-
console.log('Web Vitals Exists', vitals);
65
ipcRenderer.on('web-vitals', (event, args) => {
76
vitals.update((currVal) => {
87
currVal[args.name] = args.value;
9-
// console.log('vitals', currVal);
108
return currVal;
119
});
1210
});
@@ -17,7 +15,7 @@
1715
<main>
1816

1917
<div class='web-vitals-parent-container'>
20-
<h5 class='web-vitals-title'>Web Vitals</h5>
18+
<h5 class='web-vitals-title' data-Tooltip="Web Vitals are graded on a 'Good', 'Needs Improvement', and 'Poor' scale.">Web Vitals</h5>
2119
<div class='web-vitals-columns-container'>
2220
<div class='vitals-left'>
2321
<div class='individual-vital'>
@@ -75,5 +73,50 @@
7573
padding: 1em;
7674
text-align: center;
7775
}
76+
/* CODE BELOW CREATES TOOLTIP UNDER WEB VITALS TITLE*/
77+
.web-vitals-title {
78+
position: relative;
79+
}
80+
81+
.web-vitals-title::before,
82+
.web-vitals-title::after {
83+
--scale: 0;
84+
--arrow-size: 10px;
85+
--tooltip-color: #F3EFEE;
86+
87+
position: absolute;
88+
bottom: -.10rem;
89+
left: 50%;
90+
transform: translateX(-50%) translateY(var(--translate-y, 0)) scale(var(--scale));
91+
transition: 150ms transform;
92+
transform-origin: top center;
93+
}
94+
95+
.web-vitals-title::before {
96+
--translate-y: calc(100% + var(--arrow-size));
97+
98+
content: attr(data-tooltip);
99+
font-size: .9rem;
100+
color: rgb(20, 20, 20);
101+
padding: .5rem;
102+
border-radius: .3rem;
103+
text-align: center;
104+
width: max-content;
105+
max-width: 300%;
106+
background: var(--tooltip-color);
107+
}
108+
109+
.web-vitals-title:hover::before,
110+
.web-vitals-title:hover::after {
111+
--scale: .8;
112+
}
113+
114+
.web-vitals-title::after {
115+
--translate-y: calc(1 * var(--arrow-size));
78116
117+
content: '';
118+
border: var(--arrow-size) solid transparent;
119+
border-bottom-color: var(--tooltip-color);
120+
transform-origin: bottom center;
121+
}
79122
</style>

src/Terminal/XTerm.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
2727
// The result can be accessed through the `m`-variable.
28-
if(!$saveToFileName){
28+
// if(!$saveToFileName){
2929
m.forEach((match, groupIndex) => {
3030
3131
localhostToUse = match;
@@ -40,7 +40,7 @@
4040
$saveToFileName = path.resolve(__dirname, `./CapturedSnaps/${filename}`);
4141
ipcRenderer.send('openDebugAppWindow', localhostToUse);
4242
});
43-
}
43+
// }
4444
}
4545
}
4646

src/index.js

+44-45
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ let browser;
4545
//app.on is a start of the main process that controls the lifecycle events
4646
//Fires once when app is ready..
4747
app.on('ready', () => {
48-
createApplicationMenu();
4948
createWindow();
5049
});
5150

@@ -133,14 +132,12 @@ const createWindow = (exports.createWindow = () => {
133132
// let watcher;
134133

135134
//show window by calling the listener once
136-
newWindow.once('ready-to-show', () => {
135+
newWindow.on('ready-to-show', () => {
137136
newWindow.show();
138137
});
139-
140138
newWindow.on('focus', createApplicationMenu);
141139

142140
//save changes dialog modal message
143-
144141
newWindow.on('close', (event) => {
145142
if (newWindow.isDocumentEdited()) {
146143
event.preventDefault();
@@ -161,56 +158,58 @@ const createWindow = (exports.createWindow = () => {
161158
newWindow.on('closed', () => {
162159
windows.delete(newWindow);
163160
createApplicationMenu();
164-
// ptyProcess = null;
165161
newWindow = null;
166162
});
163+
windows.add(newWindow);
167164

168-
var shell = os.platform() === 'win32' ? 'powershell.exe' : 'zsh';
165+
});
169166

170-
// this spawns the terminal window space
171-
var ptyProcess = pty.spawn(shell, [], {
172-
name: 'xterm-color',
173-
cols: 80,
174-
rows: 24,
175-
cwd: process.env.HOME,
176-
// cwd: cwdFilePath,
177-
env: process.env,
178-
});
167+
/*
168+
* Below code (shell and ptyProcess) was previously inside createWindow fxn but
169+
* was causing issues w/ re-activation. Moving it outside of the fxn below
170+
* allows re-activation app but still not perfect implementation
171+
*/
172+
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'zsh';
173+
// this spawns the terminal window space
174+
const ptyProcess = pty.spawn(shell, [], {
175+
name: 'xterm-color',
176+
cols: 80,
177+
rows: 24,
178+
cwd: process.env.HOME,
179+
// cwd: cwdFilePath,
180+
env: process.env,
181+
});
179182

180-
//2022-ST-AJ sends to renderer cwd for it to display on prompt
181-
// ipcMain.on('cwd', (event, data) => {
182-
// event.reply('cwdreply', process.env.PWD);
183-
// });
183+
//2022-ST-AJ sends to renderer cwd for it to display on prompt
184+
// ipcMain.on('cwd', (event, data) => {
185+
// event.reply('cwdreply', process.env.PWD);
186+
// });
184187

185-
// add ipc listen for open folder and reassign ptyProcess.cwd to actual cwd
186-
ipcMain.on('openFolder', (event, data) => {
187-
ptyProcess.cwd = cwdFilePath[0];
188-
});
189-
190-
//2022-ST-AJ node-pty listens to data and send whatever it receives back to xterm to render
191-
ptyProcess.onData((data) => {
192-
newWindow.webContents.send('terminal-incData', data);
193-
});
188+
// add ipc listen for open folder and reassign ptyProcess.cwd to actual cwd
189+
ipcMain.on('openFolder', (event, data) => {
190+
ptyProcess.cwd = cwdFilePath[0];
191+
});
194192

195-
//2022-ST-AJ ipcMain listens on data passed from xterm to write to shell
196-
ipcMain.on('terminal-into', (event, data) => {
197-
ptyProcess.write(data);
198-
});
193+
//2022-ST-AJ node-pty listens to data and send whatever it receives back to xterm to render
194+
ptyProcess.onData((data) => {
195+
newWindow.webContents.send('terminal-incData', data);
196+
});
199197

200-
//2022-ST-AJ ipcMain listens to resizing event from renderer and calls resize on node-pty to align size between node-pty and xterm. They need to align otherwise there are wierd bugs everywhere.
201-
ipcMain.on('terminal-resize', (event, size) => {
202-
const cols = size.cols;
203-
const rows = size.rows;
204-
ptyProcess.resize(cols, rows);
205-
});
198+
//2022-ST-AJ ipcMain listens on data passed from xterm to write to shell
199+
ipcMain.on('terminal-into', (event, data) => {
200+
ptyProcess.write(data);
201+
});
206202

207-
require('electron-reload')(__dirname, {
208-
electron: path.join(__dirname, '../node_modules', '.bin', 'electron'),
209-
awaitWriteFinish: true,
210-
});
203+
//2022-ST-AJ ipcMain listens to resizing event from renderer and calls resize on node-pty to align size between node-pty and xterm. They need to align otherwise there are wierd bugs everywhere.
204+
ipcMain.on('terminal-resize', (event, size) => {
205+
const cols = size.cols;
206+
const rows = size.rows;
207+
ptyProcess.resize(cols, rows);
208+
});
211209

212-
windows.add(newWindow);
213-
// return newWindow;
210+
require('electron-reload')(__dirname, {
211+
electron: path.join(__dirname, '../node_modules', '.bin', 'electron'),
212+
awaitWriteFinish: true,
214213
});
215214

216215
/*
@@ -328,7 +327,7 @@ ipcMain.handle('decreaseFontSize', decreaseFontSize);
328327

329328
ipcMain.handle('createProjectFromUser', createProjectFromUser);
330329

331-
ipcMain.on('openDebugAppWindow', (event, localhostToUse) => {
330+
ipcMain.on('openDebugAppWindow', (event, localhostToUse)=> {
332331
if(localhostToUse.length === 4 || localhostToUse.length === 5) openBrowserWindow(localhostToUse);
333332
});
334333

0 commit comments

Comments
 (0)