update bullbear component
This commit is contained in:
parent
07970de039
commit
b46f62b4e4
@ -3,50 +3,12 @@
|
|||||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let marketMoods = {};
|
|
||||||
|
|
||||||
let rawData = marketMoods;
|
let rawData = {};
|
||||||
let mode = 'bullish';
|
|
||||||
let showFullText = false;
|
|
||||||
// Function to split text into paragraphs
|
|
||||||
|
|
||||||
//DO NOT TOUCH THIS CODE - SAFARI 15.3 are not compatible with the previous code. The website will break.
|
|
||||||
// CONSIDER MOVING THIS LOGIC TO THE BACKEND TO REMOVE THE RISK COMPLETELY
|
|
||||||
function splitIntoParagraphs(text) {
|
|
||||||
if (!text) return [];
|
|
||||||
|
|
||||||
// Replace "U.S." and "vs." with placeholders
|
|
||||||
const placeholderUS = '__US__';
|
|
||||||
const placeholderVs = '__VS__';
|
|
||||||
|
|
||||||
let tempText = text.replace(/U\.S\./g, placeholderUS)
|
|
||||||
.replace(/vs\./g, placeholderVs);
|
|
||||||
|
|
||||||
// Split the text based on periods followed by spaces
|
|
||||||
let paragraphs = tempText.split(/\. \s*/);
|
|
||||||
|
|
||||||
// Restore the placeholders back to "U.S." and "vs."
|
|
||||||
paragraphs = paragraphs.map(paragraph =>
|
|
||||||
paragraph.replace(new RegExp(placeholderUS, 'g'), 'U.S.')
|
|
||||||
.replace(new RegExp(placeholderVs, 'g'), 'vs.')
|
|
||||||
);
|
|
||||||
|
|
||||||
return paragraphs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let paragraphs = splitIntoParagraphs(rawData?.bullSays);
|
|
||||||
|
|
||||||
|
|
||||||
function handleMode(i) {
|
function handleMode(i) {
|
||||||
activeIdx = i;
|
activeIdx = i;
|
||||||
if(activeIdx === 0) {
|
|
||||||
paragraphs = splitIntoParagraphs(rawData?.bullSays);
|
|
||||||
}
|
|
||||||
else if (activeIdx === 1) {
|
|
||||||
paragraphs = splitIntoParagraphs(rawData?.bearSays);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
@ -62,17 +24,15 @@
|
|||||||
|
|
||||||
$: {
|
$: {
|
||||||
if($stockTicker && typeof window !== 'undefined') {
|
if($stockTicker && typeof window !== 'undefined') {
|
||||||
rawData = marketMoods;
|
rawData = data?.getBullBearSay;
|
||||||
mode = 'bullish';
|
activeIdx = 0;
|
||||||
showFullText = false;
|
|
||||||
paragraphs = splitIntoParagraphs(rawData?.bullSays);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{#if Object?.keys(marketMoods)?.length !== 0}
|
{#if Object?.keys(rawData)?.length !== 0}
|
||||||
|
|
||||||
<div class="space-y-3 overflow-hidden">
|
<div class="space-y-3 overflow-hidden">
|
||||||
<!--Start Content-->
|
<!--Start Content-->
|
||||||
@ -125,14 +85,12 @@
|
|||||||
</span>
|
</span>
|
||||||
<div class="flex mt-5 h-auto">
|
<div class="flex mt-5 h-auto">
|
||||||
|
|
||||||
<div class="{activeIdx === 0 ? 'bg-[#10DB06]' : 'bg-[#FF2F1F]'} w-3.5 rounded-l-xl" />
|
<div class="{activeIdx === 0 ? 'bg-[#10DB06]' : 'bg-[#FF2F1F]'} w-full max-w-[3px] rounded-l-xl" />
|
||||||
<span class="text-gray-100 ml-3 text-[1rem] ">
|
<span class="text-gray-100 ml-3 text-[1rem] ">
|
||||||
{#if showFullText}
|
{#if activeIdx === 0}
|
||||||
{#each (showFullText ? paragraphs : paragraphs?.slice(0,1)) as paragraph, index}
|
<p class="pr-1">{rawData?.bullSays}</p>
|
||||||
<p class="{index !== 0 ? 'mt-1' : ''} pr-1">{paragraph} {paragraphs?.length <= index+1 ? '' : '.'}</p>
|
|
||||||
{/each}
|
|
||||||
{:else}
|
{:else}
|
||||||
{paragraphs?.at(0)?.slice(0,250) + '...'}
|
<p class="pr-1">{rawData?.bearSays}</p>
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -145,10 +103,6 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label on:click={() => showFullText = !showFullText} class="{data?.user?.tier !== 'Pro' ? 'hidden' : ''} cursor-pointer m-auto flex justify-center items-center mt-5">
|
|
||||||
<svg class="w-10 h-10 transform {showFullText ? 'rotate-180' : ''} " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#2A323C" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm0 13.5L7.5 11l1.42-1.41L12 12.67l3.08-3.08L16.5 11L12 15.5z"/></svg>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@ -16,7 +16,6 @@
|
|||||||
let displayChartType = 'line';
|
let displayChartType = 'line';
|
||||||
|
|
||||||
let prePostData = {};
|
let prePostData = {};
|
||||||
let marketMoods = {}
|
|
||||||
let communitySentiment = {};
|
let communitySentiment = {};
|
||||||
|
|
||||||
$: previousClose = data?.getStockQuote?.previousClose;
|
$: previousClose = data?.getStockQuote?.previousClose;
|
||||||
@ -634,12 +633,10 @@ function changeChartType() {
|
|||||||
oneYearPrice = [];
|
oneYearPrice = [];
|
||||||
threeYearPrice = [];
|
threeYearPrice = [];
|
||||||
prePostData = {};
|
prePostData = {};
|
||||||
marketMoods = {};
|
|
||||||
communitySentiment = {}
|
communitySentiment = {}
|
||||||
output = null;
|
output = null;
|
||||||
|
|
||||||
|
|
||||||
marketMoods = data?.getBullBearSay;
|
|
||||||
communitySentiment = data?.getCommunitySentiment;
|
communitySentiment = data?.getCommunitySentiment;
|
||||||
|
|
||||||
|
|
||||||
@ -1178,8 +1175,8 @@ function changeChartType() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="w-full mt-10 sm:mt-0 m-auto sm:pl-6 sm:pb-6 sm:pt-6 {Object?.keys(marketMoods)?.length !== 0 ? '' : 'hidden'}">
|
<div class="w-full mt-10 sm:mt-0 m-auto sm:pl-6 sm:pb-6 sm:pt-6 {Object?.keys(data?.getBullBearSay || {})?.length !== 0 ? '' : 'hidden'}">
|
||||||
<BullBearSay data={data} marketMoods={marketMoods}/>
|
<BullBearSay data={data}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Lazy>
|
<Lazy>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user