@rango-dev/widget-embedded 0.51.1-next.7 → 0.51.1-next.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.51.1-next.7",
3
+ "version": "0.51.1-next.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -30,7 +30,7 @@
30
30
  "@rango-dev/queue-manager-rango-preset": "^0.53.1-next.2",
31
31
  "@rango-dev/queue-manager-react": "^0.32.1-next.0",
32
32
  "@rango-dev/signer-solana": "^0.44.0",
33
- "@rango-dev/ui": "^0.54.1-next.3",
33
+ "@rango-dev/ui": "^0.54.1-next.4",
34
34
  "@rango-dev/wallets-core": "^0.50.1-next.1",
35
35
  "@rango-dev/wallets-react": "^0.37.1-next.2",
36
36
  "@rango-dev/wallets-shared": "^0.51.1-next.1",
@@ -1,3 +1,5 @@
1
- export const WIDGET_MAX_HEIGHT = 700;
2
- export const WIDGET_MIN_HEIGHT = 425;
3
- export const COMPACT_TOKEN_SELECTOR_THRESHOLD = 640;
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 { WIDGET_MAX_HEIGHT, WIDGET_MIN_HEIGHT } from './Layout.constants';
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
- minHeight: WIDGET_MIN_HEIGHT,
27
- maxHeight: WIDGET_MAX_HEIGHT,
28
- height: WIDGET_MAX_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, setShowCompactTokenSelector } = useUiStore();
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
- const isFixedHeight =
138
- height === 'auto' || !containerRef.current || isAppLoadedIntoIframe();
139
- const isSmallScreen = isMobile || isTablet;
140
-
141
- const handler = () => {
142
- if (isFixedHeight) {
143
- return;
144
- }
133
+ if (!containerRef.current) {
134
+ return;
135
+ }
145
136
 
146
- if (isSmallScreen) {
147
- containerRef.current.style.height = `${
148
- window.innerHeight - containerRef.current.offsetTop
149
- }px`;
150
- } else {
151
- containerRef.current.style.height = `${WIDGET_MAX_HEIGHT}px`;
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
- setShowCompactTokenSelector(
155
- parseFloat(containerRef.current.style.height) <
156
- COMPACT_TOKEN_SELECTOR_THRESHOLD
157
- );
158
- };
159
-
160
- handler();
148
+ observer.observe(containerRef.current);
161
149
 
162
- window.addEventListener('resize', handler);
163
-
164
- return () => window.removeEventListener('resize', handler);
165
- }, [height, isMobile, isTablet]);
150
+ return () => observer.disconnect();
151
+ }, []);
166
152
 
167
153
  return (
168
154
  <Container
@@ -75,7 +75,10 @@ export function Detached(props: PropTypes) {
75
75
  if (!!singleSelection) {
76
76
  return (
77
77
  <>
78
- <Divider size={20} />
78
+ <Divider
79
+ size={20}
80
+ className="_detached_namespace_list_header_alert_top_divider"
81
+ />
79
82
  <Alert
80
83
  id="widget-wallet-stateful-connect-alert"
81
84
  variant="alarm"
@@ -84,13 +87,19 @@ export function Detached(props: PropTypes) {
84
87
  'This wallet can only connect to one chain at a time.'
85
88
  )}
86
89
  />
87
- <Divider size={30} />
90
+ <Divider
91
+ size={30}
92
+ className="_detached_namespace_list_header_alert_bottom_divider"
93
+ />
88
94
  </>
89
95
  );
90
96
  }
91
97
  return (
92
98
  <>
93
- <Divider size={30} />
99
+ <Divider
100
+ size={30}
101
+ className="_detached_namespace_list_header_button_top_divider"
102
+ />
94
103
  <NamespacesHeader>
95
104
  <Button
96
105
  id="widget-detached-disconnect-wallet-btn"
@@ -102,7 +111,10 @@ export function Detached(props: PropTypes) {
102
111
  {i18n.t('Disconnect wallet')}
103
112
  </Button>
104
113
  </NamespacesHeader>
105
- <Divider size={16} />
114
+ <Divider
115
+ size={16}
116
+ className="_detached_namespace_list_header_button_bottom_divider"
117
+ />
106
118
  </>
107
119
  );
108
120
  };
@@ -120,7 +120,10 @@ export function Namespaces(props: PropTypes) {
120
120
  />
121
121
  {singleNamespace ? (
122
122
  <>
123
- <Divider size={20} />
123
+ <Divider
124
+ size={20}
125
+ className="_initial_namespace_list_header_alert_top_divider"
126
+ />
124
127
  <Alert
125
128
  id="widget-wallet-stateful-connect-alert"
126
129
  variant="alarm"
@@ -129,11 +132,17 @@ export function Namespaces(props: PropTypes) {
129
132
  'This wallet can only connect to one chain at a time. '
130
133
  )}
131
134
  />
132
- <Divider size={30} />
135
+ <Divider
136
+ size={30}
137
+ className="_initial_namespace_list_header_alert_bottom_divider"
138
+ />
133
139
  </>
134
140
  ) : (
135
141
  <>
136
- <Divider size={30} />
142
+ <Divider
143
+ size={30}
144
+ className="_initial_namespace_list_header_button_top_divider"
145
+ />
137
146
  <Button
138
147
  style={{ marginLeft: 'auto' }}
139
148
  id="widget-name-space-select-all-btn"
@@ -145,7 +154,10 @@ export function Namespaces(props: PropTypes) {
145
154
  ? i18n.t('Deselect all')
146
155
  : i18n.t('Select all')}
147
156
  </Button>
148
- <Divider size={10} />
157
+ <Divider
158
+ size={10}
159
+ className="_initial_namespace_list_header_button_bottom_divider"
160
+ />
149
161
  </>
150
162
  )}
151
163
  <NamespaceList>
@@ -4,6 +4,7 @@ export const MainContainer = styled('div', {
4
4
  fontFamily: '$widget',
5
5
  boxSizing: 'border-box',
6
6
  textAlign: 'left',
7
+ height: '100%',
7
8
  '& *, *::before, *::after': {
8
9
  boxSizing: 'inherit',
9
10
  },
@@ -43,7 +43,13 @@ const useScreenDetect = () => {
43
43
  return () => window.removeEventListener('resize', handleResize);
44
44
  }, []);
45
45
 
46
- return { isMobile, isTablet, isNotebook, isLargeScreen, isExtraLargeScreen };
46
+ return {
47
+ isMobile,
48
+ isTablet,
49
+ isNotebook,
50
+ isLargeScreen,
51
+ isExtraLargeScreen,
52
+ };
47
53
  };
48
54
 
49
55
  export default useScreenDetect;