Merge pull request #9 from nimbus-gui/rd.make-a-page-flow-for-nodes

Make a page flow for nodes
This commit is contained in:
Radoslav Dimchev 2023-08-22 13:51:26 +03:00 committed by GitHub
commit 5cbdbdcc24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 64 additions and 6 deletions

View File

@ -36,6 +36,7 @@ const router = createBrowserRouter([
}, },
{ path: '/create-local-node', element: <CreateLocalNodePage /> }, { path: '/create-local-node', element: <CreateLocalNodePage /> },
]) ])
function App() { function App() {
return ( return (
<ReduxProvider store={store}> <ReduxProvider store={store}>

View File

@ -2,19 +2,52 @@ import { Tag } from '@status-im/components'
import { XStack } from 'tamagui' import { XStack } from 'tamagui'
import './TagContainer.css' import './TagContainer.css'
import { ConnectionIcon, AddSmallIcon, SwapIcon } from '@status-im/icons' import { ConnectionIcon, AddSmallIcon, SwapIcon } from '@status-im/icons'
import { useNavigate } from 'react-router'
type TagContainerProps = { type TagContainerProps = {
selectedTag: 'pair' | 'create' | 'connect' selectedTag: 'pair' | 'create' | 'connect'
} }
const TagContainer = ({ selectedTag }: TagContainerProps) => { const TagContainer = ({ selectedTag }: TagContainerProps) => {
const navigate = useNavigate()
const onPressConnect = () => {
navigate('/connect-device')
}
const onPressPair = () => {
navigate('/pair-device')
}
const onPressCreate = () => {
navigate('/create-local-node')
}
return ( return (
<XStack space={'$2'} alignItems="center" className="tag-container"> <XStack space={'$2'} alignItems="center" className="tag-container">
{selectedTag === 'connect' ? ( {selectedTag === 'connect' ? (
<Tag selected={selectedTag === 'connect'} icon={ConnectionIcon} label="Connect" size={32} /> <Tag
selected={selectedTag === 'connect'}
icon={ConnectionIcon}
label="Connect"
size={32}
onPress={onPressConnect}
/>
) : null} ) : null}
<Tag selected={selectedTag === 'pair'} icon={SwapIcon} label="Pair" size={32} /> <Tag
<Tag selected={selectedTag === 'create'} icon={AddSmallIcon} label="Create" size={32} /> selected={selectedTag === 'pair'}
icon={SwapIcon}
label="Pair"
size={32}
onPress={onPressPair}
/>
<Tag
selected={selectedTag === 'create'}
icon={AddSmallIcon}
label="Create"
size={32}
onPress={onPressCreate}
/>
</XStack> </XStack>
) )
} }

View File

@ -1,6 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react' import type { Meta, StoryObj } from '@storybook/react'
import ConnectDevicePage from './ConnectDevicePage' import ConnectDevicePage from './ConnectDevicePage'
import { withRouter } from 'storybook-addon-react-router-v6'
const meta = { const meta = {
title: 'Pages/ConnectDevicePage', title: 'Pages/ConnectDevicePage',
@ -10,6 +11,7 @@ const meta = {
}, },
tags: ['autodocs'], tags: ['autodocs'],
argTypes: {}, argTypes: {},
decorators: [withRouter],
} satisfies Meta<typeof ConnectDevicePage> } satisfies Meta<typeof ConnectDevicePage>
export default meta export default meta

View File

@ -1,6 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react' import type { Meta, StoryObj } from '@storybook/react'
import CreateLocalNodePage from './CreateLocalNodePage' import CreateLocalNodePage from './CreateLocalNodePage'
import { withRouter } from 'storybook-addon-react-router-v6'
const meta = { const meta = {
title: 'Pages/CreateLocalNodePage', title: 'Pages/CreateLocalNodePage',
@ -10,6 +11,7 @@ const meta = {
}, },
tags: ['autodocs'], tags: ['autodocs'],
argTypes: {}, argTypes: {},
decorators: [withRouter],
} satisfies Meta<typeof CreateLocalNodePage> } satisfies Meta<typeof CreateLocalNodePage>
export default meta export default meta

View File

@ -1,4 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react' import type { Meta, StoryObj } from '@storybook/react'
import { withRouter } from 'storybook-addon-react-router-v6'
import LandingPage from './LandingPage' import LandingPage from './LandingPage'
@ -10,6 +11,7 @@ const meta = {
}, },
tags: ['autodocs'], tags: ['autodocs'],
argTypes: {}, argTypes: {},
decorators: [withRouter],
} satisfies Meta<typeof LandingPage> } satisfies Meta<typeof LandingPage>
export default meta export default meta

