-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ux update
- Loading branch information
Showing
14 changed files
with
745 additions
and
547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useState, useRef, useLayoutEffect } from 'react'; | ||
|
||
const AnimateHeight = ({ children }: { children: React.ReactNode }) => { | ||
const [height, setHeight] = useState<number | null>(null); | ||
const contentRef = useRef<HTMLDivElement>(null); | ||
|
||
useLayoutEffect(() => { | ||
if (contentRef.current) { | ||
const resizeObserver = new ResizeObserver(() => { | ||
if (contentRef.current) { | ||
setHeight(contentRef.current.scrollHeight); | ||
} | ||
}); | ||
|
||
resizeObserver.observe(contentRef.current); | ||
return () => resizeObserver.disconnect(); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div | ||
className="transition-[height] duration-300 ease-in-out overflow-hidden" | ||
style={{ height: height ? `${height}px` : 'auto' }} | ||
> | ||
<div ref={contentRef}>{children}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AnimateHeight; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { memo, useMemo } from 'react'; | ||
|
||
import { Progress } from '@ui/components/ui/progress'; | ||
|
||
export type ProgressBarProps = { | ||
max: number; | ||
value: number; | ||
}; | ||
|
||
function ProgressBar({ max, value }: ProgressBarProps) { | ||
const percentage = useMemo<number>(() => (value / max) * 100, [max, value]); | ||
|
||
const percentageFormatted = useMemo<string>( | ||
() => `${percentage.toFixed(2)}%`, | ||
[percentage] | ||
); | ||
|
||
return ( | ||
<div className="w-full space-y-1"> | ||
<Progress | ||
value={percentage} | ||
className="h-2" | ||
/> | ||
<div className="text-xs text-gray-400"> | ||
{percentageFormatted} utilized | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
const MemoizedProgressBar = memo(ProgressBar); | ||
|
||
export default MemoizedProgressBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React, { memo, useMemo } from 'react'; | ||
|
||
import millify from 'millify'; | ||
|
||
import MemoizedDonutChart from './dialogs/manage/DonutChart'; | ||
|
||
interface UtilizationStatsProps { | ||
label: string; | ||
value: number; | ||
max: number; | ||
symbol?: string; | ||
valueInFiat: number; | ||
maxInFiat: number; | ||
} | ||
|
||
function UtilizationStats({ | ||
label, | ||
value, | ||
max, | ||
symbol = '', | ||
valueInFiat, | ||
maxInFiat | ||
}: UtilizationStatsProps) { | ||
return ( | ||
<div className="flex items-center justify-center"> | ||
<div className="flex items-center"> | ||
<div className="w-20 mr-4"> | ||
<MemoizedDonutChart | ||
max={max} | ||
value={value} | ||
/> | ||
</div> | ||
<div> | ||
<div className="text-gray-400">{label}:</div> | ||
<div className="text-white"> | ||
<strong> | ||
{millify(value)} of {millify(max)} {symbol} | ||
</strong> | ||
</div> | ||
<div className="text-sm text-gray-300"> | ||
${millify(valueInFiat)} of ${millify(maxInFiat)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
const MemoizedUtilizationStats = memo(UtilizationStats); | ||
|
||
export default MemoizedUtilizationStats; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.