Skip to content

Commit d798e65

Browse files
committed
Merge branch 'main' into feat-embedded-stripe
2 parents 4f167c3 + 25afa1d commit d798e65

File tree

15 files changed

+167
-81
lines changed

15 files changed

+167
-81
lines changed
Lines changed: 4 additions & 4 deletions
Loading

src/components/Nav/Account.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const Account = memo(function Account() {
4949
{userHandle}
5050
</BasicLink>
5151
)}
52-
{subscription?.status === 'active' ? (
52+
{user?.has_active_subscription || subscription?.status === 'active' ? (
5353
<span className="flex items-center gap-1 text-xs font-medium text-green-600 dark:text-green-500">
5454
<Icon name="check-circle" className="h-3.5 w-3.5" />
5555
Subscribed

src/components/Nav/Desktop.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ const LinkToPage = React.memo(function LinkToPage({
221221
<Icon name={icon as any} className="group-hover/link:animate-wiggle h-4 w-4" />
222222
) : name === 'LlamaAI' ? (
223223
<img
224-
src="/icons/ask-llama-ai.svg"
224+
src="/icons/ask-llamaai.svg"
225225
alt="LlamaAI"
226-
className="h-4 w-4 brightness-0 group-data-[linkactive=true]/link:brightness-100 dark:brightness-100 dark:group-data-[linkactive=true]/link:brightness-100"
226+
className="h-4 w-4 brightness-0 group-data-[linkactive=true]/link:invert dark:invert"
227227
/>
228228
) : null}
229229
<span className="relative inline-flex items-center gap-2">

src/components/Search/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ const Desktop = () => {
265265
className="mr-auto hidden items-center justify-between gap-[10px] rounded-md bg-[linear-gradient(93.94deg,#FDE0A9_24.73%,#FBEDCB_57.42%,#FDE0A9_99.73%)] px-4 py-2 text-xs font-semibold text-black shadow-[0px_0px_30px_0px_rgba(253,224,169,0.5),_0px_0px_1px_2px_rgba(255,255,255,0.1)] lg:flex"
266266
>
267267
<span className="whitespace-nowrap">Ask LlamaAI</span>
268-
<img src="/icons/ask-llama-ai.svg" alt="Ask LlamaAI" className="h-4 w-4 shrink-0 brightness-0" />
268+
<img src="/icons/ask-llamaai.svg" alt="Ask LlamaAI" className="h-4 w-4 shrink-0" />
269269
</BasicLink>
270270
)}
271271
</>

src/containers/LlamaAI/GetStarted.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function GetStarted() {
3131
href="/ai"
3232
className="mx-auto flex items-center justify-between gap-[10px] rounded-md bg-[linear-gradient(93.94deg,#FDE0A9_24.73%,#FBEDCB_57.42%,#FDE0A9_99.73%)] px-4 py-2 text-base font-semibold text-black shadow-[0px_0px_30px_0px_rgba(253,224,169,0.5),_0px_0px_1px_2px_rgba(255,255,255,0.1)]"
3333
>
34-
<img src="/icons/ask-llama-ai.svg" alt="Ask LlamaAI" className="h-4 w-4 shrink-0 brightness-0" />
34+
<img src="/icons/ask-llamaai.svg" alt="Ask LlamaAI" className="h-4 w-4 shrink-0 brightness-0" />
3535
<span className="whitespace-nowrap">Try LlamaAI</span>
3636
</BasicLink>
3737
</div>

src/containers/LlamaAI/components/ChartRenderer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { lazy, memo, Suspense, useEffect, useReducer, useRef } from 'react'
22
import { CSVDownloadButton } from '~/components/ButtonStyled/CsvButton'
33
import type { IBarChartProps, IChartProps, IPieChartProps, IScatterChartProps } from '~/components/ECharts/types'
4+
import { formatTooltipValue } from '~/components/ECharts/useDefaults'
45
import { Icon } from '~/components/Icon'
5-
import { formattedNum } from '~/utils'
66
import type { ChartConfiguration } from '../types'
77
import { adaptChartData, adaptMultiSeriesData } from '../utils/chartAdapter'
88
import { ChartDataTransformer } from '../utils/chartDataTransformer'
@@ -249,7 +249,7 @@ const SingleChart = memo(function SingleChart({ config, data, isActive }: Single
249249
const yValue = params[0]?.value?.[1]
250250
const seriesName = params[0]?.seriesName
251251
const valueSymbol = config.valueSymbol || '$'
252-
const formattedValue = valueSymbol === '$' ? formattedNum(yValue, true) : `${yValue}${valueSymbol}`
252+
const formattedValue = formatTooltipValue(yValue, valueSymbol)
253253
return `<div style="margin-bottom: 4px; font-weight: 600;">${xValue}</div><div>${seriesName}: ${formattedValue}</div>`
254254
}
255255
}

src/containers/LlamaAI/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ const PromptInput = memo(function PromptInput({
15601560
onChange={onChange}
15611561
onKeyDown={onKeyDown}
15621562
name="prompt"
1563-
className="block min-h-[48px] w-full rounded-lg border border-[#e6e6e6] bg-(--app-bg) p-4 text-transparent caret-black outline-none placeholder:text-[#666] focus-visible:border-(--old-blue) max-lg:resize-none max-sm:pr-8 max-sm:text-base sm:min-h-[72px] dark:border-[#222324] dark:caret-white placeholder:dark:text-[#919296]"
1563+
className="block min-h-[48px] w-full resize-none rounded-lg border border-[#e6e6e6] bg-(--app-bg) p-4 text-transparent caret-black outline-none placeholder:text-[#666] focus-visible:border-(--old-blue) max-sm:pr-8 max-sm:text-base sm:min-h-[72px] dark:border-[#222324] dark:caret-white placeholder:dark:text-[#919296]"
15641564
autoCorrect="off"
15651565
autoComplete="off"
15661566
spellCheck="false"

src/containers/LlamaAI/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ export interface ChartConfiguration {
1111
x: {
1212
field: string
1313
label: string
14-
type: 'time' | 'category'
14+
type: 'time' | 'category' | 'value'
15+
valueSymbol?: string
1516
}
1617
yAxes: Array<{
1718
id: string
1819
fields: string[]
1920
label: string
2021
position: 'left' | 'right'
2122
scale?: 'linear' | 'log'
23+
valueSymbol?: string
2224
}>
2325
}
2426

src/containers/LlamaAI/utils/chartAdapter.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ function adaptScatterChartData(config: ChartConfiguration, rawData: any[]): Adap
231231
const xAxisLabel = config.axes.x.label || xField
232232
const yAxisLabel = config.axes.yAxes[0]?.label || yField
233233

234+
const xAxisSymbol = config.axes.x.valueSymbol ?? config.valueSymbol ?? ''
235+
const yAxisSymbol = config.axes.yAxes[0]?.valueSymbol ?? config.valueSymbol ?? ''
236+
237+
const formatValue = (val: number, symbol: string) => {
238+
if (symbol === '$') return formattedNum(val, true)
239+
if (symbol === '%') return val.toFixed(2) + '%'
240+
if (symbol === '') return formattedNum(val)
241+
return `${formattedNum(val)} ${symbol}`
242+
}
243+
234244
const scatterProps = {
235245
chartData: scatterData,
236246
title: config.title,
@@ -243,12 +253,7 @@ function adaptScatterChartData(config: ChartConfiguration, rawData: any[]): Adap
243253
const xValue = params.value[0]
244254
const yValue = params.value[1]
245255
const entityName = params.value[2] || 'Unknown'
246-
const formatValue = (val: number) => {
247-
if (config.valueSymbol === '$') return formattedNum(val, true)
248-
if (config.valueSymbol === '%') return val.toFixed(2) + '%'
249-
return formattedNum(val)
250-
}
251-
return `<strong>${entityName}</strong><br/>${xAxisLabel}: ${formatValue(xValue)}<br/>${yAxisLabel}: ${formatValue(yValue)}`
256+
return `<strong>${entityName}</strong><br/>${xAxisLabel}: ${formatValue(xValue, xAxisSymbol)}<br/>${yAxisLabel}: ${formatValue(yValue, yAxisSymbol)}`
252257
}
253258
return ''
254259
}
@@ -474,7 +479,7 @@ export function adaptMultiSeriesData(config: ChartConfiguration, rawData: any[])
474479
hideDataZoom: true,
475480
hideDownloadButton: false,
476481
valueSymbol: config.valueSymbol ?? '',
477-
xAxisType: config.axes.x.type,
482+
xAxisType: config.axes.x.type === 'value' ? 'category' : config.axes.x.type,
478483

479484
...(config.hallmarks?.length && {
480485
hallmarks: normalizeHallmarks(config.hallmarks)

src/containers/ProtocolOverview/index.tsx

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,18 +311,7 @@ export const KeyMetrics = (props: IKeyMetricsProps) => {
311311
)}
312312
</p>
313313
) : null}
314-
{props.currentTvlByChain?.borrowed != null ? (
315-
<p className="group flex flex-wrap justify-between gap-4 border-b border-(--cards-border) py-1 first:pt-0 last:border-none last:pb-0">
316-
<span className="text-(--text-label)">Borrowed</span>
317-
<Flag
318-
protocol={props.name}
319-
dataType="Borrowed"
320-
isLending={props.category === 'Lending'}
321-
className="mr-auto opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100"
322-
/>
323-
<span className="font-jetbrains">{props.formatPrice(props.currentTvlByChain.borrowed)}</span>
324-
</p>
325-
) : null}
314+
<BorrowedBreakdown {...props} />
326315
<TokenLiquidity {...props} />
327316
<Treasury {...props} />
328317
<Raises {...props} />
@@ -333,6 +322,78 @@ export const KeyMetrics = (props: IKeyMetricsProps) => {
333322
)
334323
}
335324

325+
const BorrowedBreakdown = (props: IKeyMetricsProps) => {
326+
if (props.currentTvlByChain?.borrowed == null) return null
327+
328+
if (props.borrowedBreakdown?.chains.length === 0 && props.borrowedBreakdown?.tokens.length === 0) {
329+
return (
330+
<p className="group flex flex-wrap justify-between gap-4 border-b border-(--cards-border) py-1 first:pt-0 last:border-none last:pb-0">
331+
<span className="text-(--text-label)">Borrowed</span>
332+
<Flag
333+
protocol={props.name}
334+
dataType="Borrowed"
335+
isLending={props.category === 'Lending'}
336+
className="mr-auto opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100"
337+
/>
338+
<span className="font-jetbrains">{props.formatPrice(props.currentTvlByChain.borrowed)}</span>
339+
</p>
340+
)
341+
}
342+
343+
return (
344+
<details className="group">
345+
<summary className="flex flex-wrap justify-start gap-4 border-b border-(--cards-border) py-1 group-last:border-none group-open:border-none group-open:font-semibold">
346+
<span className="text-(--text-label)">Borrowed</span>
347+
<Icon
348+
name="chevron-down"
349+
height={16}
350+
width={16}
351+
className="relative top-0.5 -ml-3 transition-transform duration-100 group-open:rotate-180"
352+
/>
353+
<Flag
354+
protocol={props.name}
355+
dataType="Borrowed"
356+
isLending={props.category === 'Lending'}
357+
className="mr-auto opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100"
358+
/>
359+
<span className="font-jetbrains ml-auto">{props.formatPrice(props.currentTvlByChain.borrowed)}</span>
360+
</summary>
361+
<div className="mb-3 flex flex-col">
362+
{props.borrowedBreakdown?.chains.length > 0 ? (
363+
<details className="group/1">
364+
<summary className="flex flex-wrap justify-start gap-4 border-b border-(--cards-border) py-1 group-last/1:border-none group-open/1:border-none group-open/1:font-semibold">
365+
<span className="text-(--text-label)">Borrowed by Chain</span>
366+
<Icon
367+
name="chevron-down"
368+
height={16}
369+
width={16}
370+
className="relative top-0.5 -ml-3 transition-transform duration-100 group-open/1:rotate-180"
371+
/>
372+
<Flag
373+
protocol={props.name}
374+
dataType="Borrowed by Chain"
375+
isLending={props.category === 'Lending'}
376+
className="mr-auto opacity-0 group-hover/1:opacity-100 group-focus-visible/1:opacity-100"
377+
/>
378+
</summary>
379+
<div className="mb-3 flex flex-col">
380+
{props.borrowedBreakdown?.chains.map(([chain, tvl]) => (
381+
<p
382+
key={`${chain}-${tvl}-${props.name}`}
383+
className="flex items-center justify-between gap-1 border-b border-dashed border-[#e6e6e6] py-1 group-last:border-none dark:border-[#222224]"
384+
>
385+
<span className="text-(--text-label)">{chain}</span>
386+
<span className="font-jetbrains">{props.formatPrice(tvl)}</span>
387+
</p>
388+
))}
389+
</div>
390+
</details>
391+
) : null}
392+
</div>
393+
</details>
394+
)
395+
}
396+
336397
const Articles = (props: IProtocolOverviewPageData) => {
337398
if (!props.articles?.length) return null
338399

@@ -1877,10 +1938,11 @@ const MethodologyByAdapter = ({
18771938

18781939
return (
18791940
<>
1880-
{adapter?.methodology ? (
1941+
{adapter?.methodology || adapter?.methodologyURL ? (
18811942
adapter?.methodologyURL ? (
18821943
<a href={adapter.methodologyURL} target="_blank" rel="noopener noreferrer" className="hover:underline">
1883-
<span className="font-medium">{title}:</span> <span>{adapter.methodology}</span>
1944+
<span className="font-medium">{title}:</span>{' '}
1945+
{adapter.methodology ? <span>{adapter.methodology}</span> : null}
18841946
{adapter.methodologyURL ? (
18851947
<span className="relative top-0.5 left-1 inline-block">
18861948
<Icon name="external-link" className="h-3.5 w-3.5" />

0 commit comments

Comments
 (0)