@lifi/widget 3.26.0 → 3.26.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js +2 -1
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/dist/esm/components/BottomSheet/BottomSheet.js +13 -5
- package/dist/esm/components/BottomSheet/BottomSheet.js.map +1 -1
- package/dist/esm/components/Chains/ChainsExpanded.d.ts +1 -1
- package/dist/esm/components/Chains/ChainsExpanded.js +3 -2
- package/dist/esm/components/Chains/ChainsExpanded.js.map +1 -1
- package/dist/esm/components/Chains/ChainsExpanded.style.js +1 -2
- package/dist/esm/components/Chains/ChainsExpanded.style.js.map +1 -1
- package/dist/esm/components/Chains/SelectChainContent.d.ts +1 -1
- package/dist/esm/components/Chains/SelectChainContent.js +3 -2
- package/dist/esm/components/Chains/SelectChainContent.js.map +1 -1
- package/dist/esm/components/Expansion/Expansion.js +5 -16
- package/dist/esm/components/Expansion/Expansion.js.map +1 -1
- package/dist/esm/components/Expansion/Expansion.style.d.ts +32 -0
- package/dist/esm/components/Expansion/Expansion.style.js +40 -0
- package/dist/esm/components/Expansion/Expansion.style.js.map +1 -0
- package/dist/esm/components/Expansion/ExpansionTransition.d.ts +0 -1
- package/dist/esm/components/Expansion/ExpansionTransition.js +1 -30
- package/dist/esm/components/Expansion/ExpansionTransition.js.map +1 -1
- package/dist/esm/components/Header/CloseDrawerButton.js +2 -5
- package/dist/esm/components/Header/CloseDrawerButton.js.map +1 -1
- package/dist/esm/components/Header/Header.style.d.ts +1 -2
- package/dist/esm/components/Header/Header.style.js +3 -4
- package/dist/esm/components/Header/Header.style.js.map +1 -1
- package/dist/esm/components/Header/NavigationHeader.js +17 -21
- package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
- package/dist/esm/components/Header/SplitNavigationTabs.d.ts +1 -0
- package/dist/esm/components/Header/{NavigationTabs.js → SplitNavigationTabs.js} +4 -5
- package/dist/esm/components/Header/SplitNavigationTabs.js.map +1 -0
- package/dist/esm/components/Header/WalletHeader.d.ts +0 -1
- package/dist/esm/components/Header/WalletHeader.js +10 -14
- package/dist/esm/components/Header/WalletHeader.js.map +1 -1
- package/dist/esm/components/Routes/RoutesContent.d.ts +2 -3
- package/dist/esm/components/Routes/RoutesContent.js +5 -21
- package/dist/esm/components/Routes/RoutesContent.js.map +1 -1
- package/dist/esm/components/Routes/RoutesExpanded.d.ts +2 -3
- package/dist/esm/components/Routes/RoutesExpanded.js +24 -8
- package/dist/esm/components/Routes/RoutesExpanded.js.map +1 -1
- package/dist/esm/components/Routes/RoutesExpanded.style.js +1 -2
- package/dist/esm/components/Routes/RoutesExpanded.style.js.map +1 -1
- package/dist/esm/components/Step/StepProcess.js +8 -3
- package/dist/esm/components/Step/StepProcess.js.map +1 -1
- package/dist/esm/components/Tabs/NavigationTabs.d.ts +4 -0
- package/dist/esm/components/Tabs/NavigationTabs.js +39 -0
- package/dist/esm/components/Tabs/NavigationTabs.js.map +1 -0
- package/dist/esm/components/TokenList/TokenListItem.js +1 -0
- package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
- package/dist/esm/components/TokenList/useTokenSelect.js +9 -2
- package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useRoutes.js +32 -4
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/pages/MainPage/MainPage.js +8 -1
- package/dist/esm/pages/MainPage/MainPage.js.map +1 -1
- package/dist/esm/pages/SettingsPage/RoutePrioritySettings.js +1 -1
- package/dist/esm/pages/SettingsPage/RoutePrioritySettings.js.map +1 -1
- package/dist/esm/themes/azureLight.js +2 -3
- package/dist/esm/themes/azureLight.js.map +1 -1
- package/dist/esm/themes/createTheme.js +6 -0
- package/dist/esm/themes/createTheme.js.map +1 -1
- package/dist/esm/themes/types.d.ts +15 -1
- package/dist/esm/themes/watermelonLight.js +12 -0
- package/dist/esm/themes/watermelonLight.js.map +1 -1
- package/dist/esm/themes/windows95.js +11 -0
- package/dist/esm/themes/windows95.js.map +1 -1
- package/dist/esm/types/widget.d.ts +1 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/package.json +7 -7
- package/package.json.tmp +6 -6
- package/src/components/BaseTransactionButton/BaseTransactionButton.tsx +2 -1
- package/src/components/BottomSheet/BottomSheet.tsx +14 -3
- package/src/components/Chains/ChainsExpanded.style.tsx +1 -2
- package/src/components/Chains/ChainsExpanded.tsx +6 -2
- package/src/components/Chains/SelectChainContent.tsx +81 -82
- package/src/components/Expansion/Expansion.style.tsx +43 -0
- package/src/components/Expansion/Expansion.tsx +8 -23
- package/src/components/Expansion/ExpansionTransition.tsx +5 -33
- package/src/components/Header/CloseDrawerButton.tsx +2 -5
- package/src/components/Header/Header.style.ts +3 -5
- package/src/components/Header/NavigationHeader.tsx +66 -73
- package/src/components/Header/{NavigationTabs.tsx → SplitNavigationTabs.tsx} +10 -14
- package/src/components/Header/WalletHeader.tsx +13 -19
- package/src/components/Routes/RoutesContent.tsx +8 -29
- package/src/components/Routes/RoutesExpanded.style.ts +1 -2
- package/src/components/Routes/RoutesExpanded.tsx +33 -13
- package/src/components/Step/StepProcess.tsx +8 -3
- package/src/components/Tabs/NavigationTabs.tsx +40 -0
- package/src/components/TokenList/TokenListItem.tsx +1 -0
- package/src/components/TokenList/useTokenSelect.ts +14 -2
- package/src/config/version.ts +1 -1
- package/src/hooks/useRoutes.ts +68 -33
- package/src/pages/MainPage/MainPage.tsx +9 -1
- package/src/pages/SettingsPage/RoutePrioritySettings.tsx +0 -1
- package/src/themes/azureLight.ts +2 -3
- package/src/themes/createTheme.ts +6 -0
- package/src/themes/types.ts +20 -0
- package/src/themes/watermelonLight.ts +12 -0
- package/src/themes/windows95.ts +12 -0
- package/src/types/widget.ts +2 -0
- package/dist/esm/components/Header/NavigationTabs.d.ts +0 -1
- package/dist/esm/components/Header/NavigationTabs.js.map +0 -1
|
@@ -19,95 +19,94 @@ interface SelectChainContentProps {
|
|
|
19
19
|
|
|
20
20
|
const searchHeaderHeight = '80px'
|
|
21
21
|
|
|
22
|
-
export const SelectChainContent
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
export const SelectChainContent = memo(function SelectChainContent({
|
|
23
|
+
formType,
|
|
24
|
+
onSelect,
|
|
25
|
+
inExpansion,
|
|
26
|
+
}: SelectChainContentProps) {
|
|
27
|
+
const theme = useTheme()
|
|
28
|
+
const { chains, isLoading, setCurrentChain } = useChainSelect(formType)
|
|
29
|
+
const elementId = useDefaultElementId()
|
|
30
|
+
const scrollableContainer = useScrollableContainer(elementId)
|
|
31
|
+
const [selectedChainId] = useFieldValues(FormKeyHelper.getChainKey(formType))
|
|
32
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
33
|
+
const listRef = useRef<HTMLDivElement>(null)
|
|
34
|
+
const [debouncedSearchValue, setDebouncedSearchValue] = useState('')
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, [chains, debouncedSearchValue])
|
|
36
|
+
const filteredChains = useMemo(() => {
|
|
37
|
+
const value = debouncedSearchValue.toLowerCase()
|
|
38
|
+
return value
|
|
39
|
+
? (chains?.filter((chain) => chain.name.toLowerCase().includes(value)) ??
|
|
40
|
+
[])
|
|
41
|
+
: (chains ?? [])
|
|
42
|
+
}, [chains, debouncedSearchValue])
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const scrollToTop = useCallback(() => {
|
|
45
|
+
// Scroll widget container to top
|
|
46
|
+
if (!inExpansion && scrollableContainer) {
|
|
47
|
+
scrollableContainer.scrollTop = 0
|
|
48
|
+
}
|
|
49
|
+
}, [inExpansion, scrollableContainer])
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
const debouncedFilterChains = useMemo(
|
|
52
|
+
() =>
|
|
53
|
+
debounce((value: string) => {
|
|
54
|
+
setDebouncedSearchValue(value)
|
|
55
|
+
scrollToTop()
|
|
56
|
+
}, 250),
|
|
57
|
+
[scrollToTop]
|
|
58
|
+
)
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
const onSelectChainFallback = useCallback(
|
|
61
|
+
(chain: ExtendedChain) => {
|
|
62
|
+
setCurrentChain(chain.id)
|
|
63
|
+
},
|
|
64
|
+
[setCurrentChain]
|
|
65
|
+
)
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const onChange = useCallback(() => {
|
|
68
|
+
const value = inputRef.current?.value || ''
|
|
69
|
+
debouncedFilterChains(value)
|
|
70
|
+
}, [debouncedFilterChains])
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
const onClear = useCallback(() => {
|
|
73
|
+
setDebouncedSearchValue('')
|
|
74
|
+
scrollToTop()
|
|
75
|
+
}, [scrollToTop])
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
const listContainerHeight = useMemo(() => {
|
|
78
|
+
const fullContainerHeight = getWidgetMaxHeight(theme)
|
|
79
|
+
const heightValue =
|
|
80
|
+
typeof fullContainerHeight === 'number'
|
|
81
|
+
? `${fullContainerHeight}px`
|
|
82
|
+
: fullContainerHeight
|
|
83
|
+
return `calc(${heightValue} - ${searchHeaderHeight})`
|
|
84
|
+
}, [theme])
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
return (
|
|
87
|
+
<FullPageContainer disableGutters>
|
|
88
|
+
<ChainSearchInput
|
|
89
|
+
inputRef={inputRef}
|
|
90
|
+
inExpansion={inExpansion}
|
|
91
|
+
onChange={onChange}
|
|
92
|
+
onClear={onClear}
|
|
93
|
+
searchHeaderHeight={searchHeaderHeight}
|
|
94
|
+
/>
|
|
95
|
+
<Box
|
|
96
|
+
ref={listRef}
|
|
97
|
+
sx={
|
|
98
|
+
inExpansion ? { height: listContainerHeight, overflow: 'auto' } : {}
|
|
99
|
+
}
|
|
100
|
+
>
|
|
101
|
+
<ChainList
|
|
102
|
+
parentRef={listRef}
|
|
103
|
+
chains={filteredChains}
|
|
104
|
+
isLoading={isLoading}
|
|
105
|
+
onSelect={onSelect ?? onSelectChainFallback}
|
|
106
|
+
selectedChainId={selectedChainId}
|
|
90
107
|
inExpansion={inExpansion}
|
|
91
|
-
onChange={onChange}
|
|
92
|
-
onClear={onClear}
|
|
93
|
-
searchHeaderHeight={searchHeaderHeight}
|
|
94
108
|
/>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
>
|
|
101
|
-
<ChainList
|
|
102
|
-
parentRef={listRef}
|
|
103
|
-
chains={filteredChains}
|
|
104
|
-
isLoading={isLoading}
|
|
105
|
-
onSelect={onSelect ?? onSelectChainFallback}
|
|
106
|
-
selectedChainId={selectedChainId}
|
|
107
|
-
inExpansion={inExpansion}
|
|
108
|
-
/>
|
|
109
|
-
</Box>
|
|
110
|
-
</FullPageContainer>
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
)
|
|
109
|
+
</Box>
|
|
110
|
+
</FullPageContainer>
|
|
111
|
+
)
|
|
112
|
+
})
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Box, styled } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
export const animationDuration = 225
|
|
4
|
+
|
|
5
|
+
export const defaultStyle = {
|
|
6
|
+
opacity: 0,
|
|
7
|
+
whiteSpace: 'nowrap',
|
|
8
|
+
transform: 'translateX(-100%)',
|
|
9
|
+
display: 'inline-block',
|
|
10
|
+
position: 'absolute' as const,
|
|
11
|
+
top: 0,
|
|
12
|
+
left: 0,
|
|
13
|
+
transition: `opacity ${animationDuration}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${animationDuration}ms cubic-bezier(0.4, 0, 0.2, 1)`,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const transitionStyles = {
|
|
17
|
+
entering: {
|
|
18
|
+
opacity: 1,
|
|
19
|
+
transform: 'translateX(0)',
|
|
20
|
+
},
|
|
21
|
+
entered: {
|
|
22
|
+
opacity: 1,
|
|
23
|
+
transform: 'translateX(0)',
|
|
24
|
+
},
|
|
25
|
+
exiting: {
|
|
26
|
+
opacity: 0,
|
|
27
|
+
transform: 'translateX(-100%)',
|
|
28
|
+
},
|
|
29
|
+
exited: {
|
|
30
|
+
opacity: 0,
|
|
31
|
+
transform: 'translateX(-100%)',
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const ExpansionContainer = styled(Box, {
|
|
36
|
+
shouldForwardProp: (prop) => prop !== 'width',
|
|
37
|
+
})<{ width: string | number }>(({ width }) => ({
|
|
38
|
+
position: 'relative',
|
|
39
|
+
display: 'flex',
|
|
40
|
+
transition: `width ${animationDuration}ms cubic-bezier(0.4, 0, 0.2, 1)`,
|
|
41
|
+
width: width,
|
|
42
|
+
marginLeft: width ? '24px' : 0,
|
|
43
|
+
}))
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useCallback, useMemo, useRef, useState } from 'react'
|
|
1
|
+
import { useMemo, useRef, useState } from 'react'
|
|
3
2
|
import { useHasChainExpansion } from '../../hooks/useHasChainExpansion'
|
|
4
3
|
import { ExpansionType } from '../../types/widget'
|
|
5
4
|
import { ChainsExpanded } from '../Chains/ChainsExpanded'
|
|
6
5
|
import { chainExpansionWidth } from '../Chains/ChainsExpanded.style'
|
|
7
6
|
import { RoutesExpanded } from '../Routes/RoutesExpanded'
|
|
8
7
|
import { routesExpansionWidth } from '../Routes/RoutesExpanded.style'
|
|
9
|
-
import {
|
|
8
|
+
import { ExpansionContainer } from './Expansion.style'
|
|
10
9
|
|
|
11
10
|
export function Expansion() {
|
|
12
11
|
const [withChainExpansion, expansionType] = useHasChainExpansion()
|
|
13
12
|
const chainExpansionTypeRef = useRef<ExpansionType>(expansionType)
|
|
14
|
-
|
|
15
13
|
const [routesOpen, setRoutesOpen] = useState(false)
|
|
16
14
|
|
|
17
|
-
const handleSetRoutesOpen = useCallback((open: boolean) => {
|
|
18
|
-
setRoutesOpen(open)
|
|
19
|
-
}, [])
|
|
20
|
-
|
|
21
15
|
// Track the previous chain expansion type to avoid re-renders when transitioning to Routes
|
|
22
16
|
if (
|
|
23
17
|
expansionType === ExpansionType.FromChain ||
|
|
@@ -26,28 +20,19 @@ export function Expansion() {
|
|
|
26
20
|
chainExpansionTypeRef.current = expansionType
|
|
27
21
|
}
|
|
28
22
|
|
|
29
|
-
const
|
|
23
|
+
const containerWidth = useMemo(() => {
|
|
30
24
|
return routesOpen
|
|
31
25
|
? routesExpansionWidth
|
|
32
26
|
: withChainExpansion
|
|
33
27
|
? chainExpansionWidth
|
|
34
|
-
:
|
|
28
|
+
: 0
|
|
35
29
|
}, [routesOpen, withChainExpansion])
|
|
36
30
|
|
|
37
31
|
return (
|
|
38
|
-
<
|
|
39
|
-
sx={{
|
|
40
|
-
position: 'relative',
|
|
41
|
-
display: 'flex',
|
|
42
|
-
transition: `width ${animationDuration}ms cubic-bezier(0.4, 0, 0.2, 1)`,
|
|
43
|
-
width: boxWidth,
|
|
44
|
-
willChange: 'width',
|
|
45
|
-
marginLeft: boxWidth !== '0px' ? '24px' : '0px',
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
32
|
+
<ExpansionContainer width={containerWidth}>
|
|
48
33
|
<RoutesExpanded
|
|
49
|
-
|
|
50
|
-
setOpenExpansion={
|
|
34
|
+
canOpen={expansionType === ExpansionType.Routes}
|
|
35
|
+
setOpenExpansion={setRoutesOpen}
|
|
51
36
|
/>
|
|
52
37
|
<ChainsExpanded
|
|
53
38
|
formType={
|
|
@@ -57,6 +42,6 @@ export function Expansion() {
|
|
|
57
42
|
}
|
|
58
43
|
open={withChainExpansion}
|
|
59
44
|
/>
|
|
60
|
-
</
|
|
45
|
+
</ExpansionContainer>
|
|
61
46
|
)
|
|
62
47
|
}
|
|
@@ -1,39 +1,11 @@
|
|
|
1
1
|
import { Box } from '@mui/material'
|
|
2
2
|
import { type PropsWithChildren, useRef } from 'react'
|
|
3
3
|
import { Transition } from 'react-transition-group'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
whiteSpace: 'nowrap',
|
|
10
|
-
transform: 'translateX(-100%)',
|
|
11
|
-
display: 'inline-block',
|
|
12
|
-
position: 'absolute' as const,
|
|
13
|
-
top: 0,
|
|
14
|
-
left: 0,
|
|
15
|
-
willChange: 'opacity, transform',
|
|
16
|
-
transition: `opacity ${animationDuration}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${animationDuration}ms cubic-bezier(0.4, 0, 0.2, 1)`,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const transitionStyles = {
|
|
20
|
-
entering: {
|
|
21
|
-
opacity: 1,
|
|
22
|
-
transform: 'translateX(0)',
|
|
23
|
-
},
|
|
24
|
-
entered: {
|
|
25
|
-
opacity: 1,
|
|
26
|
-
transform: 'translateX(0)',
|
|
27
|
-
},
|
|
28
|
-
exiting: {
|
|
29
|
-
opacity: 0,
|
|
30
|
-
transform: 'translateX(-100%)',
|
|
31
|
-
},
|
|
32
|
-
exited: {
|
|
33
|
-
opacity: 0,
|
|
34
|
-
transform: 'translateX(-100%)',
|
|
35
|
-
},
|
|
36
|
-
}
|
|
4
|
+
import {
|
|
5
|
+
animationDuration,
|
|
6
|
+
defaultStyle,
|
|
7
|
+
transitionStyles,
|
|
8
|
+
} from './Expansion.style'
|
|
37
9
|
|
|
38
10
|
interface ExpansionTransitionProps {
|
|
39
11
|
in: boolean
|
|
@@ -3,7 +3,6 @@ import { IconButton, Tooltip } from '@mui/material'
|
|
|
3
3
|
import { useTranslation } from 'react-i18next'
|
|
4
4
|
import { useDrawer } from '../../AppDrawerContext.js'
|
|
5
5
|
import { useExternalWalletProvider } from '../../providers/WalletProvider/useExternalWalletProvider.js'
|
|
6
|
-
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
7
6
|
|
|
8
7
|
interface CloseDrawerButtonProps {
|
|
9
8
|
header?: 'navigation' | 'wallet'
|
|
@@ -11,15 +10,13 @@ interface CloseDrawerButtonProps {
|
|
|
11
10
|
|
|
12
11
|
export const CloseDrawerButton = ({ header }: CloseDrawerButtonProps) => {
|
|
13
12
|
const { t } = useTranslation()
|
|
14
|
-
const { subvariant } = useWidgetConfig()
|
|
15
13
|
const { closeDrawer } = useDrawer()
|
|
16
14
|
const { useExternalWalletProvidersOnly } = useExternalWalletProvider()
|
|
17
15
|
|
|
18
16
|
const showInNavigationHeader =
|
|
19
|
-
header === 'navigation' &&
|
|
20
|
-
(useExternalWalletProvidersOnly || subvariant === 'split')
|
|
17
|
+
header === 'navigation' && useExternalWalletProvidersOnly
|
|
21
18
|
|
|
22
|
-
const showInWalletHeader = header === 'wallet'
|
|
19
|
+
const showInWalletHeader = header === 'wallet'
|
|
23
20
|
|
|
24
21
|
return showInNavigationHeader || showInWalletHeader ? (
|
|
25
22
|
<Tooltip title={t('button.close')}>
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
buttonClasses,
|
|
7
7
|
styled,
|
|
8
8
|
} from '@mui/material'
|
|
9
|
-
import type { WidgetSubvariant } from '../../types/widget.js'
|
|
10
9
|
import { getAvatarMask } from '../Avatar/utils.js'
|
|
11
10
|
|
|
12
11
|
export const HeaderAppBar = styled(AppBar)(({ theme }) => ({
|
|
@@ -46,8 +45,8 @@ export const Container = styled(Box, {
|
|
|
46
45
|
})
|
|
47
46
|
|
|
48
47
|
export const WalletButton = styled(Button, {
|
|
49
|
-
shouldForwardProp: (prop) => prop !== '
|
|
50
|
-
})<{
|
|
48
|
+
shouldForwardProp: (prop) => prop !== 'withOffset',
|
|
49
|
+
})<{ withOffset?: boolean }>(({ withOffset, theme }) => ({
|
|
51
50
|
color: theme.vars.palette.text.primary,
|
|
52
51
|
padding: theme.spacing(1, 1.5),
|
|
53
52
|
maxHeight: 40,
|
|
@@ -71,8 +70,7 @@ export const WalletButton = styled(Button, {
|
|
|
71
70
|
fontSize: '24px',
|
|
72
71
|
},
|
|
73
72
|
...(theme.navigation.edge && {
|
|
74
|
-
marginRight:
|
|
75
|
-
marginLeft: subvariant === 'split' ? theme.spacing(-1) : 0,
|
|
73
|
+
marginRight: withOffset ? theme.spacing(-1.25) : 0,
|
|
76
74
|
}),
|
|
77
75
|
}))
|
|
78
76
|
|
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
import { BackButton } from './BackButton.js'
|
|
14
14
|
import { CloseDrawerButton } from './CloseDrawerButton.js'
|
|
15
15
|
import { HeaderAppBar, HeaderControlsContainer } from './Header.style.js'
|
|
16
|
-
import { NavigationTabs } from './NavigationTabs.js'
|
|
17
16
|
import { SettingsButton } from './SettingsButton.js'
|
|
17
|
+
import { SplitNavigationTabs } from './SplitNavigationTabs.js'
|
|
18
18
|
import { TransactionHistoryButton } from './TransactionHistoryButton.js'
|
|
19
|
-
import { SplitWalletMenuButton } from './WalletHeader.js'
|
|
20
19
|
|
|
21
20
|
export const NavigationHeader: React.FC = () => {
|
|
22
|
-
const { subvariant, hiddenUI, variant, defaultUI } =
|
|
21
|
+
const { subvariant, hiddenUI, variant, defaultUI, subvariantOptions } =
|
|
22
|
+
useWidgetConfig()
|
|
23
23
|
const { navigateBack } = useNavigateBack()
|
|
24
24
|
const { account } = useAccount()
|
|
25
25
|
const { element, title } = useHeaderStore((state) => state)
|
|
@@ -31,77 +31,70 @@ export const NavigationHeader: React.FC = () => {
|
|
|
31
31
|
const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1)
|
|
32
32
|
const hasPath = navigationRoutesValues.includes(path)
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const showSplitOptions =
|
|
35
|
+
subvariant === 'split' && !hasPath && !subvariantOptions?.split
|
|
35
36
|
|
|
36
37
|
return (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
/>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
/>
|
|
102
|
-
</Routes>
|
|
103
|
-
</HeaderAppBar>
|
|
104
|
-
{splitSubvariant ? <NavigationTabs /> : null}
|
|
105
|
-
</>
|
|
38
|
+
<HeaderAppBar elevation={0} sx={{ paddingTop: 1, paddingBottom: 0.5 }}>
|
|
39
|
+
{backButtonRoutes.includes(path) ? (
|
|
40
|
+
<BackButton
|
|
41
|
+
onClick={() =>
|
|
42
|
+
navigateBack(
|
|
43
|
+
// From transaction details page, navigate to home page
|
|
44
|
+
path === navigationRoutes.transactionDetails
|
|
45
|
+
? navigationRoutes.home
|
|
46
|
+
: undefined
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
/>
|
|
50
|
+
) : null}
|
|
51
|
+
{showSplitOptions ? (
|
|
52
|
+
<Box sx={{ flex: 1, marginRight: 1 }}>
|
|
53
|
+
<SplitNavigationTabs />
|
|
54
|
+
</Box>
|
|
55
|
+
) : (
|
|
56
|
+
<Typography
|
|
57
|
+
align={hasPath ? 'center' : 'left'}
|
|
58
|
+
noWrap={defaultUI?.navigationHeaderTitleNoWrap ?? true}
|
|
59
|
+
sx={{
|
|
60
|
+
fontSize: hasPath ? 18 : 24,
|
|
61
|
+
fontWeight: '700',
|
|
62
|
+
flex: 1,
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{title}
|
|
66
|
+
</Typography>
|
|
67
|
+
)}
|
|
68
|
+
<Routes>
|
|
69
|
+
<Route
|
|
70
|
+
path={navigationRoutes.home}
|
|
71
|
+
element={
|
|
72
|
+
<HeaderControlsContainer>
|
|
73
|
+
{account.isConnected && !hiddenUI?.includes(HiddenUI.History) && (
|
|
74
|
+
<TransactionHistoryButton />
|
|
75
|
+
)}
|
|
76
|
+
<SettingsButton />
|
|
77
|
+
{variant === 'drawer' &&
|
|
78
|
+
!hiddenUI?.includes(HiddenUI.DrawerCloseButton) ? (
|
|
79
|
+
<CloseDrawerButton header="navigation" />
|
|
80
|
+
) : null}
|
|
81
|
+
</HeaderControlsContainer>
|
|
82
|
+
}
|
|
83
|
+
/>
|
|
84
|
+
<Route
|
|
85
|
+
path="*"
|
|
86
|
+
element={
|
|
87
|
+
element || (
|
|
88
|
+
<Box
|
|
89
|
+
sx={{
|
|
90
|
+
width: 28,
|
|
91
|
+
height: 40,
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
</Routes>
|
|
98
|
+
</HeaderAppBar>
|
|
106
99
|
)
|
|
107
100
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useTranslation } from 'react-i18next'
|
|
2
2
|
import { useFieldActions } from '../../stores/form/useFieldActions.js'
|
|
3
3
|
import { useSplitSubvariantStore } from '../../stores/settings/useSplitSubvariantStore.js'
|
|
4
|
-
import {
|
|
5
|
-
import { HeaderAppBar } from './Header.style.js'
|
|
4
|
+
import { NavigationTab, NavigationTabs } from '../Tabs/NavigationTabs.js'
|
|
6
5
|
|
|
7
|
-
export const
|
|
6
|
+
export const SplitNavigationTabs = () => {
|
|
8
7
|
const { t } = useTranslation()
|
|
9
8
|
const [state, setState] = useSplitSubvariantStore((state) => [
|
|
10
9
|
state.state,
|
|
@@ -20,16 +19,13 @@ export const NavigationTabs = () => {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
return (
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<Tab label={t('header.bridge')} disableRipple />
|
|
32
|
-
</Tabs>
|
|
33
|
-
</HeaderAppBar>
|
|
22
|
+
<NavigationTabs
|
|
23
|
+
value={state === 'swap' ? 0 : 1}
|
|
24
|
+
onChange={handleChange}
|
|
25
|
+
aria-label="tabs"
|
|
26
|
+
>
|
|
27
|
+
<NavigationTab label={t('header.swap')} disableRipple />
|
|
28
|
+
<NavigationTab label={t('header.bridge')} disableRipple />
|
|
29
|
+
</NavigationTabs>
|
|
34
30
|
)
|
|
35
31
|
}
|