@rango-dev/widget-embedded 0.51.1-next.7 → 0.51.1-next.8
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/dist/components/Layout/Layout.constants.d.ts +5 -3
- package/dist/components/Layout/Layout.constants.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/containers/App/App.styles.d.ts.map +1 -1
- package/dist/hooks/useScreenDetect.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +2 -2
- package/src/components/Layout/Layout.constants.ts +5 -3
- package/src/components/Layout/Layout.styles.ts +12 -5
- package/src/components/Layout/Layout.tsx +18 -32
- package/src/containers/App/App.styles.ts +1 -0
- package/src/hooks/useScreenDetect.ts +7 -1
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export const WIDGET_MAX_HEIGHT =
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
1
|
+
export const WIDGET_MAX_HEIGHT = '700px';
|
|
2
|
+
export const WIDGET_MIN_HEIGHT_FOR_SMALL_SCREENS = '425px';
|
|
3
|
+
export const WIDGET_MIN_HEIGHT_FOR_LARGE_SCREENS = '550px';
|
|
4
|
+
export const COMPACT_TOKEN_SELECTOR_THRESHOLD = '640px';
|
|
5
|
+
export const LARGE_SCREEN_MIN_HEIGHT = '800px';
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { css, styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
LARGE_SCREEN_MIN_HEIGHT,
|
|
5
|
+
WIDGET_MAX_HEIGHT,
|
|
6
|
+
WIDGET_MIN_HEIGHT_FOR_LARGE_SCREENS,
|
|
7
|
+
WIDGET_MIN_HEIGHT_FOR_SMALL_SCREENS,
|
|
8
|
+
} from './Layout.constants';
|
|
4
9
|
|
|
5
10
|
export const LayoutContainer = css({
|
|
6
11
|
borderRadius: '$primary',
|
|
@@ -16,16 +21,18 @@ export const Container = styled('div', {
|
|
|
16
21
|
minWidth: '300px',
|
|
17
22
|
maxWidth: '390px',
|
|
18
23
|
backgroundColor: '$background',
|
|
24
|
+
maxHeight: WIDGET_MAX_HEIGHT,
|
|
19
25
|
variants: {
|
|
20
26
|
height: {
|
|
21
27
|
auto: {
|
|
22
28
|
height: 'auto',
|
|
23
|
-
maxHeight: WIDGET_MAX_HEIGHT,
|
|
24
29
|
},
|
|
25
30
|
fixed: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
height:
|
|
31
|
+
height: '100%',
|
|
32
|
+
minHeight: WIDGET_MIN_HEIGHT_FOR_SMALL_SCREENS,
|
|
33
|
+
[`@media screen and (min-height: ${LARGE_SCREEN_MIN_HEIGHT})`]: {
|
|
34
|
+
minHeight: WIDGET_MIN_HEIGHT_FOR_LARGE_SCREENS,
|
|
35
|
+
},
|
|
29
36
|
},
|
|
30
37
|
},
|
|
31
38
|
showBanner: {
|
|
@@ -10,7 +10,6 @@ import { WIDGET_UI_ID } from '../../constants';
|
|
|
10
10
|
import { useIframe } from '../../hooks/useIframe';
|
|
11
11
|
import { isAppLoadedIntoIframe } from '../../hooks/useIframe/useIframe.helpers';
|
|
12
12
|
import { useNavigateBack } from '../../hooks/useNavigateBack';
|
|
13
|
-
import useScreenDetect from '../../hooks/useScreenDetect';
|
|
14
13
|
import { useTheme } from '../../hooks/useTheme';
|
|
15
14
|
import { useAppStore } from '../../store/AppStore';
|
|
16
15
|
import { tabManager, useUiStore } from '../../store/ui';
|
|
@@ -22,10 +21,7 @@ import { ActivateTabModal } from '../common/ActivateTabModal';
|
|
|
22
21
|
import { BackButton, CancelButton, WalletButton } from '../HeaderButtons';
|
|
23
22
|
import { RefreshModal } from '../RefreshModal';
|
|
24
23
|
|
|
25
|
-
import {
|
|
26
|
-
COMPACT_TOKEN_SELECTOR_THRESHOLD,
|
|
27
|
-
WIDGET_MAX_HEIGHT,
|
|
28
|
-
} from './Layout.constants';
|
|
24
|
+
import { COMPACT_TOKEN_SELECTOR_THRESHOLD } from './Layout.constants';
|
|
29
25
|
import { onScrollContentAttachStatusToContainer } from './Layout.helpers';
|
|
30
26
|
import {
|
|
31
27
|
BannerContainer,
|
|
@@ -47,7 +43,7 @@ function Layout(props: PropsWithChildren<PropTypes>) {
|
|
|
47
43
|
const {
|
|
48
44
|
config: { features, theme },
|
|
49
45
|
} = useAppStore();
|
|
50
|
-
const { watermark
|
|
46
|
+
const { watermark } = useUiStore();
|
|
51
47
|
|
|
52
48
|
const hasWatermark = watermark === 'FULL';
|
|
53
49
|
const { activeTheme } = useTheme(theme || {});
|
|
@@ -64,10 +60,10 @@ function Layout(props: PropsWithChildren<PropTypes>) {
|
|
|
64
60
|
showActivateTabModal,
|
|
65
61
|
setShowActivateTabModal,
|
|
66
62
|
activateCurrentTab,
|
|
63
|
+
setShowCompactTokenSelector,
|
|
67
64
|
} = useUiStore();
|
|
68
65
|
const navigateBack = useNavigateBack();
|
|
69
66
|
const { manager } = useManager();
|
|
70
|
-
const { isTablet, isMobile } = useScreenDetect();
|
|
71
67
|
const pendingSwaps: PendingSwap[] = getPendingSwaps(manager).map(
|
|
72
68
|
({ swap }) => swap
|
|
73
69
|
);
|
|
@@ -134,35 +130,25 @@ function Layout(props: PropsWithChildren<PropTypes>) {
|
|
|
134
130
|
}, [fetchStatus]);
|
|
135
131
|
|
|
136
132
|
useLayoutEffect(() => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const handler = () => {
|
|
142
|
-
if (isFixedHeight) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
133
|
+
if (!containerRef.current) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
145
136
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
137
|
+
const observer = new ResizeObserver((entries) => {
|
|
138
|
+
for (const entry of entries) {
|
|
139
|
+
if (entry.contentRect) {
|
|
140
|
+
setShowCompactTokenSelector(
|
|
141
|
+
entry.contentRect.height <
|
|
142
|
+
parseInt(COMPACT_TOKEN_SELECTOR_THRESHOLD)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
152
145
|
}
|
|
146
|
+
});
|
|
153
147
|
|
|
154
|
-
|
|
155
|
-
parseFloat(containerRef.current.style.height) <
|
|
156
|
-
COMPACT_TOKEN_SELECTOR_THRESHOLD
|
|
157
|
-
);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
handler();
|
|
148
|
+
observer.observe(containerRef.current);
|
|
161
149
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return () => window.removeEventListener('resize', handler);
|
|
165
|
-
}, [height, isMobile, isTablet]);
|
|
150
|
+
return () => observer.disconnect();
|
|
151
|
+
}, []);
|
|
166
152
|
|
|
167
153
|
return (
|
|
168
154
|
<Container
|
|
@@ -43,7 +43,13 @@ const useScreenDetect = () => {
|
|
|
43
43
|
return () => window.removeEventListener('resize', handleResize);
|
|
44
44
|
}, []);
|
|
45
45
|
|
|
46
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
isMobile,
|
|
48
|
+
isTablet,
|
|
49
|
+
isNotebook,
|
|
50
|
+
isLargeScreen,
|
|
51
|
+
isExtraLargeScreen,
|
|
52
|
+
};
|
|
47
53
|
};
|
|
48
54
|
|
|
49
55
|
export default useScreenDetect;
|