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'
const data = [
{ {
id: 'storage', id: 'storage',
label: 'Storage', label: 'Used',
value: 55, value: used,
color: '#E95460', color: '#E95460',
}, },
{ {
id: 'storage', id: 'storage',
label: 'Storage', label: 'Free',
value: 45, value: free,
color: '#E7EAEE', 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

@ -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,7 +11,6 @@ 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 }}
@ -24,7 +23,6 @@ const StandardGauge = ({ data }: StandardGaugeProps) => (
enableArcLabels={false} enableArcLabels={false}
legends={[]} legends={[]}
/> />
// </div>
) )
export default StandardGauge export default StandardGauge