This commit is contained in:
MuslemRahimi 2025-04-03 21:25:58 +02:00
parent 47ee632513
commit 3169248abf
2 changed files with 94 additions and 135 deletions

View File

@ -1,103 +1,89 @@
<script lang="ts"> <script lang="ts">
import { indexTicker } from "$lib/store"; import { indexTicker } from "$lib/store";
import { import { abbreviateNumber, sectorNavigation } from "$lib/utils";
abbreviateNumber,
sectorNavigation,
} from "$lib/utils";
export let data;
export let data; let info;
let topSectorList = [];
let description = "";
let info; $: {
let topSectorList = []; if ($indexTicker) {
let description = ""; info = data?.getIndexProfile?.at(0);
topSectorList = data?.getIndexSectorWeighting || [];
description =
info?.description ??
$: { "A detailed description of the company is not yet available.";
if ($indexTicker) {
info = data?.getIndexProfile?.at(0);
topSectorList = data?.getIndexSectorWeighting || [];
description =
info?.description ??
"A detailed description of the company is not yet available.";
}
} }
</script> }
</script>
<div class="px-0.5 lg:px-0"> <div class="px-0.5 lg:px-0">
<h2 class="mb-2 text-2xl text-white font-semibold"> <h2 class="mb-2 text-2xl text-white font-semibold">
About {$indexTicker} About {$indexTicker}
</h2> </h2>
<p class="text-gray-200"> <p class="text-gray-200">
{description} {description}
</p> </p>
</div>
{#if topSectorList?.length !== 0}
<div
class="space-y-3 pt-5 text-muted dark:text-white {topSectorList?.length !==
0
? ''
: 'hidden'}"
>
<div class="h-auto w-full">
<!--Start Content-->
<div class="w-auto lg:w-full flex flex-col m-auto">
<h2 class="mb-2 text-2xl flex flex-row items-center">
<span class="font-bold">Top Sectors</span>
</h2>
</div> <div class="mt-2 w-full overflow-hidden">
<table class="w-full">
<thead>
<tr class="border-y border-gray-300 dark:border-gray-800">
<th class="px-1 py-1.5 text-left xs:px-2">Sector</th>
{#if topSectorList?.length !== 0} <th class="px-1 py-1.5 text-right xs:px-2">Weight %</th>
<div class="space-y-3 pt-5 {topSectorList?.length !== 0 ? '' : 'hidden'}"> </tr>
<div class="h-auto w-full"> </thead>
<!--Start Content--> <tbody>
<div class="w-auto lg:w-full flex flex-col m-auto"> {#each topSectorList as item}
<h2 {#if item?.weightPercentage > 0}
class="mb-2 text-2xl text-white font-semibold flex flex-row items-center" <tr class=" border-b border-gray-300 dark:border-gray-800">
> <td class="px-1 py-1.5 text-left xs:px-2">
<span>Top Sectors</span> <a
</h2> href={sectorNavigation?.find(
(listItem) => listItem?.title === item?.sector,
)?.link}
class="sm:hover:underline sm:hover:underline-offset-4 truncate"
>
{item?.sector}
</a>
</td>
<div class="mt-2 w-full overflow-hidden"> <td class="px-1 py-1.5 text-right xs:px-2">
<table class="w-full table table-sm table table-compact w-full"> {abbreviateNumber(item?.weightPercentage?.toFixed(2))}%
<thead> </td>
<tr> </tr>
<th {/if}
class="text-white font-semibold text-sm text-start bg-default" {/each}
>Sector</th </tbody>
> </table>
<th class="text-white font-semibold text-sm text-end bg-default"
>Weight %</th
>
</tr>
</thead>
<tbody>
{#each topSectorList as item}
{#if item?.weightPercentage > 0}
<tr class="text-white border-b border-[#27272A]">
<td class="text-start text-sm sm:text-[1rem]">
<a
href={sectorNavigation?.find(
(listItem) => listItem?.title === item?.sector,
)?.link}
class="sm:hover:underline sm:hover:underline-offset-4 text-white truncate"
>
{item?.sector}
</a>
</td>
<td class="text-white font-semibold text-end">
{abbreviateNumber(item?.weightPercentage?.toFixed(2))}%
</td>
</tr>
{/if}
{/each}
</tbody>
</table>
</div>
<a
href={`/industry/sectors`}
class="rounded cursor-pointer w-full m-auto py-2 h-full mt-6 text-[1rem] text-center font-semibold text-black sm:hover:hover:bg-gray-300 bg-[#ffff] transition duration-100"
>
All Sectors
</a>
</div> </div>
<a
href={`/industry/sectors`}
class="flex justify-center items-center rounded cursor-pointer w-full py-2 mt-3 text-[1rem] text-center font-semibold text-white dark:text-black m-auto sm:hover:bg-blue-600 dark:sm:hover:bg-gray-300 bg-[#3B82F6] dark:bg-[#fff] transition duration-100"
>
All Sectors
</a>
</div> </div>
</div> </div>
{/if} </div>
{/if}

View File

@ -218,21 +218,21 @@
hour: "numeric", hour: "numeric",
hour12: true, hour12: true,
}); });
return `<span class="font-[501] text-xs">${timeString.replace(/\s/g, " ")}</span>`; return `<span class=" text-xs">${timeString.replace(/\s/g, " ")}</span>`;
} else if (["1W", "1M"].includes(displayData)) { } else if (["1W", "1M"].includes(displayData)) {
const timeString = date?.toLocaleDateString("en-US", { const timeString = date?.toLocaleDateString("en-US", {
month: "short", month: "short",
day: "numeric", day: "numeric",
timeZone: "UTC", timeZone: "UTC",
}); });
return `<span class="font-[501] text-xs">${timeString}</span>`; return `<span class=" text-xs">${timeString}</span>`;
} else { } else {
const timeString = date?.toLocaleDateString("en-US", { const timeString = date?.toLocaleDateString("en-US", {
year: "2-digit", year: "2-digit",
month: "short", month: "short",
timeZone: "UTC", timeZone: "UTC",
}); });
return `<span class="font-[501] text-xs">${timeString}</span>`; return `<span class=" text-xs">${timeString}</span>`;
} }
}, },
}, },
@ -680,29 +680,6 @@
<div <div
class="order-1 lg:order-5 m-auto grow overflow-hidden border-gray-800 py-0.5 xs:py-1 sm:px-0.5 sm:pb-3 sm:pt-2.5 lg:mb-0 lg:border-0 lg:border-l lg:border-sharp lg:px-0 lg:py-0 lg:pl-5 md:mb-4 md:border-b" class="order-1 lg:order-5 m-auto grow overflow-hidden border-gray-800 py-0.5 xs:py-1 sm:px-0.5 sm:pb-3 sm:pt-2.5 lg:mb-0 lg:border-0 lg:border-l lg:border-sharp lg:px-0 lg:py-0 lg:pl-5 md:mb-4 md:border-b"
> >
<div class="flex items-center justify-between py-1 sm:pt-0.5">
<div class="hide-scroll overflow-x-auto">
<ul class="flex sm:space-x-2">
{#each intervals as interval}
<li>
<button
on:click={() => changeData(interval)}
class="cursor-pointer focus:outline-none"
>
<span
class="block px-3 py-1 rounded duration-100 ease-in-out
{displayData === interval
? 'bg-blue-50 text-blue-700 dark:bg-primary dark:text-white font-semibold'
: 'bg-transparent text-muted dark:text-gray-400 dark:sm:hover:text-white sm:hover:bg-gray-100 dark:sm:hover:bg-primary'}"
>
{interval}
</span>
</button>
</li>
{/each}
</ul>
</div>
</div>
<div class="h-[250px] sm:h-[350px]"> <div class="h-[250px] sm:h-[350px]">
<div <div
class="flex h-full w-full flex-col items-center justify-center rounded-sm border border-gray-800 p-6 text-center md:p-12" class="flex h-full w-full flex-col items-center justify-center rounded-sm border border-gray-800 p-6 text-center md:p-12"
@ -721,25 +698,21 @@
> >
<div class="flex items-center justify-between py-1 sm:pt-0.5"> <div class="flex items-center justify-between py-1 sm:pt-0.5">
<div class="hide-scroll overflow-x-auto"> <div class="hide-scroll overflow-x-auto">
<ul <ul class="flex sm:space-x-2">
class="flex space-x-[3px] whitespace-nowrap pl-0.5 xs:space-x-1"
>
{#each intervals as interval} {#each intervals as interval}
<li> <li>
<button <button
on:click={() => changeData(interval)} on:click={() => changeData(interval)}
class="cursor-pointer px-1 py-1 text-sm sm:text-[1rem] xs:px-[3px] bp:px-1.5 sm:px-2 xxxl:px-3" class="cursor-pointer focus:outline-none"
> >
<span <span
class="block {displayData === interval class="block px-3 py-1 rounded duration-100 ease-in-out
? 'text-white' {displayData === interval
: 'text-gray-400'}">{interval}</span ? 'bg-gray-200 text-muted dark:bg-primary dark:text-white font-semibold'
: 'bg-transparent text-muted dark:text-gray-400 dark:sm:hover:text-white sm:hover:bg-gray-100 dark:sm:hover:bg-primary'}"
> >
<div {interval}
class="{displayData === interval </span>
? `bg-[${displayLegend?.graphChange < 0 ? '#FF2F1F' : '#00FC50'}] `
: 'bg-default'} mt-1 h-[3px] w-[1.5rem] m-auto rounded-full"
/>
</button> </button>
</li> </li>
{/each} {/each}