-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TW-1452: Redesign 'Receive' page (#1171)
* TW-1452 Redesign the 'Receive' page * TW-1452 Fix text color for a selected seed phrase verification pill * TW-1452 Remove unused variables * TW-1452 Remove unused variables * TW-1452 Remove an unused export * TW-1452 Update QR code style * TW-1452 Update font size calculation for 'initials' identicon * TW-1452 Fix navigation after an accounts modal is closed
- Loading branch information
1 parent
26e49fc
commit 9325498
Showing
24 changed files
with
446 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { memo, useEffect, useMemo, useRef } from 'react'; | ||
|
||
import QRCodeStyling, { Options } from 'qr-code-styling-2'; | ||
|
||
interface QRCodeProps { | ||
size: number; | ||
data: string; | ||
imageUri?: string; | ||
} | ||
|
||
export const QRCode = memo<QRCodeProps>(({ size, data, imageUri }) => { | ||
const internalSize = size * window.devicePixelRatio; | ||
|
||
const fullProps = useMemo<Options>( | ||
() => ({ | ||
width: internalSize, | ||
height: internalSize, | ||
data, | ||
margin: 0, | ||
qrOptions: { typeNumber: 0, mode: 'Byte', errorCorrectionLevel: 'Q' }, | ||
imageOptions: { hideBackgroundDots: true, imageSize: 0.6, margin: 12 }, | ||
dotsOptions: { type: 'dots', color: '#000000' }, | ||
backgroundOptions: { color: '#ffffff' }, | ||
image: imageUri, | ||
dotsOptionsHelper: { | ||
colorType: { single: true, gradient: false }, | ||
gradient: { linear: true, radial: false, color1: '#6a1a4c', color2: '#6a1a4c', rotation: '0' } | ||
}, | ||
cornersSquareOptions: { type: 'extra-rounded', color: '#000000' }, | ||
cornersSquareOptionsHelper: { | ||
colorType: { single: true, gradient: false }, | ||
gradient: { linear: true, radial: false, color1: '#000000', color2: '#000000', rotation: '0' } | ||
}, | ||
cornersDotOptions: { type: 'square', color: '#000000' }, | ||
cornersDotOptionsHelper: { | ||
colorType: { single: true, gradient: false }, | ||
gradient: { linear: true, radial: false, color1: '#000000', color2: '#000000', rotation: '0' } | ||
}, | ||
backgroundOptionsHelper: { | ||
colorType: { single: true, gradient: false }, | ||
gradient: { linear: true, radial: false, color1: '#ffffff', color2: '#ffffff', rotation: '0' } | ||
} | ||
}), | ||
[data, imageUri, internalSize] | ||
); | ||
const styling = useMemo(() => new QRCodeStyling(fullProps), [fullProps]); | ||
const canvasRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
if (canvasRef.current) { | ||
styling.append(canvasRef.current); | ||
} | ||
}, [styling]); | ||
|
||
useEffect(() => { | ||
styling.update(fullProps); | ||
}, [fullProps, styling]); | ||
|
||
return ( | ||
<div ref={canvasRef} style={{ width: internalSize, height: internalSize, zoom: String(1 / devicePixelRatio) }} /> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useCallback, useMemo } from 'react'; | ||
|
||
import { HistoryAction, navigate, useLocation } from 'lib/woozie'; | ||
|
||
export const useModalOpenSearchParams = (paramName: string) => { | ||
const { search, pathname } = useLocation(); | ||
const isOpen = useMemo(() => { | ||
const usp = new URLSearchParams(search); | ||
|
||
return Boolean(usp.get(paramName)); | ||
}, [paramName, search]); | ||
const setModalState = useCallback( | ||
(newState: boolean) => { | ||
const newUsp = new URLSearchParams(search); | ||
if (newState) { | ||
newUsp.set(paramName, 'true'); | ||
} else { | ||
newUsp.delete(paramName); | ||
} | ||
|
||
navigate({ search: newUsp.toString(), pathname }, HistoryAction.Replace); | ||
}, | ||
[search, pathname, paramName] | ||
); | ||
const openModal = useCallback(() => setModalState(true), [setModalState]); | ||
const closeModal = useCallback(() => setModalState(false), [setModalState]); | ||
|
||
return { isOpen, openModal, closeModal }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ReactNode, useEffect, useMemo } from 'react'; | ||
|
||
import { createRoot } from 'react-dom/client'; | ||
|
||
import useTippy, { UseTippyOptions } from 'lib/ui/useTippy'; | ||
|
||
export const useRichFormatTooltip = <T extends HTMLElement>( | ||
props: Omit<UseTippyOptions, 'content'>, | ||
wrapperFactory: () => HTMLElement, | ||
content: ReactNode | ||
) => { | ||
const tippyProps = useMemo( | ||
() => ({ | ||
...props, | ||
content: wrapperFactory() | ||
}), | ||
[props, wrapperFactory] | ||
); | ||
|
||
useEffect(() => { | ||
const root = createRoot(tippyProps.content); | ||
root.render(content); | ||
}, [tippyProps.content, content]); | ||
|
||
return useTippy<T>(tippyProps); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { memo } from 'react'; | ||
|
||
import clsx from 'clsx'; | ||
|
||
import { IconBase } from 'app/atoms'; | ||
import { AccountAvatar } from 'app/atoms/AccountAvatar'; | ||
import { ReactComponent as CompactDownIcon } from 'app/icons/base/compact_down.svg'; | ||
import { StoredAccount } from 'lib/temple/types'; | ||
|
||
interface AccountDropdownHeaderProps { | ||
account: StoredAccount; | ||
onClick: EmptyFn; | ||
className?: string; | ||
} | ||
|
||
export const AccountDropdownHeader = memo<AccountDropdownHeaderProps>(({ account, className, onClick }) => ( | ||
<div | ||
className={clsx( | ||
className, | ||
'flex items-center gap-x-2 p-3 rounded-lg shadow-center border-0.5 border-transparent hover:border-lines', | ||
'cursor-pointer' | ||
)} | ||
onClick={onClick} | ||
> | ||
<AccountAvatar seed={account.id} size={24} borderColor="secondary" /> | ||
<span className="flex-1 text-font-medium-bold">{account.name}</span> | ||
<IconBase Icon={CompactDownIcon} size={16} className="text-primary" /> | ||
</div> | ||
)); |
Oops, something went wrong.