dynamically set left storage

This commit is contained in:
Hristo Nedelkov 2023-08-10 15:28:38 +03:00
parent 428cc4847f
commit c89e6e1c47
3 changed files with 40 additions and 35 deletions

View File

@ -2,24 +2,31 @@ import ShadowBox from './ShadowBox'
import IconText from './IconText' import IconText from './IconText'
import { Paragraph, Separator, XStack, YStack } from 'tamagui' import { Paragraph, Separator, XStack, YStack } from 'tamagui'
import StandardGauge from './StandardGauge' import StandardGauge from './StandardGauge'
interface DeviceStorageHealthProps {
storage: number
maxStorage: number
}
const DeviceStorageHealth: React.FC<DeviceStorageHealthProps> = ({ storage, maxStorage }) => {
const message = storage < maxStorage ? 'Good' : 'Poor'
const data = (storage: number, maxStorage: number) => {
const used = storage
const free = maxStorage - storage
const DeviceStorageHealth = () => { return [
const currentLoad = 60 {
const message = currentLoad < 80 ? 'Good' : 'Poor' id: 'storage',
const data = [ label: 'Used',
{ value: used,
id: 'storage', color: '#E95460',
label: 'Storage', },
value: 55, {
color: '#E95460', id: 'storage',
}, label: 'Free',
{ value: free,
id: 'storage', color: '#E7EAEE',
label: 'Storage', },
value: 45, ]
color: '#E7EAEE', }
},
]
return ( return (
<ShadowBox boxStyle={{ width: '284px', height: '136px' }}> <ShadowBox boxStyle={{ width: '284px', height: '136px' }}>
<YStack> <YStack>
@ -38,14 +45,14 @@ const DeviceStorageHealth = () => {
height: '75px', height: '75px',
}} }}
> >
<StandardGauge data={data} /> <StandardGauge data={data(storage, maxStorage)} />
</div> </div>
<YStack space={'$3'}> <YStack space={'$3'}>
<Paragraph color={'#09101C'} size={'$6'} fontWeight={'600'}> <Paragraph color={'#09101C'} size={'$6'} fontWeight={'600'}>
Storage Storage
</Paragraph> </Paragraph>
<Paragraph color={'#09101C'} size={'$8'} fontWeight={'700'}> <Paragraph color={'#09101C'} size={'$8'} fontWeight={'700'}>
{currentLoad} GB {storage} GB
</Paragraph> </Paragraph>
</YStack> </YStack>
</XStack> </XStack>

View File

@ -3,7 +3,7 @@ import './LandingPage.css'
import QuickStartBar from './QuickStartBar' import QuickStartBar from './QuickStartBar'
import DeviceStorageHealth from './DeviceStorageHealth' import DeviceStorageHealth from './DeviceStorageHealth'
import DeviceCPULoad from './DeviceCPULoad' import DeviceCPULoad from './DeviceCPULoad'
function LandingPage() { function LandingPage() {
return ( return (
<> <>
@ -97,7 +97,7 @@ function Content() {
Discover Nodes Discover Nodes
</button> </button>
</article> </article>
<DeviceStorageHealth /> <DeviceStorageHealth storage={60} maxStorage={100} />
<DeviceCPULoad load={[13, 32, 24, 1, 49, 90, 13, 32, 24, 1, 49, 90]} /> <DeviceCPULoad load={[13, 32, 24, 1, 49, 90, 13, 32, 24, 1, 49, 90]} />
</div> </div>
) )

View File

@ -11,20 +11,18 @@ interface StandardGaugeProps {
} }
const StandardGauge = ({ data }: StandardGaugeProps) => ( const StandardGauge = ({ data }: StandardGaugeProps) => (
// <div style={{ width: '75px', height: '75px' }}> <ResponsivePie
<ResponsivePie data={data}
data={data} margin={{ top: 0, right: 0, bottom: 0, left: 0 }}
margin={{ top: 0, right: 0, bottom: 0, left: 0 }} innerRadius={0.65}
innerRadius={0.65} colors={datum => datum.data.color}
colors={datum => datum.data.color} fit={false}
fit={false} activeOuterRadiusOffset={8}
activeOuterRadiusOffset={8} enableArcLinkLabels={false}
enableArcLinkLabels={false} arcLinkLabelsColor={{ from: 'color' }}
arcLinkLabelsColor={{ from: 'color' }} enableArcLabels={false}
enableArcLabels={false} legends={[]}
legends={[]} />
/>
// </div>
) )
export default StandardGauge export default StandardGauge