-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow virtuoso to resize dynamically, ref #5242 #5289
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
import { BreakpointToken, token } from 'leather-styles/tokens'; | ||
|
||
function useMediaQuery(query: string) { | ||
const [matches, setMatches] = useState(false); | ||
|
||
useEffect(() => { | ||
const media = window.matchMedia(query); | ||
if (media.matches !== matches) { | ||
setMatches(media.matches); | ||
} | ||
pete-watters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const listener = () => setMatches(media.matches); | ||
window.addEventListener('resize', listener); | ||
return () => window.removeEventListener('resize', listener); | ||
}, [matches, query]); | ||
|
||
return matches; | ||
} | ||
|
||
export function useViewportMinWidth(viewport: BreakpointToken) { | ||
return useMediaQuery(`(min-width: ${token(`breakpoints.${viewport}`)})`); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,10 +97,12 @@ export function Container() { | |
const isLogoClickable = variant !== 'home' && !isRpcRoute(pathname); | ||
return ( | ||
<> | ||
<SwitchAccountDialog | ||
isShowing={isShowingSwitchAccount} | ||
onClose={() => setIsShowingSwitchAccount(false)} | ||
/> | ||
{isShowingSwitchAccount && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a mistake here in that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice catch! I believe problem with requests not being cancelled on close in |
||
<SwitchAccountDialog | ||
isShowing={isShowingSwitchAccount} | ||
onClose={() => setIsShowingSwitchAccount(false)} | ||
/> | ||
)} | ||
|
||
<InAppMessages /> | ||
<ContainerLayout | ||
|
@@ -171,7 +173,7 @@ export function Container() { | |
) : null | ||
} | ||
> | ||
<Outlet /> | ||
<Outlet context={{ isShowingSwitchAccount, setIsShowingSwitchAccount }} /> | ||
</ContainerLayout> | ||
</> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,8 @@ export function MessagePreviewBox({ message, hash }: MessageBoxProps) { | |
py="space.05" | ||
overflowX="auto" | ||
> | ||
{message.split(/\r?\n/).map(line => ( | ||
<styled.span key={line} textStyle="label.01"> | ||
{message.split(/\r?\n/).map((line, index) => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was throwing a duplicate keys error |
||
<styled.span key={`${line}_${index}`} textStyle="label.01"> | ||
{line} | ||
</styled.span> | ||
))} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { memo, useEffect } from 'react'; | ||
import { useEffect } from 'react'; | ||
import { Outlet } from 'react-router-dom'; | ||
|
||
import { Flex, Stack, styled } from 'leather-styles/jsx'; | ||
|
@@ -10,10 +10,13 @@ import { useAppDetails } from '@app/common/hooks/auth/use-app-details'; | |
import { RequesterFlag } from '@app/components/requester-flag'; | ||
import { ChooseAccountsList } from '@app/pages/choose-account/components/accounts'; | ||
import { useOnOriginTabClose } from '@app/routes/hooks/use-on-tab-closed'; | ||
import { useStacksAccounts } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks'; | ||
import { LogomarkIcon } from '@app/ui/icons/logomark-icon'; | ||
|
||
export const ChooseAccount = memo(() => { | ||
export function ChooseAccount() { | ||
const { url } = useAppDetails(); | ||
const accounts = useStacksAccounts(); | ||
const hasConnectedStacksAccounts = accounts.length > 0; | ||
|
||
const cancelAuthentication = useCancelAuthRequest(); | ||
|
||
|
@@ -34,12 +37,16 @@ export const ChooseAccount = memo(() => { | |
{url && <RequesterFlag requester={url.toString()} />} | ||
<LogomarkIcon width="248px" height="58px" /> | ||
<Stack gap="space.04"> | ||
<styled.h1 textStyle="heading.05">Choose an account to connect</styled.h1> | ||
<styled.h1 textStyle="heading.05"> | ||
{hasConnectedStacksAccounts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we prob need some more explanation of what's going on for users? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mica000 @markmhendrickson @fabric-8 : Do you have any input on what copy to use on this screen? Right now :
I've just made a small change so that in these cases we say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following up here a bit late: Ideally the user should be able to connect their wallet to any site with a Ledger account, regardless of whether they've connected with Ledger for BTC or STX. It seems that our legacy endpoint for connecting (used by Gamma and others) is not behaving this way. However, because it's legacy (and deprecated), we don't need to update it per se. I also assume that our newer endpoint ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for following up anyway 👍 |
||
? 'Choose an account to connect' | ||
: 'No connected accounts found'} | ||
</styled.h1> | ||
</Stack> | ||
</Stack> | ||
<ChooseAccountsList /> | ||
{hasConnectedStacksAccounts && <ChooseAccountsList />} | ||
</Flex> | ||
<Outlet /> | ||
</> | ||
); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { useState } from 'react'; | ||
import { Route, useNavigate } from 'react-router-dom'; | ||
import { Route, useNavigate, useOutletContext } from 'react-router-dom'; | ||
|
||
import { RouteUrls } from '@shared/route-urls'; | ||
|
||
|
@@ -9,7 +8,7 @@ import { useTotalBalance } from '@app/common/hooks/balance/use-total-balance'; | |
import { useOnMount } from '@app/common/hooks/use-on-mount'; | ||
import { ActivityList } from '@app/features/activity-list/activity-list'; | ||
import { AssetsList } from '@app/features/asset-list/asset-list'; | ||
import { SwitchAccountDialog } from '@app/features/dialogs/switch-account-dialog/switch-account-dialog'; | ||
import { SwitchAccountOutletContext } from '@app/features/dialogs/switch-account-dialog/switch-account-dialog'; | ||
import { FeedbackButton } from '@app/features/feedback-button/feedback-button'; | ||
import { homePageModalRoutes } from '@app/routes/app-routes'; | ||
import { ModalBackgroundWrapper } from '@app/routes/components/modal-background-wrapper'; | ||
|
@@ -22,9 +21,9 @@ import { AccountActions } from './components/account-actions'; | |
import { HomeTabs } from './components/home-tabs'; | ||
|
||
export function Home() { | ||
const [isShowingSwitchAccount, setIsShowingSwitchAccount] = useState(false); | ||
const { decodedAuthRequest } = useOnboardingState(); | ||
|
||
const { isShowingSwitchAccount, setIsShowingSwitchAccount } = | ||
useOutletContext<SwitchAccountOutletContext>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was investigating why we were re-rendering We were rendering it both inside of the main Now it stays at It needs to stay at that level so the settings menu can also trigger it |
||
const navigate = useNavigate(); | ||
const account = useCurrentStacksAccount(); | ||
|
||
|
@@ -49,12 +48,6 @@ export function Home() { | |
<AccountCard | ||
name={name} | ||
balance={totalUsdBalance} | ||
switchAccount={ | ||
<SwitchAccountDialog | ||
isShowing={isShowingSwitchAccount} | ||
onClose={() => setIsShowingSwitchAccount(false)} | ||
/> | ||
} | ||
toggleSwitchAccount={() => setIsShowingSwitchAccount(!isShowingSwitchAccount)} | ||
isLoadingBnsName={isLoadingBnsName} | ||
isLoadingBalance={isInitialLoading} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ import { Box } from 'leather-styles/jsx'; | |
|
||
import { useFilteredBitcoinAccounts } from '@app/store/accounts/blockchain/bitcoin/bitcoin.ledger'; | ||
import { useStacksAccounts } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks'; | ||
import { Dialog, getHeightOffset } from '@app/ui/components/containers/dialog/dialog'; | ||
import { Dialog } from '@app/ui/components/containers/dialog/dialog'; | ||
import { Header } from '@app/ui/components/containers/headers/header'; | ||
import { virtuosoHeight, virtuosoStyles } from '@app/ui/shared/virtuoso'; | ||
import { VirtuosoWrapper } from '@app/ui/components/virtuoso'; | ||
|
||
import { AccountListItem } from './account-list-item'; | ||
|
||
|
@@ -23,27 +23,31 @@ export function RecipientAccountsDialog() { | |
|
||
if (stacksAddressesNum === 0 && btcAddressesNum === 0) return null; | ||
const accountNum = stacksAddressesNum || btcAddressesNum; | ||
const maxAccountsShown = accountNum > 10 ? 10 : accountNum; | ||
|
||
return ( | ||
<Dialog header={<Header variant="dialog" title="My accounts" />} isShowing onClose={onGoBack}> | ||
<Virtuoso | ||
height={virtuosoHeight} | ||
style={{ | ||
...virtuosoStyles, | ||
height: `calc(${virtuosoHeight * maxAccountsShown}px + ${getHeightOffset(true, true)}px)`, | ||
}} | ||
itemContent={index => ( | ||
<Box key={index} my="space.05" px="space.05"> | ||
<AccountListItem | ||
stacksAccount={stacksAccounts[index]} | ||
onClose={onGoBack} | ||
index={index} | ||
/> | ||
</Box> | ||
)} | ||
totalCount={stacksAddressesNum || btcAddressesNum} | ||
/> | ||
<Dialog | ||
header={<Header variant="dialog" title="My accounts" />} | ||
isShowing | ||
onClose={onGoBack} | ||
wrapChildren={false} | ||
> | ||
<VirtuosoWrapper> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<Virtuoso | ||
style={{ | ||
height: '100%', | ||
}} | ||
itemContent={index => ( | ||
<Box key={index} my="space.05" px="space.05"> | ||
<AccountListItem | ||
stacksAccount={stacksAccounts[index]} | ||
onClose={onGoBack} | ||
index={index} | ||
/> | ||
</Box> | ||
)} | ||
totalCount={accountNum} | ||
/> | ||
</VirtuosoWrapper> | ||
</Dialog> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-adding this which I naively removed as I thought we didn't need it, however it's important as it alters the breakpoint on re-size