mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-28 02:50:45 +00:00
Implement memory health card
This commit is contained in:
parent
7aa238b5de
commit
04b29d9e84
70
src/components/DeviceMemoryHealth.tsx
Normal file
70
src/components/DeviceMemoryHealth.tsx
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import StandartLineChart from './StandardLineChart'
|
||||||
|
import ShadowBox from './ShadowBox'
|
||||||
|
import IconText from './IconText'
|
||||||
|
import { Paragraph, Separator, XStack, YStack } from 'tamagui'
|
||||||
|
|
||||||
|
type DataPoint = {
|
||||||
|
x: number
|
||||||
|
y: number
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChartData = {
|
||||||
|
id: string
|
||||||
|
color: string
|
||||||
|
data: DataPoint[]
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeviceMemoryProps = {
|
||||||
|
load: number[]
|
||||||
|
}
|
||||||
|
const DeviceMemory: React.FC<DeviceMemoryProps> = ({ load }) => {
|
||||||
|
const chartData: ChartData[] = [
|
||||||
|
{
|
||||||
|
id: 'cpu',
|
||||||
|
color: '#8DC6BC',
|
||||||
|
data: load.map((yValue, index: number) => ({
|
||||||
|
x: index + 1,
|
||||||
|
y: yValue,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
const currentLoad =
|
||||||
|
chartData[0].data.length > 0 ? chartData[0].data[chartData[0].data.length - 1].y : 0
|
||||||
|
|
||||||
|
const message = currentLoad < 80 ? 'Good' : 'Poor'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ShadowBox boxStyle={{ width: '284px', height: '136px' }}>
|
||||||
|
<YStack>
|
||||||
|
<XStack
|
||||||
|
justifyContent="space-between"
|
||||||
|
style={{
|
||||||
|
padding: '8px 16px',
|
||||||
|
position: 'relative', // Make XStack a positioning context
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }}>
|
||||||
|
<StandartLineChart data={chartData} />
|
||||||
|
</div>
|
||||||
|
<YStack space={'$3'}>
|
||||||
|
<Paragraph color={'#09101C'} size={'$6'} fontWeight={'600'}>
|
||||||
|
Memory
|
||||||
|
</Paragraph>
|
||||||
|
<Paragraph color={'#09101C'} size={'$8'} fontWeight={'700'}>
|
||||||
|
{currentLoad} GB
|
||||||
|
</Paragraph>
|
||||||
|
</YStack>
|
||||||
|
</XStack>
|
||||||
|
<Separator borderColor={'#e3e3e3'} />
|
||||||
|
<XStack space={'$4'} style={{ padding: '10px 16px 10px 16px' }}>
|
||||||
|
<IconText icon={message === 'Good' ? '/icons/check-circle.png' : '/icons/alert.png'}>
|
||||||
|
{message}
|
||||||
|
</IconText>
|
||||||
|
{/* <Text color={'#E95460'}>This is additional text</Text> */}
|
||||||
|
</XStack>
|
||||||
|
</YStack>
|
||||||
|
</ShadowBox>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DeviceMemory
|
@ -1,6 +1,7 @@
|
|||||||
import LayoutComponent from './LayoutComponent'
|
import LayoutComponent from './LayoutComponent'
|
||||||
import './LandingPage.css'
|
import './LandingPage.css'
|
||||||
import QuickStartBar from './QuickStartBar'
|
import QuickStartBar from './QuickStartBar'
|
||||||
|
import DeviceMemory from './DeviceMemoryHealth'
|
||||||
|
|
||||||
function LandingPage() {
|
function LandingPage() {
|
||||||
return (
|
return (
|
||||||
@ -95,6 +96,7 @@ function Content() {
|
|||||||
Discover Nodes
|
Discover Nodes
|
||||||
</button>
|
</button>
|
||||||
</article>
|
</article>
|
||||||
|
<DeviceMemory load={[12,13,14,14,2,1,3]}></DeviceMemory>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user