From 199563ce219a829016f4aa997963375ed9b86b9c Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Thu, 8 Aug 2024 12:58:23 +0200 Subject: [PATCH] add upcoming earnins and recent earnings to dashboard --- src/app.css | 35 +++++++------ src/routes/home/+page.svelte | 96 +++++++++++++++++++++++++++++++++--- 2 files changed, 110 insertions(+), 21 deletions(-) diff --git a/src/app.css b/src/app.css index 30745015..872c12c3 100644 --- a/src/app.css +++ b/src/app.css @@ -47,20 +47,27 @@ @layer utilities { - /* Chrome, Safari and Opera */ - .no-scrollbar::-webkit-scrollbar { - display: none; - } - - .no-scrollbar { - -ms-overflow-style: none; /* IE and Edge */ - scrollbar-width: none; /* Firefox */ - overflow: -moz-scrollbars-none; /* Legacy support for older Firefox versions */ - } - - .no-scrollbar::-webkit-scrollbar { - display: none; /* Chrome, Safari, and other WebKit-based browsers */ - } + .no-scrollbar { + overflow-x: hidden; + overflow-y: auto; + } + + /* Styles for WebKit browsers (Chrome, Safari, newer versions of Opera) */ + .no-scrollbar::-webkit-scrollbar { + width: auto; /* Keep the width for vertical scrollbar */ + height: 0; /* Set height to 0 to hide horizontal scrollbar */ + } + + /* Styles for Firefox */ + .no-scrollbar { + scrollbar-width: thin; + scrollbar-color: auto transparent; /* vertical scrollbar color, then track color */ + } + + /* Styles for Internet Explorer and Edge */ + .no-scrollbar { + -ms-overflow-style: -ms-autohiding-scrollbar; + } .shake-ticker:hover img { diff --git a/src/routes/home/+page.svelte b/src/routes/home/+page.svelte index 83a67ea8..accd7dca 100644 --- a/src/routes/home/+page.svelte +++ b/src/routes/home/+page.svelte @@ -24,10 +24,22 @@ export let data; - let isLoaded = false; const quickInfo = data?.getDashboard?.quickInfo; + + function compareTimes(time1, time2) { + const [hours1, minutes1] = time1.split(':').map(Number); + const [hours2, minutes2] = time2.split(':').map(Number); + + if (hours1 > hours2) return 1; + if (hours1 < hours2) return -1; + if (minutes1 > minutes2) return 1; + if (minutes1 < minutes2) return -1; + return 0; +} + + function reformatDate(dateString) { return dateString.substring(5, 7) + '/' + dateString.substring(8) + '/' + dateString.substring(2, 4); } @@ -116,7 +128,6 @@ function latestInfoDate(inputDate) { let Feedback; onMount( async() => { - isLoaded = true; Feedback = (await import('$lib/components/Feedback.svelte')).default }) @@ -255,9 +266,12 @@ onMount( async() => { -
- + + +
+ +
@@ -309,7 +323,7 @@ onMount( async() => { - +
@@ -323,7 +337,7 @@ onMount( async() => {
- {#if data?.getDashboard?.retailTracker?.length !== 0 && isLoaded} + {#if data?.getDashboard?.retailTracker?.length !== 0}
@@ -341,8 +355,76 @@ onMount( async() => {
+ +
+ + + +
+
+ Upcoming Earnings + + View All + +
+
+
+ +
    + {#each data?.getDashboard?.upcomingEarnings as item} +
  • + {item?.name} ({item?.symbol}) + will report tomorrow + {#if item?.time} + {#if compareTimes(item?.time, '16:00') > 0} + after market closes. + {:else if compareTimes(item?.time, '09:30') < 0} + before market opens. + {:else} + during market. + {/if} + {/if}Analysts estimate {abbreviateNumber(item?.revenueEst,true)} in revenue ({((item?.revenueEst/item?.revenuePrior-1)*100)?.toFixed(2)}% YoY) and ${item?.epsEst} in earnings per share ({((item?.epsEst/item?.epsPrior-1)*100)?.toFixed(2)}% YoY).
  • +
    + + {/each} +
+
+
+ + + +
+
+ Recent Earnings +
+
+
+ +
    + {#each data?.getDashboard?.recentEarnings as item} + {item?.name} ({item?.symbol}) has released its quarterly earnings: + +
  • + Revenue of {abbreviateNumber(item?.revenue,true)} ({(item?.revenue/item?.revenuePrior-1) > 0 ? '+' :''}{((item?.revenue/item?.revenuePrior-1)*100)?.toFixed(2)}% YoY) {item?.revenueSurprise > 0 ? 'beats' : 'misses'} by {abbreviateNumber(Math.abs(item?.revenueSurprise),true)}. +
  • +
  • + EPS of ${item?.eps} ({(item?.eps/item?.epsPrior-1) > 0 ? '+' :''}{((item?.eps/item?.epsPrior-1)*100)?.toFixed(2)}% YoY) {item?.epsSurprise > 0 ? 'beats' : 'misses'} by ${Math.abs(item?.epsSurprise)?.toFixed(2)}. +
  • +
    + {/each} +
+ +
+
+ + +
+ + +
- +
Market Momentum