|
1 | 1 | <script>
|
2 | 2 | import { vitals } from "../DataStore/SvelteStormDataStore";
|
| 3 | + import FileDir from "../Directory/FileDir.svelte"; |
3 | 4 | const { ipcRenderer } = require('electron');
|
4 | 5 |
|
5 | 6 | ipcRenderer.on('web-vitals', (event, args) => {
|
6 | 7 | vitals.update((currVal) => {
|
7 |
| - currVal[args.name] = args.value; |
| 8 | + currVal[args.name] = args; |
8 | 9 | return currVal;
|
9 | 10 | });
|
10 | 11 | });
|
|
20 | 21 | <div class='vitals-left'>
|
21 | 22 | <div class='individual-vital'>
|
22 | 23 | <h5>Largest Contentful Paint</h5>
|
23 |
| - <p>{$vitals.LCP === undefined ? "TBD" : ($vitals.LCP).toFixed(3)}</p> |
| 24 | + <p>{$vitals.LCP === undefined ? "TBD" : ($vitals.LCP.value).toFixed(3) + 's'}</p> |
| 25 | + {#if $vitals.LCP} |
| 26 | + <p>Rating: |
| 27 | + <span class={$vitals.LCP.rating[0]}>{$vitals.LCP.rating.toUpperCase()} |
| 28 | + </span> |
| 29 | + </p> |
| 30 | + {/if} |
24 | 31 | </div>
|
25 | 32 | <div class='individual-vital'>
|
26 | 33 | <h5>First Input Delay</h5>
|
27 |
| - <p>{$vitals.FID === undefined ? "TBD" : ($vitals.FID).toFixed(3)}</p> |
| 34 | + <p>{$vitals.FID === undefined ? "TBD" : ($vitals.FID.value).toFixed(3) + 'ms'}</p> |
| 35 | + {#if $vitals.FID} |
| 36 | + <p>Rating: |
| 37 | + <span class={$vitals.FID.rating[0]}>{$vitals.FID.rating.toUpperCase()} |
| 38 | + </span> |
| 39 | + </p> |
| 40 | + {/if} |
28 | 41 | </div>
|
29 | 42 | <div class='individual-vital'>
|
30 | 43 | <h5>Cumulative Layout Shift</h5>
|
31 |
| - <p>{$vitals.CLS === undefined ? "TBD" : ($vitals.CLS).toFixed(3)}</p> |
| 44 | + <p>{$vitals.CLS === undefined ? "TBD" : ($vitals.CLS.value).toFixed(3)}</p> |
| 45 | + {#if $vitals.CLS} |
| 46 | + <p>Rating: |
| 47 | + <span class={$vitals.CLS.rating[0]}>{$vitals.CLS.rating.toUpperCase()} |
| 48 | + </span> |
| 49 | + </p> |
| 50 | + {/if} |
32 | 51 | </div>
|
33 | 52 | </div>
|
34 | 53 | <div class='vitals-right'>
|
35 | 54 | <div class='individual-vital'>
|
36 | 55 | <h5>First Contentful Paint</h5>
|
37 |
| - <p>{$vitals.FCP === undefined ? "TBD" : ($vitals.FCP).toFixed(3)}</p> |
| 56 | + <p>{$vitals.FCP === undefined ? "TBD" : ($vitals.FCP.value).toFixed(3) + 's'}</p> |
| 57 | + {#if $vitals.FCP} |
| 58 | + <p>Rating: |
| 59 | + <span class={$vitals.FCP.rating[0]}>{$vitals.FCP.rating.toUpperCase()} |
| 60 | + </span> |
| 61 | + </p> |
| 62 | + {/if} |
38 | 63 | </div>
|
39 | 64 | <div class='individual-vital'>
|
40 | 65 | <h5>Time To First Byte</h5>
|
41 |
| - <p>{$vitals.TTFB === undefined ? "TBD" : ($vitals.TTFB).toFixed(3)}</p> |
| 66 | + <p>{$vitals.TTFB === undefined ? "TBD" : ($vitals.TTFB.value).toFixed(3) + 'ms'}</p> |
| 67 | + {#if $vitals.TTFB} |
| 68 | + <p>Rating: |
| 69 | + <span class={$vitals.TTFB.rating[0]}>{$vitals.TTFB.rating.toUpperCase()} |
| 70 | + </span> |
| 71 | + </p> |
| 72 | + {/if} |
42 | 73 | </div>
|
43 | 74 | <div class='individual-vital'>
|
44 | 75 | <h5>Interaction to Next Paint</h5>
|
45 |
| - <p>{$vitals.INP === undefined ? "TBD" : ($vitals.INP).toFixed(3)}</p> |
| 76 | + <p>{$vitals.INP === undefined ? "TBD" : ($vitals.INP.value).toFixed(3) + 'ms'}</p> |
| 77 | + {#if $vitals.INP} |
| 78 | + <p>Rating: |
| 79 | + <span class={$vitals.INP.rating[0]}>{$vitals.INP.rating.toUpperCase()} |
| 80 | + </span> |
| 81 | + </p> |
| 82 | + {/if} |
46 | 83 | </div>
|
47 | 84 | </div>
|
48 | 85 | </div>
|
|
51 | 88 | </main>
|
52 | 89 |
|
53 | 90 | <style>
|
| 91 | + .invisible { |
| 92 | + display: none; |
| 93 | + } |
| 94 | +
|
| 95 | + .g, .n, .p { |
| 96 | + font-weight: bold; |
| 97 | + } |
| 98 | +
|
| 99 | + .g { |
| 100 | + color: rgb(0, 154, 0); |
| 101 | + } |
| 102 | +
|
| 103 | + .n { |
| 104 | + color: rgb(243, 197, 80); |
| 105 | + } |
| 106 | +
|
| 107 | + .p { |
| 108 | + color: rgb(240, 38, 38); |
| 109 | + } |
54 | 110 |
|
55 | 111 | .web-vitals-parent-container {
|
56 | 112 | display: flex;
|
|
0 commit comments