simplify web app & connect to provider
This commit is contained in:
parent
838180c9d5
commit
5b802b1d15
|
@ -11,7 +11,6 @@
|
||||||
"@status-im/components": "*",
|
"@status-im/components": "*",
|
||||||
"@status-im/icons": "*",
|
"@status-im/icons": "*",
|
||||||
"@tamagui/core": "1.0.15",
|
"@tamagui/core": "1.0.15",
|
||||||
"expo-blur": "~12.0.1",
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-native-web": "^0.18.6"
|
"react-native-web": "^0.18.6"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { cloneElement, useRef, useState } from 'react'
|
import { useMemo, useRef, useState } from 'react'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Composer,
|
Composer,
|
||||||
|
@ -6,120 +6,80 @@ import {
|
||||||
Sidebar,
|
Sidebar,
|
||||||
SidebarMembers,
|
SidebarMembers,
|
||||||
Topbar,
|
Topbar,
|
||||||
|
useAppDispatch,
|
||||||
|
useAppState,
|
||||||
} from '@status-im/components'
|
} from '@status-im/components'
|
||||||
import { useBlur } from '@status-im/components/hooks'
|
import { useBlur } from '@status-im/components/hooks'
|
||||||
import { COMMUNITIES } from '@status-im/components/src/sidebar/mock-data'
|
import { CHANNEL_GROUPS } from '@status-im/components/src/sidebar/mock-data'
|
||||||
import { Stack, styled, TamaguiProvider } from '@tamagui/core'
|
|
||||||
import { AnimatePresence } from 'tamagui'
|
|
||||||
|
|
||||||
import tamaguiConfig from '../tamagui.config'
|
const COMMUNITY = {
|
||||||
|
name: 'Rarible',
|
||||||
import type { ReactElement, ReactNode } from 'react'
|
description:
|
||||||
|
'Multichain community-centric NFT marketplace. Create, buy and sell your NFTs.',
|
||||||
type ThemeVars = 'light' | 'dark'
|
membersCount: 123,
|
||||||
|
imageUrl:
|
||||||
const AnimatableDrawer = styled(Stack, {
|
'https://images.unsplash.com/photo-1574786527860-f2e274867c91?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1764&q=80',
|
||||||
variants: {
|
}
|
||||||
fromRight: {
|
|
||||||
true: {
|
|
||||||
x: 500,
|
|
||||||
width: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
fromLeft: {
|
|
||||||
true: {
|
|
||||||
x: 500,
|
|
||||||
width: 250,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [theme, setTheme] = useState<ThemeVars>('light')
|
|
||||||
const [showMembers, setShowMembers] = useState(false)
|
const [showMembers, setShowMembers] = useState(false)
|
||||||
|
|
||||||
const [selectedChannel, setSelectedChannel] = useState<string>('welcome')
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
const refMessagesContainer = useRef<HTMLDivElement>(null)
|
|
||||||
|
|
||||||
// TODO - this is a hack to get the icon to show up in the topbar when a channel is selected on mount
|
|
||||||
const [icon, setIcon] = useState<ReactNode>(
|
|
||||||
cloneElement(COMMUNITIES[0].channels[0].icon as ReactElement, {
|
|
||||||
hasBackground: false,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
const onChannelPress = (id: string, icon?: ReactNode) => {
|
|
||||||
setSelectedChannel(id)
|
|
||||||
setIcon(icon)
|
|
||||||
}
|
|
||||||
|
|
||||||
const { shouldBlurTop, shouldBlurBottom } = useBlur({
|
const { shouldBlurTop, shouldBlurBottom } = useBlur({
|
||||||
ref: refMessagesContainer,
|
ref: containerRef,
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
const appState = useAppState()
|
||||||
<TamaguiProvider config={tamaguiConfig} defaultTheme={'light'}>
|
const appDispatch = useAppDispatch()
|
||||||
<div id="app">
|
|
||||||
<div id="sidebar" style={{ zIndex: 200 }}>
|
|
||||||
<Sidebar
|
|
||||||
name="Rarible"
|
|
||||||
description="Multichain community-centric NFT marketplace. Create, buy and sell your NFTs."
|
|
||||||
membersCount={123}
|
|
||||||
onChannelPress={onChannelPress}
|
|
||||||
selectedChannel={selectedChannel}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<main id="main">
|
|
||||||
<Topbar
|
|
||||||
isBlurred={shouldBlurTop}
|
|
||||||
backgroundColor="$blurBackground"
|
|
||||||
icon={
|
|
||||||
icon &&
|
|
||||||
cloneElement(icon as ReactElement, { hasBackground: false })
|
|
||||||
}
|
|
||||||
title={`#${selectedChannel}`}
|
|
||||||
description="Share random funny stuff with the community. Play nice."
|
|
||||||
membersVisisble={showMembers}
|
|
||||||
onMembersPress={() => setShowMembers(show => !show)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div
|
// TODO: This should change based on the URL
|
||||||
id="content"
|
const selectedChannel = useMemo(() => {
|
||||||
ref={refMessagesContainer}
|
for (const { channels } of CHANNEL_GROUPS) {
|
||||||
style={{ position: 'relative' }}
|
for (const channel of channels) {
|
||||||
>
|
if (channel.id === appState.channelId) {
|
||||||
<div id="messages">
|
return channel
|
||||||
<Messages />
|
}
|
||||||
</div>
|
}
|
||||||
<div id="composer">
|
}
|
||||||
<Composer isBlurred={shouldBlurBottom} reply={false} />
|
}, [appState.channelId])
|
||||||
</div>
|
|
||||||
</div>
|
return (
|
||||||
</main>
|
<div id="app">
|
||||||
<AnimatePresence enterVariant="fromRight" exitVariant="fromLeft">
|
<div id="sidebar" style={{ zIndex: 200 }}>
|
||||||
{showMembers && (
|
<Sidebar
|
||||||
<AnimatableDrawer
|
community={COMMUNITY}
|
||||||
id="members"
|
selectedChannelId={appState.channelId}
|
||||||
key="members"
|
onChannelPress={channelId =>
|
||||||
animation={[
|
appDispatch({ type: 'set-channel', channelId })
|
||||||
'fast',
|
}
|
||||||
{
|
/>
|
||||||
opacity: {
|
|
||||||
overshootClamping: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
enterStyle={{ opacity: 0 }}
|
|
||||||
exitStyle={{ opacity: 0 }}
|
|
||||||
opacity={1}
|
|
||||||
>
|
|
||||||
<SidebarMembers />
|
|
||||||
</AnimatableDrawer>
|
|
||||||
)}
|
|
||||||
</AnimatePresence>
|
|
||||||
</div>
|
</div>
|
||||||
</TamaguiProvider>
|
|
||||||
|
<main id="main">
|
||||||
|
<Topbar
|
||||||
|
blur={shouldBlurTop}
|
||||||
|
channel={selectedChannel}
|
||||||
|
membersVisisble={showMembers}
|
||||||
|
onMembersPress={() => setShowMembers(show => !show)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div id="content" ref={containerRef}>
|
||||||
|
<div id="messages">
|
||||||
|
<Messages />
|
||||||
|
</div>
|
||||||
|
<div id="composer">
|
||||||
|
<Composer blur={shouldBlurBottom} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
{showMembers && (
|
||||||
|
<div id="members">
|
||||||
|
<SidebarMembers />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ body,
|
||||||
}
|
}
|
||||||
|
|
||||||
#content {
|
#content {
|
||||||
|
position: relative;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding: 40px 0px 0px 0px;
|
padding: 40px 0px 0px 0px;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
|
Loading…
Reference in New Issue