This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: empty homepage state layout, closes #156
refactor: update electron-react-boilerplate/electron-react-boilerplate#2501
- Loading branch information
1 parent
ea151ac
commit 5662138
Showing
26 changed files
with
456 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { FC } from 'react'; | ||
import { Box, Button, Text } from '@blockstack/ui'; | ||
|
||
interface BalanceCardProps { | ||
balance: string; | ||
} | ||
|
||
export const BalanceCard: FC<BalanceCardProps> = ({ balance }) => { | ||
return ( | ||
<Box> | ||
<Text textStyle="body.large.medium" display="block"> | ||
Total balance | ||
</Text> | ||
<Text fontSize="40px" lineHeight="56px" fontWeight="bold" letterSpacing="-0.01em"> | ||
{balance} | ||
</Text> | ||
<Box mt="loose"> | ||
<Button size="md">Send</Button> | ||
<Button size="md" ml="tight"> | ||
Receive | ||
</Button> | ||
</Box> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as React from 'react'; | ||
import { Box, BoxProps } from '@blockstack/ui'; | ||
|
||
export const MovementArrow = ({ ...props }: BoxProps) => ( | ||
<Box {...props}> | ||
<svg width={16} height={16} viewBox="0 0 16 16" fill="none"> | ||
<path | ||
d="M5.883 9.75h4.234a.5.5 0 00.429-.757L8.429 5.465a.5.5 0 00-.858 0L5.454 8.993a.5.5 0 00.43.757z" | ||
fill="#00A73E" | ||
/> | ||
<circle opacity={0.24} cx={8} cy={8} r={7} stroke="#00A73E" strokeWidth={2} /> | ||
</svg> | ||
</Box> | ||
); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { Box, Flex, Text, Button } from '@blockstack/ui'; | ||
|
||
export const StackingPromoCard = () => { | ||
return ( | ||
<Box | ||
mt="extra-loose" | ||
borderRadius="8px" | ||
boxShadow="0px 1px 2px rgba(0, 0, 0, 0.04);" | ||
border="1px solid #F0F0F5" | ||
> | ||
<Flex flexDirection="column" mt="40px" mb="extra-loose"> | ||
<img src="assets/images/btc-podium.svg" /> | ||
<Text display="block" textAlign="center" textStyle="display.small" mt="loose"> | ||
Earn Bitcoin rewards | ||
</Text> | ||
<Text display="block" mt="tight" textAlign="center" maxWidth="320px" mx="auto"> | ||
You’ll earn Bitcoin when you temporarily lock 100,000 STX or more | ||
</Text> | ||
<Button size="md" mt="base" mx="auto" width="272px"> | ||
Buy STX | ||
</Button> | ||
</Flex> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { FC } from 'react'; | ||
import { Box, Flex, Text } from '@blockstack/ui'; | ||
import { Hr } from './hr'; | ||
import { MovementArrow } from './icons/movement-arrow'; | ||
|
||
interface StackingRewardCardProps { | ||
lifetime: string; | ||
lastCycle: string; | ||
} | ||
|
||
export const StackingRewardCard: FC<StackingRewardCardProps> = ({ lifetime, lastCycle }) => { | ||
return ( | ||
<Box | ||
mt="extra-loose" | ||
borderRadius="8px" | ||
boxShadow="0px 1px 2px rgba(0, 0, 0, 0.04);" | ||
border="1px solid #F0F0F5" | ||
> | ||
<Flex m="loose" flexDirection="column"> | ||
<Text textStyle="body.small" color="ink.600"> | ||
Lifetime rewards | ||
</Text> | ||
<Flex mt="tight" alignItems="center"> | ||
<MovementArrow mr="tight" /> | ||
<Text textStyle="body.large.medium">{lifetime}</Text> | ||
</Flex> | ||
</Flex> | ||
<Hr /> | ||
<Flex m="loose" flexDirection="column"> | ||
<Text textStyle="body.small" color="ink.600"> | ||
Last cycle | ||
</Text> | ||
<Flex mt="tight" alignItems="center"> | ||
<MovementArrow mr="tight" /> | ||
<Text textStyle="body.large.medium">{lastCycle}</Text> | ||
</Flex> | ||
</Flex> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/components/transaction-list/transaction-list-empty.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { Text, Flex } from '@blockstack/ui'; | ||
|
||
export const TransactionListEmpty = () => { | ||
return ( | ||
<Flex | ||
borderRadius="8px" | ||
boxShadow="0px 1px 2px rgba(0, 0, 0, 0.04);" | ||
border="1px solid #F0F0F5" | ||
minHeight={['152px', '152px', '300px', '416px']} | ||
justifyContent="center" | ||
alignItems={['center', 'center', null, null]} | ||
> | ||
<Text textStyle="body.small" display="block" textAlign="center" mb="tight"> | ||
You haven't made any transactions yet | ||
</Text> | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React, { FC } from 'react'; | ||
import { TransactionListEmpty } from './transaction-list-empty'; | ||
|
||
interface TransactionListProps { | ||
txs: any[]; | ||
} | ||
|
||
export const TransactionList: FC<TransactionListProps> = ({ txs }) => { | ||
if (txs.length === 0) return <TransactionListEmpty />; | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
import { Flex, Box } from '@blockstack/ui'; | ||
|
||
type HomeComponents = | ||
| 'balanceCard' | ||
| 'transactionList' | ||
| 'stackingPromoCard' | ||
| 'stackingRewardCard'; | ||
|
||
type HomeLayout = { | ||
[key in HomeComponents]: JSX.Element; | ||
}; | ||
|
||
export const HomeLayout: React.FC<HomeLayout> = ({ | ||
balanceCard, | ||
transactionList, | ||
stackingPromoCard, | ||
stackingRewardCard, | ||
}) => { | ||
return ( | ||
<Flex | ||
flexShrink={1} | ||
maxWidth="1104px" | ||
pt="120px" | ||
flexDirection="column" | ||
mx={['loose', 'loose', 'extra-loose', 'extra-loose', 'auto']} | ||
mb="extra-loose" | ||
> | ||
{balanceCard} | ||
<Flex flexDirection={['column', 'column', 'row']}> | ||
<Box mt="extra-loose" flexGrow={1} mr={[null, null, 'extra-loose', '72px']}> | ||
{transactionList} | ||
</Box> | ||
<Flex flexDirection="column" minWidth={[null, null, '376px']}> | ||
{stackingPromoCard} | ||
{stackingRewardCard} | ||
</Flex> | ||
</Flex> | ||
{/* <Button onClick={openModal}>Open a modal</Button> */} | ||
{/* <Box>Mnemonic: {mnemonic}</Box> | ||
<Box mt="loose">MnemonicEncryptedHex: {privateKey}</Box> | ||
<Box mt="loose">Private key: {privateKey}</Box> | ||
<Box mt="loose">Base58: {base58}</Box> | ||
<Box mt="loose">Salt: {(keys as any).salt}</Box> | ||
<Box mt="loose">Password: {(keys as any).password}</Box> | ||
<Box mt="loose">Stretched Key: {(keys as any).derivedEncryptionKey}</Box> */} | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,40 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { Flex, Box } from '@blockstack/ui'; | ||
import { ChainID } from '@blockstack/stacks-transactions'; | ||
import { deriveRootKeychainFromMnemonic, deriveStxAddressChain } from '@blockstack/keychain'; | ||
import { deriveRootKeychainFromMnemonic } from '@blockstack/keychain'; | ||
|
||
import { selectMnemonic, selectKeysSlice } from '../../store/keys'; | ||
import { selectMnemonic } from '../../store/keys'; | ||
import { BIP32Interface } from '../../types'; | ||
import { TransactionList } from '../../components/transaction-list/transaction-list'; | ||
import { StackingPromoCard } from '../../components/stacking-promo-card'; | ||
import { StackingRewardCard } from '../../components/stacking-rewards-card'; | ||
import { BalanceCard } from '../../components/balance-card'; | ||
import { HomeLayout } from './home-layout'; | ||
|
||
// | ||
// Placeholder component | ||
export const Home: React.FC = () => { | ||
const mnemonic = useSelector(selectMnemonic); | ||
const keys = useSelector(selectKeysSlice); | ||
const [keychain, setKeychain] = useState<{ rootNode: BIP32Interface } | null>(null); | ||
|
||
useEffect(() => { | ||
const deriveMasterKeychain = async () => { | ||
if (!mnemonic) return; | ||
const resp = await deriveRootKeychainFromMnemonic(mnemonic, ''); | ||
setKeychain(resp); | ||
const { rootNode } = await deriveRootKeychainFromMnemonic(mnemonic, ''); | ||
setKeychain({ rootNode }); | ||
}; | ||
void deriveMasterKeychain(); | ||
}, [mnemonic]); | ||
|
||
if (keychain === null) return <div>Homepage, but no keychain can be derived</div>; | ||
|
||
const rootNode = deriveStxAddressChain(ChainID.Testnet)(keychain.rootNode); | ||
|
||
const privateKey = rootNode.privateKey; | ||
|
||
const base58 = rootNode.childKey.toBase58(); | ||
|
||
if (!mnemonic) return <>How you get to homepage without a mnemonic?</>; | ||
|
||
// console.log(keychain); | ||
if (keychain === null) return <></>; | ||
|
||
return ( | ||
<Flex pt="120px" flexDirection="column" mx="loose"> | ||
<Box>Mnemonic: {mnemonic}</Box> | ||
<Box mt="loose">MnemonicEncryptedHex: {privateKey}</Box> | ||
<Box mt="loose">Private key: {privateKey}</Box> | ||
<Box mt="loose">Base58: {base58}</Box> | ||
<Box mt="loose">Salt: {(keys as any).salt}</Box> | ||
<Box mt="loose">Password: {(keys as any).password}</Box> | ||
<Box mt="loose">Stretched Key: {(keys as any).derivedEncryptionKey}</Box> | ||
</Flex> | ||
<HomeLayout | ||
balanceCard={<BalanceCard balance="124,000.1003 STX" />} | ||
transactionList={<TransactionList txs={[]} />} | ||
stackingPromoCard={<StackingPromoCard />} | ||
stackingRewardCard={ | ||
<StackingRewardCard lifetime="0.0281 Bitcoin" lastCycle="0.000383 Bitcoin" /> | ||
} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.