ui fixes
This commit is contained in:
parent
2ae8736828
commit
c7f8d14461
@ -461,7 +461,7 @@ $: {
|
|||||||
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
|
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
|
||||||
<div class="w-full flex justify-between items-center p-3 mt-3">
|
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||||
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||||
Pro Subscription
|
Pro Subscription 🔥
|
||||||
</h2>
|
</h2>
|
||||||
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
|
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,11 +3,38 @@ import logo from '$lib/images/news_logo.png'
|
|||||||
import ScrollToTop from '$lib/components/ScrollToTop.svelte';
|
import ScrollToTop from '$lib/components/ScrollToTop.svelte';
|
||||||
import ArrowLogo from "lucide-svelte/icons/move-up-right";
|
import ArrowLogo from "lucide-svelte/icons/move-up-right";
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
let displaySection = 'stock'
|
|
||||||
|
|
||||||
|
|
||||||
|
function handleMode(i) {
|
||||||
|
activeIdx = i;
|
||||||
|
if(activeIdx === 0) {
|
||||||
|
goto("/market-news")
|
||||||
|
} else if (activeIdx === 1) {
|
||||||
|
goto("/market-news/general")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const tabs = [
|
||||||
|
{
|
||||||
|
title: "Stock",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "General",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
let activeIdx = 0;
|
||||||
|
|
||||||
|
// Subscribe to the $page store to reactively update the activeIdx based on the URL
|
||||||
|
$: if ($page.url.pathname === '/market-news') {
|
||||||
|
activeIdx = 0;
|
||||||
|
} else if ($page.url.pathname.startsWith('/market-news/general')) {
|
||||||
|
activeIdx = 1;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- HEADER FOR BETTER SEO -->
|
<!-- HEADER FOR BETTER SEO -->
|
||||||
@ -86,21 +113,24 @@ let displaySection = 'stock'
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="w-full mb-2" >
|
<div class="bg-[#313131] w-fit relative mr-auto flex flex-wrap items-center justify-center rounded sm:rounded-lg p-1 -mt-3">
|
||||||
<ul class="pr-4 sm:pr-0 w-full font-medium flex flex-row items-center bg-[#09090B] overflow-x-scroll no-scrollbar space-x-3 rtl:space-x-reverse py-2">
|
{#each tabs as item, i}
|
||||||
<li class="cursor-pointer flex flex-col items-center text-xl">
|
<button
|
||||||
<a href='/market-news' on:click={() => displaySection = 'stock'} class="px-3 font-medium text-gray-400 sm:hover:text-white {displaySection === 'stock' ? 'text-white ' : 'bg-[#09090B]'}" >
|
on:click={() => handleMode(i)}
|
||||||
Stock
|
class="group relative z-[1] rounded-full px-6 py-1 {activeIdx === i
|
||||||
</a>
|
? 'z-0'
|
||||||
<div class="{displaySection === 'stock' ? 'bg-[#75D377]' : 'bg-[#09090B]'} mt-1 h-[3px] rounded-full w-[4.2rem]" />
|
: ''} "
|
||||||
</li>
|
>
|
||||||
<li class="cursor-pointer flex flex-col items-center text-xl">
|
{#if activeIdx === i}
|
||||||
<a href='/market-news/general' on:click={() => displaySection = 'general'} class="px-3 font-medium text-gray-400 sm:hover:text-white {displaySection === 'general' ? 'text-white ' : 'bg-[#09090B]'}" >
|
<div
|
||||||
General
|
class="absolute inset-0 rounded-lg bg-purple-600"
|
||||||
</a>
|
></div>
|
||||||
<div class="{displaySection === 'general' ? 'bg-[#75D377]' : 'bg-[#09090B]'} mt-1 h-[3px] rounded-full w-[4.2rem]" />
|
{/if}
|
||||||
</li>
|
<span class="relative text-[1rem] sm:text-lg block font-semibold duration-200 text-white">
|
||||||
</ul>
|
{item.title}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -121,7 +151,7 @@ let displaySection = 'stock'
|
|||||||
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
|
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
|
||||||
<div class="w-full flex justify-between items-center p-3 mt-3">
|
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||||
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||||
Pro Subscription
|
Pro Subscription 🔥
|
||||||
</h2>
|
</h2>
|
||||||
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
|
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
|
||||||
</div>
|
</div>
|
||||||
@ -132,30 +162,44 @@ let displaySection = 'stock'
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div on:click={() => goto('/analysts')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
|
<div on:click={() => goto('/earnings-calendar')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
|
||||||
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
|
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
|
||||||
<div class="w-full flex justify-between items-center p-3 mt-3">
|
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||||
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||||
Wallstreet Analyst
|
Earnings Calendar 🌟
|
||||||
</h2>
|
</h2>
|
||||||
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
|
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-white p-3 ml-3 mr-3">
|
<span class="text-white p-3 ml-3 mr-3">
|
||||||
Get the latest top Wall Street analyst ratings.
|
Get the latest Earnings of companies
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div on:click={() => goto('/politicians')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
|
<div on:click={() => goto('/dividends-calendar')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
|
||||||
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
|
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
|
||||||
<div class="w-full flex justify-between items-center p-3 mt-3">
|
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||||
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||||
Congress Trading
|
Dividend Calendar 💸
|
||||||
</h2>
|
</h2>
|
||||||
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
|
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-white p-3 ml-3 mr-3">
|
<span class="text-white p-3 ml-3 mr-3">
|
||||||
Get the latest top Congress trading insights.
|
Stay updated on upcoming Dividends in the stock market.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div on:click={() => goto('/economic-calendar')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer">
|
||||||
|
<div class="w-auto lg:w-full p-1 flex flex-col m-auto px-2 sm:px-0">
|
||||||
|
<div class="w-full flex justify-between items-center p-3 mt-3">
|
||||||
|
<h2 class="text-start text-xl font-semibold text-white ml-3">
|
||||||
|
Economic Events 🌍
|
||||||
|
</h2>
|
||||||
|
<ArrowLogo class="w-8 h-8 mr-3 flex-shrink-0"/>
|
||||||
|
</div>
|
||||||
|
<span class="text-white p-3 ml-3 mr-3">
|
||||||
|
Stay updated on upcoming Economic Events worldwide.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { formatDistanceToNow } from 'date-fns';
|
|
||||||
import { formatInTimeZone } from 'date-fns-tz'
|
|
||||||
|
|
||||||
import InfiniteLoading from '$lib/components/InfiniteLoading.svelte';
|
|
||||||
import { numberOfUnreadNotification } from '$lib/store';
|
import { numberOfUnreadNotification } from '$lib/store';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
@ -37,17 +36,22 @@ const inputDate = new Date(dateString);
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
async function infiniteHandler({ detail: { loaded, complete } })
|
async function handleScroll() {
|
||||||
{
|
const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height
|
||||||
if (news?.length === rawData?.length) {
|
const isBottom = window.innerHeight + window.scrollY >= scrollThreshold;
|
||||||
complete();
|
if (isBottom && news?.length !== rawData?.length) {
|
||||||
} else {
|
|
||||||
const nextIndex = news?.length;
|
const nextIndex = news?.length;
|
||||||
const newArticles = rawData?.slice(nextIndex, nextIndex + 5);
|
const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 25);
|
||||||
news = [...news, ...newArticles];
|
news = [...news, ...filteredNewResults];
|
||||||
loaded();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
window.addEventListener('scroll', handleScroll);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('scroll', handleScroll);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
let videoId = null;
|
let videoId = null;
|
||||||
|
|
||||||
@ -117,7 +121,7 @@ function checkIfYoutubeVideo(link) {
|
|||||||
{:else}
|
{:else}
|
||||||
<a href={item.url} target="_blank">
|
<a href={item.url} target="_blank">
|
||||||
<div class="h-48 sm:h-60 m-auto border border-slate-800 rounded-none sm:rounded-lg ">
|
<div class="h-48 sm:h-60 m-auto border border-slate-800 rounded-none sm:rounded-lg ">
|
||||||
<img src={item?.image} class="w-screen sm:w-full h-48 sm:h-60 rounded-none sm:rounded-t-lg" alt="news image" loading="lazy">
|
<img src={item?.image} class="w-screen sm:w-full object-cover h-48 sm:h-60 rounded-none sm:rounded-t-lg" alt="news image" loading="lazy">
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
@ -137,7 +141,7 @@ function checkIfYoutubeVideo(link) {
|
|||||||
{item?.title?.length > 120 ? item?.title?.slice(0,120) +'...' : item?.title}
|
{item?.title?.length > 120 ? item?.title?.slice(0,120) +'...' : item?.title}
|
||||||
</a>
|
</a>
|
||||||
<p class="text-white text-sm mt-2">
|
<p class="text-white text-sm mt-2">
|
||||||
{item?.text.length > 100 ? item?.text.slice(0,100) + "..." : item?.text}
|
{item?.text?.length > 100 ? item?.text?.slice(0,100) + "..." : item?.text}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -145,8 +149,6 @@ function checkIfYoutubeVideo(link) {
|
|||||||
|
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
<InfiniteLoading on:infinite={infiniteHandler} />
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@ -1,38 +1,68 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import InfiniteLoading from '$lib/components/InfiniteLoading.svelte';
|
|
||||||
import { numberOfUnreadNotification } from '$lib/store';
|
|
||||||
import { formatDate } from '$lib/utils';
|
|
||||||
|
|
||||||
export let data;
|
|
||||||
|
|
||||||
|
|
||||||
let rawData = data?.getGeneralNews;
|
import { numberOfUnreadNotification } from '$lib/store';
|
||||||
let news = rawData.slice(0,15) ?? [];
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
export let data;
|
||||||
|
|
||||||
|
|
||||||
async function infiniteHandler({ detail: { loaded, complete } })
|
let rawData = data?.getGeneralNews;
|
||||||
{
|
let news = rawData.slice(0,15) ?? [];
|
||||||
if (news?.length === rawData?.length) {
|
|
||||||
complete();
|
const formatDate = (dateString) => {
|
||||||
|
// Create a date object for the input dateString
|
||||||
|
const inputDate = new Date(dateString);
|
||||||
|
|
||||||
|
// Create a date object for the current time in New York City
|
||||||
|
const nycTime = new Date().toLocaleString("en-US", { timeZone: "America/New_York" });
|
||||||
|
const currentNYCDate = new Date(nycTime);
|
||||||
|
|
||||||
|
// Calculate the difference in milliseconds
|
||||||
|
const difference = inputDate.getTime() - currentNYCDate.getTime();
|
||||||
|
|
||||||
|
// Convert the difference to minutes
|
||||||
|
const minutes = Math.abs(Math.round(difference / (1000 * 60)));
|
||||||
|
|
||||||
|
if (minutes < 60) {
|
||||||
|
return `${minutes} minutes`;
|
||||||
|
} else if (minutes < 1440) {
|
||||||
|
const hours = Math.round(minutes / 60);
|
||||||
|
return `${hours} hour${hours !== 1 ? 's' : ''}`;
|
||||||
} else {
|
} else {
|
||||||
|
const days = Math.round(minutes / 1440);
|
||||||
|
return `${days} day${days !== 1 ? 's' : ''}`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
async function handleScroll() {
|
||||||
|
const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height
|
||||||
|
const isBottom = window.innerHeight + window.scrollY >= scrollThreshold;
|
||||||
|
if (isBottom && news?.length !== rawData?.length) {
|
||||||
const nextIndex = news?.length;
|
const nextIndex = news?.length;
|
||||||
const newArticles = rawData?.slice(nextIndex, nextIndex + 5);
|
const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 25);
|
||||||
news = [...news, ...newArticles];
|
news = [...news, ...filteredNewResults];
|
||||||
loaded();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
window.addEventListener('scroll', handleScroll);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('scroll', handleScroll);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
let videoId = null;
|
let videoId = null;
|
||||||
|
|
||||||
|
|
||||||
function checkIfYoutubeVideo(link) {
|
function checkIfYoutubeVideo(link) {
|
||||||
|
|
||||||
const url = new URL(link);
|
const url = new URL(link);
|
||||||
if (url.hostname === "www.youtube.com") {
|
if (url.hostname === "www.youtube.com") {
|
||||||
const searchParams = url.searchParams;
|
const searchParams = url.searchParams;
|
||||||
searchParams.delete('t'); // Remove the "t" parameter
|
searchParams?.delete('t'); // Remove the "t" parameter
|
||||||
const videoIdMatch = url.search.match(/v=([^&]+)/);
|
const videoIdMatch = url?.search?.match(/v=([^&]+)/);
|
||||||
|
|
||||||
if (videoIdMatch) {
|
if (videoIdMatch) {
|
||||||
return videoIdMatch[1];
|
return videoIdMatch[1];
|
||||||
@ -41,10 +71,11 @@
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|
||||||
@ -92,7 +123,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<a href={item?.url} target="_blank">
|
<a href={item?.url} target="_blank">
|
||||||
<div class="h-48 sm:h-60 m-auto border border-slate-800 rounded-none sm:rounded-lg ">
|
<div class="h-48 sm:h-60 m-auto border border-slate-800 rounded-none sm:rounded-lg ">
|
||||||
<img src={item?.image} class="w-screen sm:w-full h-48 sm:h-60 rounded-none sm:rounded-t-lg" alt="news image" loading="lazy">
|
<img src={item?.image} class="w-screen sm:w-full object-cover h-48 sm:h-60 rounded-none sm:rounded-t-lg" alt="news image" loading="lazy">
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
@ -114,7 +145,6 @@
|
|||||||
|
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
<InfiniteLoading on:infinite={infiniteHandler} />
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user