ui fixes
This commit is contained in:
parent
a886bbbbb9
commit
2a34847fa1
@ -23,11 +23,11 @@
|
|||||||
let dividendYield;
|
let dividendYield;
|
||||||
|
|
||||||
async function stockSelector(ticker: string) {
|
async function stockSelector(ticker: string) {
|
||||||
if (ticker?.length !== 0 && !["BTC", "USD"]?.includes(ticker)) {
|
if (ticker?.length !== 0 && !["BTCUSD", "USD"]?.includes(ticker)) {
|
||||||
window?.scroll({ top: 0, left: 0, behavior: "smooth" });
|
window?.scroll({ top: 0, left: 0, behavior: "smooth" });
|
||||||
stockTicker.update((value) => ticker);
|
stockTicker.update((value) => ticker);
|
||||||
goto("/stocks/" + ticker + "/");
|
goto("/stocks/" + ticker + "/");
|
||||||
} else if (ticker === "BTC") {
|
} else if (ticker === "BTCUSD") {
|
||||||
window?.scroll({ top: 0, left: 0, behavior: "smooth" });
|
window?.scroll({ top: 0, left: 0, behavior: "smooth" });
|
||||||
cryptoTicker.update((value) => "BTCUSD");
|
cryptoTicker.update((value) => "BTCUSD");
|
||||||
goto("/crypto/BTCUSD");
|
goto("/crypto/BTCUSD");
|
||||||
@ -189,7 +189,10 @@
|
|||||||
{#if typeof item?.name !== "undefined"}
|
{#if typeof item?.name !== "undefined"}
|
||||||
{item?.name?.length > 20
|
{item?.name?.length > 20
|
||||||
? formatString(item?.name?.slice(0, 20)) + "..."
|
? formatString(item?.name?.slice(0, 20)) + "..."
|
||||||
: formatString(item?.name)}
|
: formatString(item?.name)?.replace(
|
||||||
|
"Usd",
|
||||||
|
"USD",
|
||||||
|
)}
|
||||||
{:else}
|
{:else}
|
||||||
n/a
|
n/a
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@ -1,46 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { stockTicker, etfTicker } from "$lib/store";
|
import { stockTicker, etfTicker } from "$lib/store";
|
||||||
|
import { formatDate } from "$lib/utils";
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
let rawData = [];
|
let rawData = [];
|
||||||
let newsList = [];
|
let newsList = [];
|
||||||
|
|
||||||
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} minute${minutes !== 1 ? "s" : ""}`;
|
|
||||||
} else if (minutes < 1440) {
|
|
||||||
const hours = Math.round(minutes / 60);
|
|
||||||
return `${hours} hour${hours !== 1 ? "s" : ""}`;
|
|
||||||
} else if (minutes < 10080) {
|
|
||||||
const days = Math.round(minutes / 1440);
|
|
||||||
if (days > 6) {
|
|
||||||
return "1 week";
|
|
||||||
}
|
|
||||||
return `${days} day${days !== 1 ? "s" : ""}`;
|
|
||||||
} else if (minutes < 20160) {
|
|
||||||
return "2 weeks";
|
|
||||||
} else {
|
|
||||||
const weeks = Math.round(minutes / 10080);
|
|
||||||
return `${weeks} week${weeks !== 1 ? "s" : ""}`;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
let videoId = null;
|
let videoId = null;
|
||||||
|
|
||||||
@ -138,7 +104,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<div class="-mt-3 w-full">
|
<div class="-mt-3 w-full">
|
||||||
<h3 class="text-sm text-white/80 truncate mb-2 mt-3">
|
<h3 class="text-sm text-white/80 truncate mb-2 mt-3">
|
||||||
{formatDate(item?.publishedDate)} ago · {item?.site}
|
{formatDate(item?.publishedDate)} · {item?.site}
|
||||||
</h3>
|
</h3>
|
||||||
<a
|
<a
|
||||||
href={item?.url}
|
href={item?.url}
|
||||||
|
|||||||
@ -14,11 +14,11 @@
|
|||||||
let totalAssetPercentage = 0;
|
let totalAssetPercentage = 0;
|
||||||
|
|
||||||
async function stockSelector(ticker: string) {
|
async function stockSelector(ticker: string) {
|
||||||
if (ticker?.length !== 0 && !["BTC", "USD"]?.includes(ticker)) {
|
if (ticker?.length !== 0 && !["BTCUSD", "BTC" "USD"]?.includes(ticker)) {
|
||||||
window?.scroll({ top: 0, left: 0, behavior: "smooth" });
|
window?.scroll({ top: 0, left: 0, behavior: "smooth" });
|
||||||
stockTicker.update((value) => ticker);
|
stockTicker.update((value) => ticker);
|
||||||
goto("/stocks/" + ticker + "/");
|
goto("/stocks/" + ticker + "/");
|
||||||
} else if (ticker === "BTC") {
|
} else if (ticker === "BTCUSD") {
|
||||||
window?.scroll({ top: 0, left: 0, behavior: "smooth" });
|
window?.scroll({ top: 0, left: 0, behavior: "smooth" });
|
||||||
cryptoTicker.update((value) => "BTCUSD");
|
cryptoTicker.update((value) => "BTCUSD");
|
||||||
goto("/crypto/BTCUSD");
|
goto("/crypto/BTCUSD");
|
||||||
|
|||||||
@ -572,13 +572,20 @@ export function abbreviateNumber(number, addDollarSign = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const formatDate = (dateString) => {
|
export const formatDate = (dateString) => {
|
||||||
const date = new Date(dateString);
|
const date = new Date(dateString);
|
||||||
|
const now = new Date();
|
||||||
|
const diffInDays = Math.floor((now - date) / (1000 * 60 * 60 * 24));
|
||||||
|
|
||||||
|
if (diffInDays >= 7) {
|
||||||
|
const weeks = Math.floor(diffInDays / 7);
|
||||||
|
return `${weeks} week${weeks > 1 ? "s" : ""} ago`;
|
||||||
|
}
|
||||||
|
|
||||||
return formatDistanceToNow(date, {
|
return formatDistanceToNow(date, {
|
||||||
addSuffix: false,
|
addSuffix: true,
|
||||||
includeSeconds: false,
|
includeSeconds: false,
|
||||||
})?.replace(/about /i, "");
|
}).replace(/about /i, "");
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formatRuleValue = (rule) => {
|
export const formatRuleValue = (rule) => {
|
||||||
|
|||||||
@ -1,37 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { etfTicker } from "$lib/store";
|
import { etfTicker } from "$lib/store";
|
||||||
import ArrowLogo from "lucide-svelte/icons/move-up-right";
|
import ArrowLogo from "lucide-svelte/icons/move-up-right";
|
||||||
|
import { formatDate } from "$lib/utils";
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
let newsList = data?.getNews ?? [];
|
let newsList = data?.getNews ?? [];
|
||||||
|
|
||||||
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 {
|
|
||||||
const days = Math.round(minutes / 1440);
|
|
||||||
return `${days} day${days !== 1 ? "s" : ""}`;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section class="w-auto overflow-hidden">
|
<section class="w-auto overflow-hidden">
|
||||||
@ -77,7 +51,7 @@
|
|||||||
<ul class="text-white">
|
<ul class="text-white">
|
||||||
{#each newsList?.slice(0, 10) as item}
|
{#each newsList?.slice(0, 10) as item}
|
||||||
<li class="mb-3 last:mb-1">
|
<li class="mb-3 last:mb-1">
|
||||||
{formatDate(item?.publishedDate)} ago -
|
{formatDate(item?.publishedDate)} ·
|
||||||
<a
|
<a
|
||||||
class="sm:hover:text-white text-blue-400"
|
class="sm:hover:text-white text-blue-400"
|
||||||
href={item?.url}
|
href={item?.url}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user