@rango-dev/widget-embedded 0.40.2-next.4 → 0.40.2-next.6

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.40.2-next.4",
3
+ "version": "0.40.2-next.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -27,10 +27,10 @@
27
27
  "@rango-dev/logging-core": "^0.7.1-next.1",
28
28
  "@rango-dev/provider-all": "^0.43.1-next.4",
29
29
  "@rango-dev/queue-manager-core": "^0.28.1-next.0",
30
- "@rango-dev/queue-manager-rango-preset": "^0.43.1-next.4",
30
+ "@rango-dev/queue-manager-rango-preset": "^0.43.1-next.5",
31
31
  "@rango-dev/queue-manager-react": "^0.28.1-next.0",
32
32
  "@rango-dev/signer-solana": "^0.37.1-next.2",
33
- "@rango-dev/ui": "^0.44.1-next.4",
33
+ "@rango-dev/ui": "^0.44.1-next.5",
34
34
  "@rango-dev/wallets-core": "^0.41.1-next.4",
35
35
  "@rango-dev/wallets-react": "^0.28.1-next.4",
36
36
  "@rango-dev/wallets-shared": "^0.42.1-next.4",
@@ -26,6 +26,11 @@ export const Container = styled('div', {
26
26
  height: WIDGET_HEIGHT,
27
27
  },
28
28
  },
29
+ showBanner: {
30
+ true: {
31
+ overflow: 'visible',
32
+ },
33
+ },
29
34
  },
30
35
  });
31
36
 
@@ -55,3 +60,10 @@ export const Footer = styled('div', {
55
60
  },
56
61
  },
57
62
  });
63
+
64
+ export const BannerContainer = styled('div', {
65
+ width: '100%',
66
+ position: 'absolute',
67
+ bottom: '-$10',
68
+ transform: 'translateY(100%)',
69
+ });
@@ -4,7 +4,7 @@ import type { PropsWithChildren } from 'react';
4
4
 
5
5
  import { useManager } from '@rango-dev/queue-manager-react';
6
6
  import { BottomLogo, Divider, Header } from '@rango-dev/ui';
7
- import React, { useEffect, useRef, useState } from 'react';
7
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
8
8
 
9
9
  import { WIDGET_UI_ID } from '../../constants';
10
10
  import { useIframe } from '../../hooks/useIframe';
@@ -22,12 +22,22 @@ import { BackButton, CancelButton, WalletButton } from '../HeaderButtons';
22
22
  import { RefreshModal } from '../RefreshModal';
23
23
 
24
24
  import { onScrollContentAttachStatusToContainer } from './Layout.helpers';
25
- import { Container, Content, Footer, LayoutContainer } from './Layout.styles';
25
+ import {
26
+ BannerContainer,
27
+ Container,
28
+ Content,
29
+ Footer,
30
+ LayoutContainer,
31
+ } from './Layout.styles';
26
32
 
27
33
  function Layout(props: PropsWithChildren<PropTypes>) {
28
34
  const { connectHeightObserver, disconnectHeightObserver } = useIframe();
29
35
  const { children, header, footer, height = 'fixed' } = props;
30
- const { fetchStatus, connectedWallets } = useAppStore();
36
+ const {
37
+ fetchStatus,
38
+ connectedWallets,
39
+ config: { __UNSTABLE_OR_INTERNAL__ },
40
+ } = useAppStore();
31
41
  const [openRefreshModal, setOpenRefreshModal] = useState(false);
32
42
  const {
33
43
  config: { features, theme },
@@ -68,6 +78,22 @@ function Layout(props: PropsWithChildren<PropTypes>) {
68
78
 
69
79
  const scrollViewRef = useRef<HTMLDivElement>(null);
70
80
  const containerRef = useRef<HTMLDivElement>(null);
81
+ const showBanner = useMemo(() => {
82
+ const anyRouteExists =
83
+ (__UNSTABLE_OR_INTERNAL__?.swapBoxBanner?.routes?.length ?? 0) === 0;
84
+ const routesMatched =
85
+ !!__UNSTABLE_OR_INTERNAL__?.swapBoxBanner?.routes?.some((route) =>
86
+ location.pathname.endsWith(route)
87
+ );
88
+
89
+ return (
90
+ __UNSTABLE_OR_INTERNAL__?.swapBoxBanner &&
91
+ (anyRouteExists || routesMatched)
92
+ );
93
+ }, [
94
+ __UNSTABLE_OR_INTERNAL__?.swapBoxBanner?.routes?.length,
95
+ location.pathname,
96
+ ]);
71
97
 
72
98
  useEffect(() => {
73
99
  const isIframe = isAppLoadedIntoIframe();
@@ -104,7 +130,8 @@ function Layout(props: PropsWithChildren<PropTypes>) {
104
130
  height={height}
105
131
  id={WIDGET_UI_ID.SWAP_BOX_ID}
106
132
  className={`${activeTheme()} ${LayoutContainer()}`}
107
- ref={containerRef}>
133
+ ref={containerRef}
134
+ showBanner={showBanner}>
108
135
  <Header
109
136
  prefix={
110
137
  showBackButton ? (
@@ -112,7 +139,7 @@ function Layout(props: PropsWithChildren<PropTypes>) {
112
139
  onClick={() => {
113
140
  navigateBack();
114
141
  // As an example, used in routes page to add a custom logic when navigating back to the home page.
115
- header.onBack && header.onBack();
142
+ header.onBack?.();
116
143
  }}
117
144
  />
118
145
  ) : null
@@ -159,6 +186,11 @@ function Layout(props: PropsWithChildren<PropTypes>) {
159
186
  <BottomLogo />
160
187
  </div>
161
188
  </Footer>
189
+ {showBanner && (
190
+ <BannerContainer>
191
+ {__UNSTABLE_OR_INTERNAL__?.swapBoxBanner?.element}
192
+ </BannerContainer>
193
+ )}
162
194
  <RefreshModal
163
195
  open={openRefreshModal}
164
196
  onClose={() => setOpenRefreshModal(false)}
@@ -2,6 +2,7 @@ import type { Language, theme } from '@rango-dev/ui';
2
2
  import type { LegacyProviderInterface } from '@rango-dev/wallets-core/dist/legacy/mod';
3
3
  import type { WalletType } from '@rango-dev/wallets-shared';
4
4
  import type { Asset } from 'rango-sdk';
5
+ import type { ReactElement } from 'react';
5
6
 
6
7
  export type WidgetVariant = 'default' | 'expanded' | 'full-expanded';
7
8
 
@@ -273,6 +274,10 @@ export type WidgetConfig = {
273
274
  __UNSTABLE_OR_INTERNAL__?: {
274
275
  walletConnectListedDesktopWalletLink?: string;
275
276
  autoUpdateSettings?: boolean; // If true, settings will be updated automatically based on the configuration.
277
+ swapBoxBanner?: {
278
+ element: ReactElement;
279
+ routes?: string[];
280
+ };
276
281
  };
277
282
  routing?: Routing;
278
283
  };