View File

@ -6,8 +6,15 @@ import NimbusLogo from '../../components/Logos/NimbusLogo'
import { NodeIcon } from '@status-im/icons' import { NodeIcon } from '@status-im/icons'
import { Button as StatusButton, Text } from '@status-im/components' import { Button as StatusButton, Text } from '@status-im/components'
import QuickStartBar from '../../components/General/QuickStartBar/QuickStartBar' import QuickStartBar from '../../components/General/QuickStartBar/QuickStartBar'
import { useNavigate } from 'react-router'
function LandingPage() { function LandingPage() {
const navigate = useNavigate()
const getStartedHanlder = () => {
navigate('/pair-device')
}
return ( return (
<> <>
<PageWrapperShadow rightImageSrc="./background-images/landing-page-bg.png"> <PageWrapperShadow rightImageSrc="./background-images/landing-page-bg.png">
@ -25,7 +32,9 @@ function LandingPage() {
</YStack> </YStack>
<XStack> <XStack>
<StatusButton icon={<NodeIcon size={20} />}>Get Started</StatusButton> <StatusButton icon={<NodeIcon size={20} />} onPress={getStartedHanlder}>
Get Started
</StatusButton>
</XStack> </XStack>
</YStack> </YStack>
</PageWrapperShadow> </PageWrapperShadow>

View File

@ -1,6 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react' import type { Meta, StoryObj } from '@storybook/react'
import SyncStatus from './SyncStatus' import SyncStatus from './SyncStatus'
import { withRouter } from 'storybook-addon-react-router-v6'
const meta = { const meta = {
title: 'Pair Device/SyncStatus', title: 'Pair Device/SyncStatus',
@ -10,6 +11,7 @@ const meta = {
}, },
tags: ['autodocs'], tags: ['autodocs'],
argTypes: {}, argTypes: {},
decorators: [withRouter],
} satisfies Meta<typeof SyncStatus> } satisfies Meta<typeof SyncStatus>
export default meta export default meta

View File

@ -7,6 +7,7 @@ import Icon from '../../components/General/Icon'
import ConnectionIcon from '/icons/connection.svg' import ConnectionIcon from '/icons/connection.svg'
import { convertSecondsToTimerFormat } from '../../utilities' import { convertSecondsToTimerFormat } from '../../utilities'
import { RefreshIcon } from '@status-im/icons' import { RefreshIcon } from '@status-im/icons'
import { useNavigate } from 'react-router'
type SyncStatusProps = { type SyncStatusProps = {
isPairing: boolean isPairing: boolean
@ -20,11 +21,13 @@ const SyncStatus = ({
changeSetIsAwaitingPairing, changeSetIsAwaitingPairing,
}: SyncStatusProps) => { }: SyncStatusProps) => {
const [elapsedTime, setElapsedTime] = useState(0) const [elapsedTime, setElapsedTime] = useState(0)
const navigate = useNavigate()
const resetTimer = () => { const resetTimer = () => {
setElapsedTime(0) setElapsedTime(0)
changeSetIsAwaitingPairing(false) changeSetIsAwaitingPairing(false)
} }
useEffect(() => { useEffect(() => {
let timer: ReturnType<typeof setTimeout> let timer: ReturnType<typeof setTimeout>
@ -42,7 +45,11 @@ const SyncStatus = ({
return () => clearInterval(timer) return () => clearInterval(timer)
}, [isPairing, elapsedTime]) }, [isPairing, elapsedTime])
const timer = convertSecondsToTimerFormat(elapsedTime) // Assuming you've imported the convertSecondsToTimerFormat function const timer = convertSecondsToTimerFormat(elapsedTime)
const connectViaIpHandler = () => {
navigate('/connect-device');
};
return ( return (
<YStack space={'$2'}> <YStack space={'$2'}>
@ -84,7 +91,7 @@ const SyncStatus = ({
)} )}
{isAwaitingPairing && ( {isAwaitingPairing && (
<XStack> <XStack>
<Button icon={<Icon src={ConnectionIcon} />} size={40}> <Button icon={<Icon src={ConnectionIcon} />} size={40} onPress={connectViaIpHandler} >
Connect via IP Connect via IP
</Button> </Button>
</XStack> </XStack>