From d52aa74818db11de8bdc91186bd1eed3191e2df2 Mon Sep 17 00:00:00 2001 From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> Date: Tue, 28 Feb 2023 14:59:47 +0100 Subject: [PATCH] simplify web app & connect to provider --- apps/vite/package.json | 1 - apps/vite/src/app.tsx | 164 +++++++++++++++------------------------ apps/vite/styles/app.css | 1 + 3 files changed, 63 insertions(+), 103 deletions(-) diff --git a/apps/vite/package.json b/apps/vite/package.json index e7298642..ce5345f2 100644 --- a/apps/vite/package.json +++ b/apps/vite/package.json @@ -11,7 +11,6 @@ "@status-im/components": "*", "@status-im/icons": "*", "@tamagui/core": "1.0.15", - "expo-blur": "~12.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-native-web": "^0.18.6" diff --git a/apps/vite/src/app.tsx b/apps/vite/src/app.tsx index 9ce7e2c5..955a2b0a 100644 --- a/apps/vite/src/app.tsx +++ b/apps/vite/src/app.tsx @@ -1,4 +1,4 @@ -import { cloneElement, useRef, useState } from 'react' +import { useMemo, useRef, useState } from 'react' import { Composer, @@ -6,120 +6,80 @@ import { Sidebar, SidebarMembers, Topbar, + useAppDispatch, + useAppState, } from '@status-im/components' import { useBlur } from '@status-im/components/hooks' -import { COMMUNITIES } from '@status-im/components/src/sidebar/mock-data' -import { Stack, styled, TamaguiProvider } from '@tamagui/core' -import { AnimatePresence } from 'tamagui' +import { CHANNEL_GROUPS } from '@status-im/components/src/sidebar/mock-data' -import tamaguiConfig from '../tamagui.config' - -import type { ReactElement, ReactNode } from 'react' - -type ThemeVars = 'light' | 'dark' - -const AnimatableDrawer = styled(Stack, { - variants: { - fromRight: { - true: { - x: 500, - width: 0, - }, - }, - fromLeft: { - true: { - x: 500, - width: 250, - }, - }, - }, -}) +const COMMUNITY = { + name: 'Rarible', + description: + 'Multichain community-centric NFT marketplace. Create, buy and sell your NFTs.', + membersCount: 123, + imageUrl: + 'https://images.unsplash.com/photo-1574786527860-f2e274867c91?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1764&q=80', +} function App() { - const [theme, setTheme] = useState('light') const [showMembers, setShowMembers] = useState(false) - const [selectedChannel, setSelectedChannel] = useState('welcome') - const refMessagesContainer = useRef(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( - cloneElement(COMMUNITIES[0].channels[0].icon as ReactElement, { - hasBackground: false, - }) - ) - - const onChannelPress = (id: string, icon?: ReactNode) => { - setSelectedChannel(id) - setIcon(icon) - } + const containerRef = useRef(null) const { shouldBlurTop, shouldBlurBottom } = useBlur({ - ref: refMessagesContainer, + ref: containerRef, }) - return ( - -
- -
- setShowMembers(show => !show)} - /> + const appState = useAppState() + const appDispatch = useAppDispatch() -
-
- -
-
- -
-
-
- - {showMembers && ( - - - - )} - + // TODO: This should change based on the URL + const selectedChannel = useMemo(() => { + for (const { channels } of CHANNEL_GROUPS) { + for (const channel of channels) { + if (channel.id === appState.channelId) { + return channel + } + } + } + }, [appState.channelId]) + + return ( +
+ - + +
+ setShowMembers(show => !show)} + /> + +
+
+ +
+
+ +
+
+
+ + {showMembers && ( +
+ +
+ )} +
) } diff --git a/apps/vite/styles/app.css b/apps/vite/styles/app.css index 944fc433..d944a747 100644 --- a/apps/vite/styles/app.css +++ b/apps/vite/styles/app.css @@ -40,6 +40,7 @@ body, } #content { + position: relative; overflow: auto; padding: 40px 0px 0px 0px; height: 100vh;