diff --git a/idea/frontend/src/features/balance/assets/plus.svg b/idea/frontend/src/features/balance/assets/plus.svg new file mode 100644 index 0000000000..95ca840dec --- /dev/null +++ b/idea/frontend/src/features/balance/assets/plus.svg @@ -0,0 +1,3 @@ + diff --git a/idea/frontend/src/features/balance/index.ts b/idea/frontend/src/features/balance/index.ts index 80ad4b54a3..4f355e02dc 100644 --- a/idea/frontend/src/features/balance/index.ts +++ b/idea/frontend/src/features/balance/index.ts @@ -1,3 +1,3 @@ -import { TransferBalance } from './ui'; +import { TransferBalance, ProgramBalance } from './ui'; -export { TransferBalance }; +export { TransferBalance, ProgramBalance }; diff --git a/idea/frontend/src/features/balance/ui/balance/balance.module.scss b/idea/frontend/src/features/balance/ui/balance/balance.module.scss new file mode 100644 index 0000000000..db549d9e80 --- /dev/null +++ b/idea/frontend/src/features/balance/ui/balance/balance.module.scss @@ -0,0 +1,10 @@ +.value { + font-family: Kanit; + font-weight: 600; +} + +.unit { + font-family: Kanit; + font-weight: 300; + color: rgba(255, 255, 255, 0.7); +} diff --git a/idea/frontend/src/features/balance/ui/balance/balance.tsx b/idea/frontend/src/features/balance/ui/balance/balance.tsx new file mode 100644 index 0000000000..52092c84a7 --- /dev/null +++ b/idea/frontend/src/features/balance/ui/balance/balance.tsx @@ -0,0 +1,26 @@ +import { useBalanceFormat } from '@gear-js/react-hooks'; +import { Balance as BalanceType } from '@polkadot/types/interfaces'; + +import styles from './balance.module.scss'; + +type Props = { + value: BalanceType | undefined; +}; + +function Balance({ value }: Props) { + const { getFormattedBalance } = useBalanceFormat(); + + if (!value) return null; + + const balance = getFormattedBalance(value); + + return ( +
+ {balance.value} + + {balance.unit} +
+ ); +} + +export { Balance }; diff --git a/idea/frontend/src/features/balance/ui/balance/index.ts b/idea/frontend/src/features/balance/ui/balance/index.ts new file mode 100644 index 0000000000..d35c5d0857 --- /dev/null +++ b/idea/frontend/src/features/balance/ui/balance/index.ts @@ -0,0 +1,3 @@ +import { Balance } from './balance'; + +export { Balance }; diff --git a/idea/frontend/src/features/balance/ui/index.ts b/idea/frontend/src/features/balance/ui/index.ts index 3b589a4992..ef61899e9b 100644 --- a/idea/frontend/src/features/balance/ui/index.ts +++ b/idea/frontend/src/features/balance/ui/index.ts @@ -1,3 +1,4 @@ import { TransferBalance } from './transfer-balance'; +import { ProgramBalance } from './program-balance'; -export { TransferBalance }; +export { TransferBalance, ProgramBalance }; diff --git a/idea/frontend/src/features/balance/ui/program-balance/index.ts b/idea/frontend/src/features/balance/ui/program-balance/index.ts new file mode 100644 index 0000000000..1741372bcd --- /dev/null +++ b/idea/frontend/src/features/balance/ui/program-balance/index.ts @@ -0,0 +1,3 @@ +import { ProgramBalance } from './program-balance'; + +export { ProgramBalance }; diff --git a/idea/frontend/src/features/balance/ui/program-balance/program-balance.module.scss b/idea/frontend/src/features/balance/ui/program-balance/program-balance.module.scss new file mode 100644 index 0000000000..b65f098799 --- /dev/null +++ b/idea/frontend/src/features/balance/ui/program-balance/program-balance.module.scss @@ -0,0 +1,5 @@ +.balance { + display: flex; + align-items: center; + gap: 8px; +} diff --git a/idea/frontend/src/features/balance/ui/program-balance/program-balance.tsx b/idea/frontend/src/features/balance/ui/program-balance/program-balance.tsx new file mode 100644 index 0000000000..d42fd4ef87 --- /dev/null +++ b/idea/frontend/src/features/balance/ui/program-balance/program-balance.tsx @@ -0,0 +1,35 @@ +import { HexString } from '@gear-js/api'; +import { useAccount, useBalance } from '@gear-js/react-hooks'; +import { Button } from '@gear-js/ui'; + +import { useModalState } from '@/hooks'; + +import PlusSVG from '../../assets/plus.svg?react'; +import { Balance } from '../balance'; +import { TransferBalanceModal } from '../transfer-balance-modal'; +import styles from './program-balance.module.scss'; + +type Props = { + id: HexString; +}; + +function ProgramBalance({ id }: Props) { + const { account } = useAccount(); + const { balance } = useBalance(id); + + const [isModalOpen, openModal, closeModal] = useModalState(); + + return ( + <> +