-
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-1547: [evm] Settings. DApps (#1214)
* TW-1547: [evm] Settings. DApps. Refactor * TW-1547: [evm] Settings. DApps. + Connections list. WIP * TW-1547: [evm] Settings. DApps. + Unlinking * TW-1547: [evm] Settings. DApps. Refactor * TW-1547: [evm] Settings. DApps. + Filtering by account * TW-1547: [evm] Settings. DApps. + Current connection * TW-1547: [evm] Settings. DApps. -- DApps page * TW-1547: [evm] Settings. DApps. Fix unit tests. Beacon * TW-1547: [evm] Settings. DApps. -- Old Settings * TW-1547: [evm] Settings. DApps. -- 'safari' * TW-1547: [evm] Settings. DApps. Refactor * TW-1547: [evm] Settings. DApps. + Icon plug * TW-1547: [evm] Settings. DApps. + Disabled 'Disconnect all' button
- Loading branch information
Showing
92 changed files
with
619 additions
and
1,841 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { CSSProperties, memo, useMemo } from 'react'; | ||
|
||
import clsx from 'clsx'; | ||
|
||
import { ImageStacked } from 'lib/ui/ImageStacked'; | ||
|
||
import { IconBase } from '../IconBase'; | ||
|
||
import { ReactComponent as PlugSvg } from './plug.svg'; | ||
|
||
interface DAppLogoProps { | ||
origin: string; | ||
size: number; | ||
className?: string; | ||
icon?: string; | ||
style?: CSSProperties; | ||
} | ||
|
||
const DAppLogo = memo<DAppLogoProps>(({ origin, size, icon, className, style }) => { | ||
const faviconSrc = useMemo(() => [icon ? icon : `${origin}/favicon.ico`], [origin, icon]); | ||
|
||
const styleMemo = useMemo(() => ({ width: size, height: size, ...style }), [style, size]); | ||
|
||
const placeholder = ( | ||
<div className={clsx('flex items-center bg-grey-4', className)} style={styleMemo}> | ||
<IconBase Icon={PlugSvg} size={16} className="mx-auto text-grey-1" /> | ||
</div> | ||
); | ||
|
||
return ( | ||
<ImageStacked | ||
sources={faviconSrc} | ||
alt={origin} | ||
style={styleMemo} | ||
className={className} | ||
loader={placeholder} | ||
fallback={placeholder} | ||
/> | ||
); | ||
}); | ||
|
||
export default DAppLogo; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
File renamed without changes.
File renamed without changes.
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, { FC, UIEventHandler, useCallback, useMemo, useRef } from 'react'; | ||
|
||
import clsx from 'clsx'; | ||
import { throttle } from 'lodash'; | ||
|
||
import { useSafeState } from 'lib/ui/hooks'; | ||
import { useWillUnmount } from 'lib/ui/hooks/useWillUnmount'; | ||
|
||
interface Props extends PropsWithChildren { | ||
className?: string; | ||
} | ||
|
||
export const ScrollView: FC<Props> = ({ className, children }) => { | ||
const [contentHiding, setContentHiding] = useSafeState(false); | ||
|
||
const ref = useRef<HTMLDivElement | nullish>(); | ||
|
||
const setContentHidingThrottled = useMemo(() => throttle((value: boolean) => setContentHiding(value), 300), []); | ||
|
||
const onScroll = useCallback<UIEventHandler<HTMLDivElement>>(event => { | ||
const node = event.currentTarget; | ||
|
||
setContentHidingThrottled(isContentHidingBelow(node)); | ||
}, []); | ||
|
||
const resizeObserver = useMemo( | ||
() => | ||
new ResizeObserver(() => { | ||
const node = ref.current; | ||
|
||
if (node) setContentHidingThrottled(isContentHidingBelow(node)); | ||
}), | ||
[] | ||
); | ||
|
||
useWillUnmount(() => void resizeObserver.disconnect()); | ||
|
||
const refFn = useCallback((node: HTMLDivElement | null) => { | ||
ref.current = node; | ||
if (!node) return void setContentHiding(false); | ||
|
||
resizeObserver.observe(node); | ||
|
||
setContentHiding(isContentHidingBelow(node)); | ||
}, []); | ||
|
||
return ( | ||
<div | ||
ref={refFn} | ||
className={clsx('flex-grow flex flex-col overflow-y-auto', className, contentHiding && 'shadow-inner-bottom')} | ||
onScroll={onScroll} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
function isContentHidingBelow(node: HTMLDivElement) { | ||
const scrollBottom = node.scrollHeight - node.clientHeight - node.scrollTop; | ||
|
||
return node.scrollHeight > node.clientHeight && scrollBottom > 0; | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.