Separate logic in files

This commit is contained in:
Hristo Nedelkov 2023-09-21 09:29:06 +03:00
parent b59e074cf7
commit 43cc1772a4
4 changed files with 71 additions and 7 deletions

View File

@ -0,0 +1,63 @@
import { Separator, Stack, XStack, YStack } from 'tamagui'
import { Shadow, Text } from '@status-im/components'
import { SwapIcon } from '@status-im/icons'
import { CSSProperties } from 'react'
import { formatNumberWithComa } from '../../../utilities'
import IconText from '../../../components/General/IconText'
import Icon from '../../../components/General/Icon'
import StandardGauge from '../../../components/Charts/StandardGauge'
type ConsensusCardProps = {
title: string
value: number
total: number
isTop?: boolean
}
const data = [
{
id: 'storage',
label: 'Used',
value: 132156,
color: '#ff6161',
},
{
id: 'storage',
label: 'Free',
value: 200000,
color: '#E7EAEE',
},
]
const ConsensusCard = ({ title, value, total, isTop }: ConsensusCardProps) => {
const style: CSSProperties = {}
if (isTop === true) {
style.borderTopLeftRadius = '16px'
style.borderTopRightRadius = '16px'
} else if (isTop === false) {
style.borderBottomLeftRadius = '16px'
style.borderBottomRightRadius = '16px'
}
return (
<Shadow variant="$1" style={style}>
<YStack>
<Stack style={{ minHeight: '90px', padding: '12px 16px' }}>
<Text size={15} weight={'semibold'} color="#647084">
{title}
</Text>
</Stack>
<Separator borderColor={'#e3e3e3'} />
<XStack space={'$3'} style={{ padding: '12px 16px' }}>
<IconText icon={<SwapIcon size={16} />}>Syncing</IconText>
<Text size={13} weight={'semibold'}>
{formatNumberWithComa(value)} / {formatNumberWithComa(total)}
</Text>
</XStack>
</YStack>
</Shadow>
)
}
export default ConsensusCard

View File

@ -8,7 +8,7 @@ import IconText from '../../../components/General/IconText'
import Icon from '../../../components/General/Icon' import Icon from '../../../components/General/Icon'
import StandardGauge from '../../../components/Charts/StandardGauge' import StandardGauge from '../../../components/Charts/StandardGauge'
type SyncCardContentProps = { type ExecutionClientCardProps = {
title: string title: string
value: number value: number
total: number total: number
@ -28,7 +28,7 @@ const data = [
color: '#E7EAEE', color: '#E7EAEE',
}, },
] ]
const SyncCardContent = ({ title, value, total, isTop }: SyncCardContentProps) => { const ExecutionClientCard = ({ title, value, total, isTop }: ExecutionClientCardProps) => {
const style: CSSProperties = {} const style: CSSProperties = {}
if (isTop === true) { if (isTop === true) {
@ -70,4 +70,4 @@ const SyncCardContent = ({ title, value, total, isTop }: SyncCardContentProps) =
) )
} }
export default SyncCardContent export default ExecutionClientCard

View File

@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react' import type { Meta, StoryObj } from '@storybook/react'
import SyncCardContent from './SyncCardContent' import SyncCardContent from './ExecutionClientCard'
const meta = { const meta = {
title: 'Dashboard/SyncCardContent', title: 'Dashboard/SyncCardContent',

View File

@ -1,8 +1,9 @@
import { Separator, Stack, YStack } from 'tamagui' import { Separator, Stack, YStack } from 'tamagui'
import { Text } from '@status-im/components' import { Text } from '@status-im/components'
import SyncCardContent from './SyncCardContent'
import DashboardCardWrapper from '../DashboardCardWrapper' import DashboardCardWrapper from '../DashboardCardWrapper'
import ExecutionClientCard from './ExecutionClientCard'
import ConsensusCard from './ConsensusClientCard'
const SyncStatusCard = () => { const SyncStatusCard = () => {
return ( return (
@ -14,9 +15,9 @@ const SyncStatusCard = () => {
</Text> </Text>
</Stack> </Stack>
<YStack> <YStack>
<SyncCardContent title={'Execution Client'} value={123.424} total={170} isTop={true} /> <ConsensusCard title={'Execution Client'} value={123.424} total={170} isTop={true} />
<Separator borderColor={'#e3e3e3'} /> <Separator borderColor={'#e3e3e3'} />
<SyncCardContent title={'Consensus Client'} value={123.424} total={170} isTop={false} /> <ExecutionClientCard title={'Consensus Client'} value={123.424} total={170} isTop={false} />
</YStack> </YStack>
</YStack> </YStack>
</DashboardCardWrapper> </DashboardCardWrapper>