@rango-dev/widget-embedded 0.36.1-next.2 → 0.36.1-next.4

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.36.1-next.2",
3
+ "version": "0.36.1-next.4",
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.40.1-next.1",
31
31
  "@rango-dev/queue-manager-react": "^0.27.0",
32
32
  "@rango-dev/signer-solana": "^0.35.0",
33
- "@rango-dev/ui": "^0.42.1-next.1",
33
+ "@rango-dev/ui": "^0.42.1-next.3",
34
34
  "@rango-dev/wallets-core": "^0.40.1-next.1",
35
35
  "@rango-dev/wallets-react": "^0.26.1-next.1",
36
36
  "@rango-dev/wallets-shared": "^0.40.1-next.1",
@@ -54,4 +54,4 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  }
57
- }
57
+ }
@@ -17,7 +17,11 @@ import {
17
17
  import BigNumber from 'bignumber.js';
18
18
  import React, { useRef, useState } from 'react';
19
19
 
20
- import { GAS_FEE_MAX } from '../../constants/quote';
20
+ import {
21
+ GAS_FEE_MAX,
22
+ ROUTE_TIME_MAX,
23
+ SECONDS_IN_MINUTE,
24
+ } from '../../constants/quote';
21
25
  import {
22
26
  GAS_FEE_MAX_DECIMALS,
23
27
  GAS_FEE_MIN_DECIMALS,
@@ -311,7 +315,8 @@ export function Quote(props: QuoteProps) {
311
315
  const container = propContainer || getContainer();
312
316
  const sortedQuoteTags = sortTags(props.quote.tags || []);
313
317
  const showAllRoutesButton = !!onClickAllRoutes;
314
- const totalTime = roundedSecondsToString(totalArrivalTime(quote?.swaps));
318
+ const totalDurationSeconds = totalArrivalTime(quote?.swaps);
319
+ const totalTime = roundedSecondsToString(totalDurationSeconds);
315
320
  const totalFee = getTotalFeeInUsd(quote?.swaps ?? [], findToken);
316
321
  const fee = numberToString(
317
322
  totalFee,
@@ -320,6 +325,8 @@ export function Quote(props: QuoteProps) {
320
325
  );
321
326
 
322
327
  const feeWarning = totalFee.gte(new BigNumber(GAS_FEE_MAX));
328
+ const timeWarning =
329
+ totalDurationSeconds / SECONDS_IN_MINUTE >= ROUTE_TIME_MAX;
323
330
 
324
331
  return fullExpandedMode ? (
325
332
  <FullExpandedQuote
@@ -329,7 +336,18 @@ export function Quote(props: QuoteProps) {
329
336
  tooltipContainer={getExpanded()}
330
337
  steps={steps}
331
338
  tags={sortedQuoteTags}
332
- feeWarning={feeWarning}
339
+ quoteCost={
340
+ <QuoteCostDetails
341
+ quote={quote}
342
+ fullExpandedMode
343
+ time={totalTime}
344
+ fee={fee}
345
+ feeWarning={feeWarning}
346
+ timeWarning={timeWarning}
347
+ showModalFee={showModalFee}
348
+ steps={numberOfSteps}
349
+ />
350
+ }
333
351
  percentageChange={percentageChange}
334
352
  warningLevel={priceImpactWarningLevel}
335
353
  outputPrice={{
@@ -368,6 +386,7 @@ export function Quote(props: QuoteProps) {
368
386
  time={totalTime}
369
387
  fee={fee}
370
388
  feeWarning={feeWarning}
389
+ timeWarning={timeWarning}
371
390
  showModalFee={showModalFee}
372
391
  steps={numberOfSteps}
373
392
  />
@@ -48,5 +48,7 @@ export type QuoteCostDetailsProps = {
48
48
  fee: string;
49
49
  time: string;
50
50
  feeWarning?: boolean;
51
+ timeWarning?: boolean;
51
52
  showModalFee: boolean;
53
+ fullExpandedMode?: boolean;
52
54
  };
@@ -28,7 +28,6 @@ export const ModalContainer = styled('div', {
28
28
 
29
29
  export const ModalHeader = styled('div', {
30
30
  padding: '$20 $20 $10',
31
- textAlign: 'center',
32
31
  position: 'relative',
33
32
  '._icon-button': {
34
33
  position: 'absolute',
@@ -21,7 +21,7 @@ import {
21
21
  USD_VALUE_MAX_DECIMALS,
22
22
  USD_VALUE_MIN_DECIMALS,
23
23
  } from '../../constants/routing';
24
- import { getContainer } from '../../utils/common';
24
+ import { getContainer, getExpanded } from '../../utils/common';
25
25
  import { numberToString } from '../../utils/numbers';
26
26
  import { getFeesGroup, getTotalFeesInUsd, getUsdFee } from '../../utils/swap';
27
27
  import { WatermarkedModal } from '../common/WatermarkedModal';
@@ -57,9 +57,18 @@ const NonPayableFee = (props: { fee: BigNumber; label: string }) => {
57
57
  export function QuoteCostDetails(props: QuoteCostDetailsProps) {
58
58
  const [open, setOpen] = useState<boolean>(false);
59
59
  const [openCollapse, setOpenCollapse] = useState<boolean>(false);
60
- const { steps, quote, fee, time, feeWarning, showModalFee } = props;
60
+ const {
61
+ steps,
62
+ quote,
63
+ fee,
64
+ time,
65
+ feeWarning,
66
+ timeWarning,
67
+ showModalFee,
68
+ fullExpandedMode = false,
69
+ } = props;
61
70
  const swaps = quote?.swaps ?? [];
62
- const container = getContainer();
71
+ const container = fullExpandedMode ? getExpanded() : getContainer();
63
72
 
64
73
  const feesGroup = getFeesGroup(swaps);
65
74
 
@@ -76,6 +85,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
76
85
  }
77
86
  fee={fee}
78
87
  feeWarning={feeWarning}
88
+ timeWarning={timeWarning}
79
89
  time={time}
80
90
  steps={steps}
81
91
  tooltipGas={showModalFee ? i18n.t('View more info') : undefined}
@@ -85,8 +95,17 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
85
95
  <WatermarkedModal
86
96
  container={container}
87
97
  open={open}
98
+ anchor={fullExpandedMode ? 'center' : 'bottom'}
99
+ styles={{
100
+ container: {
101
+ maxWidth: fullExpandedMode ? '484px' : 'unset',
102
+ },
103
+ }}
88
104
  header={
89
- <ModalHeader>
105
+ <ModalHeader
106
+ style={{
107
+ textAlign: fullExpandedMode ? 'left' : 'center',
108
+ }}>
90
109
  <Typography variant="title" size="medium">
91
110
  {i18n.t('Gas & Fee Explanation')}
92
111
  </Typography>
@@ -33,3 +33,5 @@ export const HIGH_PRIORITY_TAGS: TagValue[] = [
33
33
  ];
34
34
 
35
35
  export const GAS_FEE_MAX = 30;
36
+ export const ROUTE_TIME_MAX = 15;
37
+ export const SECONDS_IN_MINUTE = 60;
@@ -4,6 +4,7 @@ export const Container = styled('div', {
4
4
  transition: 'width 0.2s, opacity 0.2s, margin-left 0.2s',
5
5
  height: '700px',
6
6
  width: '390px',
7
+ position: 'relative',
7
8
  opacity: 1,
8
9
  marginLeft: '$16',
9
10
  backgroundColor: '$neutral100',
@@ -64,7 +64,7 @@ export function ExpandedQuotes(props: PropTypes) {
64
64
  />
65
65
  <Content>
66
66
  <Quotes
67
- showModalFee={false}
67
+ showModalFee={true}
68
68
  fetch={fetch}
69
69
  hasSort={false}
70
70
  loading={loading}