From 1757f62b34fd3b60fb79f3b9db3f3518917b7119 Mon Sep 17 00:00:00 2001 From: marcelines Date: Fri, 10 Feb 2023 16:25:13 +0000 Subject: [PATCH] Add blur and IconButton variants (#340) * feat: add blurview to topbar and composer with scroll position * fix: icon button component and adds scrolls var position for the top bar * fix: changes from review --- apps/mobile/app.json | 2 +- apps/vite/package.json | 1 + apps/vite/src/app.tsx | 40 +++- apps/vite/styles/app.css | 8 +- eas.json | 28 +++ packages/components/hooks/index.ts | 2 + packages/components/hooks/use-blur.ts | 68 +++++++ packages/components/hooks/use-throttle.ts | 38 ++++ .../components/src/accordion/accordion.tsx | 1 + .../src/accordion/accordionItem.tsx | 1 + packages/components/src/composer/composer.tsx | 109 ++++++++--- packages/components/src/divider/divider.tsx | 2 +- .../src/icon-button/icon-button.tsx | 175 ++++++++++++++---- packages/components/src/input/input.tsx | 61 +++--- .../src/messages/components/reactions.tsx | 2 - packages/components/src/messages/index.tsx | 16 ++ packages/components/src/sidebar/sidebar.tsx | 5 +- packages/components/src/tamagui.config.ts | 8 +- packages/components/src/themes.ts | 50 +++++ packages/components/src/topbar/topbar.tsx | 131 ++++++++----- packages/icons/12/add-icon.tsx | 2 +- packages/icons/12/add-reaction-icon.tsx | 2 +- packages/icons/12/alert-icon.tsx | 2 +- packages/icons/12/arrow-down-icon.tsx | 2 +- packages/icons/12/arrow-right-icon.tsx | 2 +- packages/icons/12/arrow-up-icon.tsx | 2 +- packages/icons/12/block-icon.tsx | 4 +- packages/icons/12/camera-icon.tsx | 2 +- packages/icons/12/cards-icon.tsx | 2 +- packages/icons/12/check-icon.tsx | 2 +- packages/icons/12/check-large-icon.tsx | 2 +- packages/icons/12/chevron-bottom-icon.tsx | 2 +- packages/icons/12/chevron-left-icon.tsx | 2 +- packages/icons/12/chevron-right-icon.tsx | 2 +- packages/icons/12/chevron-top-icon.tsx | 2 +- packages/icons/12/close-icon.tsx | 2 +- packages/icons/12/color-icon.tsx | 2 +- packages/icons/12/communities-icon.tsx | 2 +- packages/icons/12/contact-icon.tsx | 6 +- packages/icons/12/copy-icon.tsx | 2 +- packages/icons/12/delivered-icon.tsx | 2 +- packages/icons/12/dropdown-icon.tsx | 2 +- packages/icons/12/edit-icon.tsx | 2 +- packages/icons/12/gas-icon.tsx | 2 +- packages/icons/12/hold-icon.tsx | 4 +- packages/icons/12/info-1-icon.tsx | 2 +- packages/icons/12/info-icon.tsx | 4 +- packages/icons/12/jump-to-icon.tsx | 2 +- packages/icons/12/lightning-icon.tsx | 2 +- packages/icons/12/list-icon.tsx | 2 +- packages/icons/12/loading-icon.tsx | 2 +- packages/icons/12/locked-icon.tsx | 2 +- packages/icons/12/mention-icon.tsx | 2 +- packages/icons/12/more-icon.tsx | 2 +- packages/icons/12/negative-icon.tsx | 4 +- packages/icons/12/notification-icon.tsx | 4 +- packages/icons/12/pause-icon.tsx | 2 +- packages/icons/12/pending-icon.tsx | 4 +- packages/icons/12/pick-icon.tsx | 2 +- packages/icons/12/placeholder-icon.tsx | 2 +- packages/icons/12/play-icon.tsx | 2 +- packages/icons/12/positive-icon.tsx | 4 +- packages/icons/12/progress-icon.tsx | 2 +- packages/icons/12/pullup-icon.tsx | 2 +- packages/icons/12/remove-icon.tsx | 4 +- packages/icons/12/search-icon.tsx | 2 +- packages/icons/12/send-message-icon.tsx | 4 +- packages/icons/12/sent-icon.tsx | 2 +- packages/icons/12/timeout-icon.tsx | 2 +- packages/icons/12/total-members-icon.tsx | 2 +- packages/icons/12/trash-icon.tsx | 2 +- packages/icons/12/unlocked-icon.tsx | 2 +- packages/icons/12/untrustworthy-icon.tsx | 4 +- packages/icons/12/verified-1-icon.tsx | 2 +- packages/icons/12/verified-icon.tsx | 4 +- packages/icons/12/whistle-icon.tsx | 2 +- packages/icons/16/add-icon.tsx | 2 +- packages/icons/16/add-user-icon.tsx | 2 +- packages/icons/16/alert-icon.tsx | 2 +- packages/icons/16/arrow-down-icon.tsx | 2 +- packages/icons/16/arrow-right-icon.tsx | 2 +- packages/icons/16/calendar-icon.tsx | 2 +- packages/icons/16/check-circle-icon.tsx | 2 +- packages/icons/16/chevron-down-icon.tsx | 2 +- packages/icons/16/chevron-left-icon.tsx | 2 +- packages/icons/16/chevron-right-icon.tsx | 2 +- packages/icons/16/chevron-top-icon.tsx | 2 +- packages/icons/16/close-icon.tsx | 2 +- packages/icons/16/connection-icon.tsx | 6 +- packages/icons/16/contact-book-icon.tsx | 2 +- packages/icons/16/delete-icon.tsx | 2 +- packages/icons/16/email-icon.tsx | 2 +- packages/icons/16/forward-icon.tsx | 6 +- packages/icons/16/gif-icon.tsx | 2 +- packages/icons/16/group-icon.tsx | 2 +- packages/icons/16/history-icon.tsx | 6 +- packages/icons/16/info-icon.tsx | 2 +- packages/icons/16/lightning-icon.tsx | 2 +- packages/icons/16/locked-icon.tsx | 2 +- packages/icons/16/mention-icon.tsx | 2 +- packages/icons/16/more-icon.tsx | 2 +- packages/icons/16/mute-icon.tsx | 2 +- packages/icons/16/negative-icon.tsx | 6 +- packages/icons/16/notification-icon.tsx | 4 +- packages/icons/16/pin-icon.tsx | 2 +- packages/icons/16/placeholder-icon.tsx | 2 +- packages/icons/16/positive-icon.tsx | 6 +- packages/icons/16/privacy-icon.tsx | 4 +- packages/icons/16/progress-icon.tsx | 2 +- packages/icons/16/remove-user-icon.tsx | 2 +- packages/icons/16/sad-icon.tsx | 2 +- packages/icons/16/stickers-icon.tsx | 2 +- packages/icons/16/unlocked-icon.tsx | 2 +- packages/icons/16/unmute-icon.tsx | 2 +- packages/icons/16/world-icon.tsx | 4 +- packages/icons/20/account-number-icon.tsx | 2 +- packages/icons/20/active-member-icon.tsx | 2 +- packages/icons/20/activity-center-icon.tsx | 2 +- packages/icons/20/add-icon.tsx | 2 +- packages/icons/20/add-reaction-icon.tsx | 2 +- packages/icons/20/add-small-icon.tsx | 2 +- packages/icons/20/add-token-icon.tsx | 2 +- packages/icons/20/add-user-icon.tsx | 2 +- packages/icons/20/alert-icon.tsx | 2 +- packages/icons/20/alphabetically-icon.tsx | 2 +- packages/icons/20/android-icon.tsx | 2 +- packages/icons/20/anonymous-icon.tsx | 4 +- packages/icons/20/arrow-down-icon.tsx | 2 +- packages/icons/20/arrow-left-icon.tsx | 2 +- packages/icons/20/arrow-right-icon.tsx | 2 +- packages/icons/20/arrow-up-icon.tsx | 2 +- packages/icons/20/attach-icon.tsx | 2 +- packages/icons/20/audio-icon.tsx | 2 +- packages/icons/20/automatic-icon.tsx | 4 +- packages/icons/20/block-icon.tsx | 2 +- packages/icons/20/bold-icon.tsx | 2 +- packages/icons/20/bridge-icon.tsx | 2 +- packages/icons/20/browser-icon.tsx | 2 +- packages/icons/20/bullet-icon.tsx | 2 +- packages/icons/20/bullet-list-icon.tsx | 2 +- packages/icons/20/buy-icon.tsx | 2 +- packages/icons/20/camera-icon.tsx | 2 +- packages/icons/20/card-view-icon.tsx | 2 +- packages/icons/20/centre-align-icon.tsx | 2 +- packages/icons/20/chatkey-icon.tsx | 2 +- packages/icons/20/check-icon.tsx | 2 +- packages/icons/20/chevron-down-icon.tsx | 2 +- packages/icons/20/chevron-left-icon.tsx | 2 +- packages/icons/20/chevron-right-icon.tsx | 2 +- packages/icons/20/chevron-up-icon.tsx | 2 +- packages/icons/20/chevrons-left-icon.tsx | 2 +- packages/icons/20/chevrons-right-icon.tsx | 2 +- packages/icons/20/clear-icon.tsx | 2 +- packages/icons/20/close-icon.tsx | 2 +- packages/icons/20/code-block-icon.tsx | 2 +- packages/icons/20/code-icon.tsx | 2 +- packages/icons/20/collapse-icon.tsx | 4 +- packages/icons/20/colour-pick-icon.tsx | 2 +- packages/icons/20/communities-icon.tsx | 2 +- packages/icons/20/connection-icon.tsx | 6 +- packages/icons/20/contact-book-icon.tsx | 2 +- packages/icons/20/contact-icon.tsx | 10 +- packages/icons/20/copy-icon.tsx | 2 +- packages/icons/20/correct-icon.tsx | 6 +- packages/icons/20/crown-icon.tsx | 2 +- packages/icons/20/customize-icon.tsx | 2 +- packages/icons/20/dark-icon.tsx | 4 +- packages/icons/20/data-usage-icon.tsx | 2 +- packages/icons/20/delete-icon.tsx | 2 +- packages/icons/20/desktop-icon.tsx | 2 +- packages/icons/20/download-icon.tsx | 2 +- packages/icons/20/dropdown-icon.tsx | 2 +- packages/icons/20/duration-icon.tsx | 2 +- packages/icons/20/edit-icon.tsx | 2 +- packages/icons/20/email-icon.tsx | 2 +- packages/icons/20/expand-icon.tsx | 4 +- packages/icons/20/external-icon.tsx | 2 +- packages/icons/20/face-id-icon.tsx | 2 +- packages/icons/20/favourite-icon.tsx | 2 +- packages/icons/20/file-icon.tsx | 2 +- packages/icons/20/flag-icon.tsx | 2 +- packages/icons/20/flash-icon.tsx | 2 +- packages/icons/20/flash-off-icon.tsx | 2 +- packages/icons/20/flashlight-off-icon.tsx | 2 +- packages/icons/20/flashlight-on-icon.tsx | 2 +- packages/icons/20/flip-icon.tsx | 4 +- packages/icons/20/folder-icon.tsx | 2 +- packages/icons/20/format-icon.tsx | 2 +- packages/icons/20/forward-icon.tsx | 2 +- packages/icons/20/friend-icon.tsx | 2 +- packages/icons/20/gas-icon.tsx | 2 +- packages/icons/20/gif-icon.tsx | 2 +- packages/icons/20/globe-icon.tsx | 2 +- packages/icons/20/hashtag-1-icon.tsx | 2 +- packages/icons/20/hashtag-icon.tsx | 2 +- packages/icons/20/heart-icon.tsx | 2 +- packages/icons/20/help-icon.tsx | 2 +- packages/icons/20/hide-icon.tsx | 2 +- packages/icons/20/history-icon.tsx | 6 +- packages/icons/20/hold-icon.tsx | 2 +- packages/icons/20/image-icon.tsx | 3 +- packages/icons/20/inactive-icon.tsx | 4 +- packages/icons/20/info-badge-icon.tsx | 6 +- packages/icons/20/info-icon.tsx | 2 +- packages/icons/20/italic-icon.tsx | 2 +- packages/icons/20/justify-icon.tsx | 2 +- packages/icons/20/key-icon.tsx | 6 +- packages/icons/20/keyboard-icon.tsx | 2 +- packages/icons/20/keycard-icon.tsx | 2 +- packages/icons/20/keycard-logo-icon.tsx | 2 +- packages/icons/20/laptop-icon.tsx | 2 +- packages/icons/20/left-align-icon.tsx | 2 +- packages/icons/20/light-icon.tsx | 6 +- packages/icons/20/link-icon.tsx | 2 +- packages/icons/20/list-view-icon.tsx | 2 +- packages/icons/20/loading-icon.tsx | 2 +- packages/icons/20/locked-icon.tsx | 2 +- packages/icons/20/log-out-icon.tsx | 2 +- packages/icons/20/members-icon.tsx | 2 +- packages/icons/20/mention-icon.tsx | 2 +- packages/icons/20/menu-icon.tsx | 2 +- packages/icons/20/messages-icon.tsx | 2 +- packages/icons/20/mobile-icon.tsx | 2 +- packages/icons/20/multi-profile-icon.tsx | 2 +- packages/icons/20/muted-icon.tsx | 2 +- packages/icons/20/mutual-contact-icon.tsx | 6 +- packages/icons/20/new-message-icon.tsx | 2 +- packages/icons/20/nft-icon.tsx | 2 +- packages/icons/20/node-icon.tsx | 2 +- packages/icons/20/notification-icon.tsx | 4 +- packages/icons/20/notifications-icon.tsx | 2 +- packages/icons/20/numbered-list-icon.tsx | 2 +- packages/icons/20/online-icon.tsx | 4 +- packages/icons/20/online-left-icon.tsx | 4 +- packages/icons/20/options-icon.tsx | 8 +- packages/icons/20/password-icon.tsx | 2 +- packages/icons/20/pause-icon.tsx | 2 +- packages/icons/20/pending-icon.tsx | 2 +- packages/icons/20/pending-user-icon.tsx | 2 +- packages/icons/20/pin-1-icon.tsx | 2 +- packages/icons/20/pin-icon.tsx | 2 +- packages/icons/20/placeholder-icon.tsx | 2 +- packages/icons/20/play-icon.tsx | 2 +- packages/icons/20/privacy-icon.tsx | 4 +- packages/icons/20/profile-icon.tsx | 2 +- packages/icons/20/pullup-icon.tsx | 2 +- packages/icons/20/qr-code-icon.tsx | 2 +- packages/icons/20/quarter-icon.tsx | 2 +- packages/icons/20/reaction-icon.tsx | 3 +- packages/icons/20/receive-icon.tsx | 2 +- packages/icons/20/receive-message-icon.tsx | 2 +- packages/icons/20/recent-icon.tsx | 2 +- packages/icons/20/refresh-icon.tsx | 4 +- packages/icons/20/remove-user-icon.tsx | 2 +- packages/icons/20/reply-icon.tsx | 2 +- packages/icons/20/reveal-icon.tsx | 2 +- packages/icons/20/revere-icon.tsx | 4 +- packages/icons/20/right-align-icon.tsx | 2 +- packages/icons/20/rotate-icon.tsx | 4 +- packages/icons/20/sad-icon.tsx | 2 +- packages/icons/20/save-icon.tsx | 2 +- packages/icons/20/scan-icon.tsx | 2 +- packages/icons/20/search-icon.tsx | 2 +- packages/icons/20/seed-icon.tsx | 2 +- packages/icons/20/send-icon.tsx | 2 +- packages/icons/20/send-message-icon.tsx | 2 +- packages/icons/20/settings-icon.tsx | 2 +- packages/icons/20/share-icon.tsx | 2 +- packages/icons/20/signature-icon.tsx | 2 +- packages/icons/20/sort-icon.tsx | 2 +- packages/icons/20/speed-icon.tsx | 2 +- packages/icons/20/status-icon.tsx | 2 +- packages/icons/20/stickers-icon.tsx | 2 +- packages/icons/20/stop-icon.tsx | 2 +- packages/icons/20/strikethrough-icon.tsx | 2 +- packages/icons/20/subscript-icon.tsx | 2 +- packages/icons/20/superscript-icon.tsx | 2 +- packages/icons/20/swap-icon.tsx | 2 +- packages/icons/20/syncing-icon.tsx | 2 +- packages/icons/20/toggle-icon.tsx | 2 +- packages/icons/20/token-icon.tsx | 2 +- packages/icons/20/unblock-icon.tsx | 2 +- packages/icons/20/underline-icon.tsx | 2 +- packages/icons/20/unlocked-icon.tsx | 2 +- packages/icons/20/unread-icon.tsx | 2 +- packages/icons/20/untrustworthy-icon.tsx | 6 +- packages/icons/20/up-to-date-icon.tsx | 2 +- packages/icons/20/verified-icon.tsx | 6 +- packages/icons/20/video-icon.tsx | 2 +- packages/icons/20/wallet-icon.tsx | 2 +- packages/icons/20/warning-icon.tsx | 2 +- packages/icons/20/world-icon.tsx | 2 +- packages/icons/react-native-svg.d.ts | 8 + packages/icons/tsconfig.json | 3 +- yarn.lock | 6 +- 295 files changed, 956 insertions(+), 485 deletions(-) create mode 100644 eas.json create mode 100644 packages/components/hooks/index.ts create mode 100644 packages/components/hooks/use-blur.ts create mode 100644 packages/components/hooks/use-throttle.ts create mode 100644 packages/icons/react-native-svg.d.ts diff --git a/apps/mobile/app.json b/apps/mobile/app.json index de9cecc..ce29ee9 100644 --- a/apps/mobile/app.json +++ b/apps/mobile/app.json @@ -2,7 +2,7 @@ "expo": { "name": "mobile", "slug": "status-poc", - "version": "1.0.2", + "version": "1.0.3", "orientation": "portrait", "icon": "./assets/icon.png", "userInterfaceStyle": "light", diff --git a/apps/vite/package.json b/apps/vite/package.json index ce5345f..e729864 100644 --- a/apps/vite/package.json +++ b/apps/vite/package.json @@ -11,6 +11,7 @@ "@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 e0853bc..b6d560f 100644 --- a/apps/vite/src/app.tsx +++ b/apps/vite/src/app.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { cloneElement, useRef, useState } from 'react' import { Composer, @@ -7,11 +7,15 @@ import { SidebarMembers, Topbar, } 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 tamaguiConfig from '../tamagui.config' +import type { ReactElement, ReactNode } from 'react' + type ThemeVars = 'light' | 'dark' const AnimatableDrawer = styled(Stack, { @@ -36,15 +40,28 @@ function App() { const [showMembers, setShowMembers] = useState(false) const [selectedChannel, setSelectedChannel] = useState('welcome') + const refMessagesContainer = useRef(null) - const onChannelPress = (id: string) => { + // 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 { shouldBlurTop, shouldBlurBottom } = useBlur({ + ref: refMessagesContainer, + }) + return (
-