diff --git a/src/lib/components/Searchbar.svelte b/src/lib/components/Searchbar.svelte index 54b1e6fa..c3319600 100644 --- a/src/lib/components/Searchbar.svelte +++ b/src/lib/components/Searchbar.svelte @@ -1,17 +1,11 @@ searchBarTicker(searchQuery, assetType)} + on:click={() => searchBarTicker(searchQuery)} class="absolute inset-0 right-auto group" type="submit" aria-label="Search" @@ -548,8 +510,9 @@ {#if !showSuggestions} {#each searchHistory?.length > 0 ? searchHistory : popularList as item} - popularTicker(item?.symbol, item?.type)} + popularTicker(item?.symbol)} class="mb-2 {item?.symbol === focusedSuggestion ? 'shake-ticker cursor-pointer flex justify-start items-center p-2 text-white bg-[#27272A] rounded group' : 'shake-ticker cursor-pointer bg-[#09090B] sm:hover:bg-[#27272A] rounded-lg flex justify-start items-center p-2 text-white group'} w-full" @@ -578,7 +541,7 @@ {item?.type} - + {/each} {:else if showSuggestions && searchResults?.length > 0} @@ -589,9 +552,9 @@ - searchBarTicker(item?.symbol, item?.type)} + searchBarTicker(item?.symbol)} class="mb-2 {item?.symbol === focusedSuggestion ? 'shake-ticker cursor-pointer flex justify-start items-center p-2 text-white bg-[#27272A] rounded group' : 'cursor-pointer mb-2 bg-[#09090B] sm:hover:bg-[#27272A] rounded-lg flex justify-start items-center p-2 text-white group'}" @@ -610,7 +573,7 @@ {item?.type} - + {/each} {:else if showSuggestions && searchResults?.length === 0} @@ -697,7 +660,7 @@ autocomplete="off" /> searchBarTicker(searchQuery, assetType)} + on:click={() => searchBarTicker(searchQuery)} class="absolute inset-0 right-auto group" type="submit" aria-label="Search" @@ -736,8 +699,9 @@ {#if !showSuggestions} {#each searchHistory?.length > 0 ? searchHistory : popularList as item} - popularTicker(item?.symbol, item?.type)} + popularTicker(item?.symbol)} class="mb-2 {item?.symbol === focusedSuggestion ? 'shake-ticker cursor-pointer flex justify-start items-center p-2 text-white bg-[#27272A] rounded group' : 'cursor-pointer bg-[#09090B] bg-opacity-[0.4] rounded-lg flex justify-start items-center p-2 text-white group'} w-full" @@ -766,7 +730,7 @@ {item?.type} - + {/each} {:else if showSuggestions && searchResults?.length > 0} @@ -777,10 +741,9 @@ - - searchBarTicker(item?.symbol, item?.type)} + searchBarTicker(item?.symbol)} class="mb-2 {item?.symbol === focusedSuggestion ? 'shake-ticker cursor-pointer flex justify-start items-center p-2 text-white bg-[#27272A] rounded group' : 'cursor-pointer mb-2 bg-[#09090B] bg-opacity-[0.4] rounded-lg flex justify-start items-center p-2 text-white group'}" @@ -799,7 +762,7 @@ {item?.type} - + {/each} {:else if showSuggestions && searchResults?.length === 0} diff --git a/src/routes/crypto/[tickerID]/+layout.server.ts b/src/routes/crypto/[tickerID]/+layout.server.ts index 3b1dc70a..0b3f0b57 100644 --- a/src/routes/crypto/[tickerID]/+layout.server.ts +++ b/src/routes/crypto/[tickerID]/+layout.server.ts @@ -83,5 +83,6 @@ export const load = async ({ params, locals, setHeaders }) => { getOneDayPrice, getUserWatchlist, companyName, + getParams: params.tickerID, }; }; diff --git a/src/routes/crypto/[tickerID]/+layout.svelte b/src/routes/crypto/[tickerID]/+layout.svelte index d2e54f34..25128184 100644 --- a/src/routes/crypto/[tickerID]/+layout.svelte +++ b/src/routes/crypto/[tickerID]/+layout.svelte @@ -1,587 +1,752 @@ - - + - - - - - - - - - - - - goto('/')} class="ml-2 cursor-pointer"> - + + + + + + + + + + goto("/")} + class="ml-2 cursor-pointer" + > + - - - + + + {$cryptoTicker} - - - {#if $currentPortfolioPrice !== null && $currentPortfolioPrice !== 0} - ${$currentPortfolioPrice} - {:else} - --- - {/if} - - - - - - - - - - - - shareContent('https://stocknear.com/crypto/'+$cryptoTicker)} > - - - - - - - - - {#if data?.user} - - {#if userWatchList?.length !== 0} - - {#if isTickerIncluded} - - {:else} - - {/if} - - - {:else if userWatchList?.length === 0} - toggleUserWatchlist('firstList')} class="cursor-pointer flex-shrink-0"> - {#if isTickerIncluded} - - {:else} - - {/if} - - - {/if} - + + + {#if $currentPortfolioPrice !== null && $currentPortfolioPrice !== 0} + ${$currentPortfolioPrice} {:else} - - + --- + {/if} + + + + + + + + + + + + shareContent( + "https://stocknear.com/crypto/" + $cryptoTicker, + )} + > + + + + + + + {#if data?.user} + + {#if userWatchList?.length !== 0} + + {#if isTickerIncluded} + + {:else} + + {/if} + + {:else if userWatchList?.length === 0} + toggleUserWatchlist("firstList")} + class="cursor-pointer flex-shrink-0" + > + {#if isTickerIncluded} + + {:else} + + {/if} {/if} - - - - $openPriceAlert = true} for={data?.user ? 'priceAlertModal' : 'userLogin'} class="mr-2"> - + + {:else} + + - - - + {/if} + + + + ($openPriceAlert = true)} + for={data?.user ? "priceAlertModal" : "userLogin"} + class="mr-2" + > + + + + - - - - - - - + + + + - - - - - - - - - + + - - - {#if data?.user} - - {#if userWatchList?.length !== 0} - - - {#if isTickerIncluded} - - {:else} - - {/if} - - - - {:else if userWatchList?.length === 0} - - toggleUserWatchlist('firstList')} class="cursor-pointer flex-shrink-0"> - {#if isTickerIncluded} - - {:else} - - {/if} - - - - {/if} - - {:else} - - - - - - {/if} - + + + - - - - $openPriceAlert = true} for={data?.user ? 'priceAlertModal' : 'userLogin'} class="cursor-pointer flex-shrink-0 text-white"> - - - - - - - - - - - - - - - - - - - - {$cryptoTicker?.toUpperCase()} - - - {$displayCompanyName?.length > charNumber ? $displayCompanyName?.slice(0,charNumber) + "..." : $displayCompanyName} - - - + {#if data?.user} + + {#if userWatchList?.length !== 0} + + + {#if isTickerIncluded} + + {:else} + + {/if} + + + {:else if userWatchList?.length === 0} + + + toggleUserWatchlist("firstList")} + class="cursor-pointer flex-shrink-0" + > + {#if isTickerIncluded} + + {:else} + + {/if} + + + {/if} + + {:else} + + + + + + {/if} + + - - - - + + + + + + + + + + + + + + + {$cryptoTicker?.toUpperCase()} + + + {$displayCompanyName?.length > charNumber + ? $displayCompanyName?.slice(0, charNumber) + + "..." + : $displayCompanyName} + + + + + + - - - - - - - - - - - - - - - - - - - (changeSection('overview','item1'))} class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === 'overview' ? 'text-white ' : 'bg-[#09090B]'}" > - Overview - - - - - (changeSection('stats','item2'))} class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === 'stats' ? 'text-white ' : 'bg-[#09090B]'}" >Stats - - - - (changeSection('forecast','item3'))} class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === 'forecast' ? 'text-white ' : 'bg-[#09090B]'}" > - Forecast - - - - - (changeSection('congress-trading','item7'))} class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === 'congress-trading' ? 'text-white ' : 'bg-[#09090B]'}" > - Insider - - - - - (changeSection('news','item7'))} class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === 'news' ? 'text-white ' : 'bg-[#09090B]'}" > - News - - - - - - - + + + + - - - - + - - - + + + + + changeSection("overview", "item1")} + class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === + 'overview' + ? 'text-white ' + : 'bg-[#09090B]'}" + > + Overview + + + + + changeSection("stats", "item2")} + class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === + 'stats' + ? 'text-white ' + : 'bg-[#09090B]'}">Stats + + + + changeSection("forecast", "item3")} + class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === + 'forecast' + ? 'text-white ' + : 'bg-[#09090B]'}" + > + Forecast + + + + + + changeSection("congress-trading", "item7")} + class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === + 'congress-trading' + ? 'text-white ' + : 'bg-[#09090B]'}" + > + Insider + + + + + changeSection("news", "item7")} + class="px-3 text-sm sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySection === + 'news' + ? 'text-white ' + : 'bg-[#09090B]'}" + > + News + + + + + - - + + + + + + + - - - - - - - - + + + - - - - + + + + {#if LoginPopup} - -{/if} + +{/if} {#if PriceAlert} - + {/if} - - - - - - + + - - - - - - - + - - - - - {$displayCompanyName?.length > 30 ? $displayCompanyName?.slice(0, 30) + "..." : $displayCompanyName} + + + + + {$displayCompanyName?.length > 30 + ? $displayCompanyName?.slice(0, 30) + "..." + : $displayCompanyName} + + + + Current Price: ${$currentPortfolioPrice} - - - - Current Price: ${$currentPortfolioPrice} - - - Holding Shares: {holdingShares} - - - + + Holding Shares: {holdingShares} + + - + + + Type of Trade - - - Type of Trade - - - - - - handleTypeOfTrade('buy')} class="cursor-pointer flex flex-row justify-start items-center"> - - - - Buy {$cryptoTicker} Shares - - - - - handleTypeOfTrade('sell')} class="cursor-pointer flex flex-row justify-start items-center"> - - - - - Sell {$cryptoTicker} Shares - - - - - + + + handleTypeOfTrade("buy")} + class="cursor-pointer flex flex-row justify-start items-center" + > + + + + + + + Buy {$cryptoTicker} Shares + + + + handleTypeOfTrade("sell")} + class="cursor-pointer flex flex-row justify-start items-center" + > + + + + + Sell {$cryptoTicker} Shares + + + + + - - - - - - - - - - + - - + + - ✕ + + ✕ + Add to Watchlist {#each userWatchList as item} - toggleUserWatchlist(item?.id)} class="cursor-pointer w-full flex flex-row justify-start items-center mb-5"> - + toggleUserWatchlist(item?.id)} + class="cursor-pointer w-full flex flex-row justify-start items-center mb-5" + > + {item?.title} - + {item?.ticker?.length} {item?.ticker?.length !== 1 ? "Companies" : "Company"} - + {#if item?.ticker?.includes($cryptoTicker)} - - ic_fluent_checkmark_circle_48_filled Created with Sketch. - - + + + ic_fluent_checkmark_circle_48_filled + Created with Sketch. + + - + - - - - - - - - - - - - - \ No newline at end of file + ::-webkit-scrollbar-corner { + background: #09090b; + } + diff --git a/src/routes/crypto/[tickerID]/+layout.ts b/src/routes/crypto/[tickerID]/+layout.ts deleted file mode 100644 index a203b122..00000000 --- a/src/routes/crypto/[tickerID]/+layout.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { displayCompanyName, cryptoTicker, assetType } from "$lib/store"; - -export const load = async ({ params, data }) => { - cryptoTicker.update((value) => params.tickerID?.toUpperCase()); - assetType.update((value) => "crypto"); - - displayCompanyName.update((value) => data?.companyName); -}; diff --git a/src/routes/stocks/[tickerID]/+layout.server.ts b/src/routes/stocks/[tickerID]/+layout.server.ts index 04a442ac..f717ad5f 100644 --- a/src/routes/stocks/[tickerID]/+layout.server.ts +++ b/src/routes/stocks/[tickerID]/+layout.server.ts @@ -94,5 +94,6 @@ export const load = async ({ params, locals }) => { getNews, getUserWatchlist, companyName: cleanString(getStockDeck?.companyName), + getParams: params.tickerID, }; }; diff --git a/src/routes/stocks/[tickerID]/+layout.svelte b/src/routes/stocks/[tickerID]/+layout.svelte index d902bf35..c0589f51 100644 --- a/src/routes/stocks/[tickerID]/+layout.svelte +++ b/src/routes/stocks/[tickerID]/+layout.svelte @@ -12,8 +12,9 @@ isCrosshairMoveActive, currentPrice, priceIncrease, - displayCompanyName, stockTicker, + assetType, + displayCompanyName, isOpen, shouldUpdatePriceChart, priceChartData, @@ -315,6 +316,9 @@ function handleTypeOfTrade(state:string) $: { if ($page?.url?.pathname && typeof window !== "undefined") { + stockTicker.update((value) => (value = data?.getParams?.toUpperCase())); + assetType.update((value) => (value = "stock")); + displayCompanyName.update((value) => (value = data?.companyName)); const parts = $page?.url?.pathname?.split("/"); const sectionMap = { statistics: "statistics", diff --git a/src/routes/stocks/[tickerID]/+layout.ts b/src/routes/stocks/[tickerID]/+layout.ts index 933902b0..a1e6e7b9 100644 --- a/src/routes/stocks/[tickerID]/+layout.ts +++ b/src/routes/stocks/[tickerID]/+layout.ts @@ -1,7 +1,4 @@ import { - displayCompanyName, - stockTicker, - assetType, isOpen, isAfterMarketClose, isBeforeMarketOpen, @@ -53,8 +50,5 @@ const checkMarketHour = async () => { }; export const load = async ({ params, data }) => { - stockTicker.update((value) => (value = params.tickerID?.toUpperCase())); - assetType.update((value) => (value = "stock")); - displayCompanyName.update((value) => (value = data?.companyName)); await checkMarketHour(); };