@rango-dev/widget-embedded 0.23.1-next.2 → 0.23.1-next.21
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/AppRoutes.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -283
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +489 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/InProgressTransactionBadge.d.ts +4 -0
- package/dist/components/HeaderButtons/InProgressTransactionBadge.d.ts.map +1 -0
- package/dist/components/HeaderButtons/RefreshButton.d.ts.map +1 -1
- package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +1 -1
- package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.helpers.d.ts +8 -0
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.styles.d.ts +167 -1
- package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.types.d.ts +1 -0
- package/dist/components/NoResult/NoResult.types.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +165 -0
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.types.d.ts +1 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/Quote/QuoteTrigger.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
- package/dist/components/Quotes/Quotes.d.ts.map +1 -1
- package/dist/components/Quotes/Quotes.types.d.ts +1 -0
- package/dist/components/Quotes/Quotes.types.d.ts.map +1 -1
- package/dist/components/Quotes/SelectStrategy.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/common/ActivateTabAlert/ActivateTabAlert.d.ts.map +1 -1
- package/dist/constants/navigationRoutes.d.ts +0 -1
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/settings.d.ts +6 -0
- package/dist/constants/settings.d.ts.map +1 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -1
- package/dist/containers/ExpandedQuotes/ExpandedQuotes.d.ts.map +1 -1
- package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts +3 -1
- package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
- package/dist/containers/Settings/Lists.d.ts +3 -0
- package/dist/containers/Settings/Lists.d.ts.map +1 -0
- package/dist/hooks/useScreenDetect.d.ts +9 -0
- package/dist/hooks/useScreenDetect.d.ts.map +1 -0
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts.map +1 -1
- package/dist/types/config.d.ts +9 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/colors.d.ts +5 -3
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +2 -1
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +2 -0
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/ui.d.ts +5 -2
- package/dist/utils/ui.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/components/AppRoutes.tsx +0 -5
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +6 -12
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +7 -11
- package/src/components/ConfirmWalletsModal/WalletList.tsx +2 -2
- package/src/components/HeaderButtons/HeaderButtons.styles.ts +43 -2
- package/src/components/HeaderButtons/HeaderButtons.tsx +2 -0
- package/src/components/HeaderButtons/InProgressTransactionBadge.tsx +26 -0
- package/src/components/HeaderButtons/RefreshButton.tsx +2 -1
- package/src/components/HeaderButtons/UnreadNotificationsBadge.tsx +10 -2
- package/src/components/HeaderButtons/WalletButton.tsx +26 -6
- package/src/components/Layout/Layout.styles.ts +3 -0
- package/src/components/Layout/Layout.tsx +4 -4
- package/src/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.ts +1 -1
- package/src/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.tsx +4 -4
- package/src/components/NoResult/NoResult.helpers.ts +13 -0
- package/src/components/NoResult/NoResult.styles.ts +19 -1
- package/src/components/NoResult/NoResult.tsx +27 -16
- package/src/components/NoResult/NoResult.types.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.styles.ts +14 -1
- package/src/components/NotificationContent/NotificationContent.tsx +49 -39
- package/src/components/Quote/Quote.styles.ts +13 -14
- package/src/components/Quote/Quote.tsx +166 -145
- package/src/components/Quote/Quote.types.ts +1 -0
- package/src/components/Quote/QuoteTrigger.tsx +7 -8
- package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +1 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +2 -3
- package/src/components/Quotes/Quotes.tsx +21 -10
- package/src/components/Quotes/Quotes.types.ts +1 -0
- package/src/components/Quotes/SelectStrategy.tsx +3 -11
- package/src/components/Slippage/Slippage.tsx +11 -13
- package/src/components/SwapDetails/SwapDetails.tsx +1 -1
- package/src/components/TokenList/TokenList.tsx +9 -8
- package/src/components/common/ActivateTabAlert/ActivateTabAlert.tsx +2 -4
- package/src/constants/navigationRoutes.ts +0 -1
- package/src/constants/settings.ts +5 -0
- package/src/containers/App/App.styles.ts +0 -4
- package/src/containers/ExpandedQuotes/ExpandedQuotes.styles.ts +13 -0
- package/src/containers/ExpandedQuotes/ExpandedQuotes.tsx +5 -0
- package/src/containers/QuoteInfo/QuoteInfo.tsx +2 -0
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +1 -0
- package/src/containers/Settings/Lists.tsx +264 -0
- package/src/hooks/useScreenDetect.ts +49 -0
- package/src/hooks/useSwapInput.ts +7 -2
- package/src/pages/ConfirmSwapPage.tsx +7 -3
- package/src/pages/Home.tsx +31 -7
- package/src/pages/LiquiditySourcePage.tsx +4 -3
- package/src/pages/SettingsPage.tsx +6 -185
- package/src/store/slices/config.ts +2 -2
- package/src/store/slices/data.ts +8 -5
- package/src/store/slices/settings.ts +7 -3
- package/src/types/config.ts +9 -5
- package/src/utils/colors.ts +106 -75
- package/src/utils/configs.ts +12 -1
- package/src/utils/swap.ts +11 -0
- package/src/utils/ui.ts +7 -5
- package/dist/hooks/useMobileDetect.d.ts +0 -3
- package/dist/hooks/useMobileDetect.d.ts.map +0 -1
- package/dist/pages/ThemePage.d.ts +0 -3
- package/dist/pages/ThemePage.d.ts.map +0 -1
- package/src/hooks/useMobileDetect.ts +0 -21
- package/src/pages/ThemePage.tsx +0 -90
package/src/utils/colors.ts
CHANGED
|
@@ -1,68 +1,113 @@
|
|
|
1
1
|
import type { WidgetColors, WidgetColorsKeys } from '../types';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let [r, g, b]: any = col.match(/.{2}/g);
|
|
13
|
-
[r, g, b] = [
|
|
14
|
-
parseInt(r, RADIX) + amt,
|
|
15
|
-
parseInt(g, RADIX) + amt,
|
|
16
|
-
parseInt(b, RADIX) + amt,
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
r = Math.max(Math.min(RANGE, r), 0).toString(RADIX);
|
|
20
|
-
g = Math.max(Math.min(RANGE, g), 0).toString(RADIX);
|
|
21
|
-
b = Math.max(Math.min(RANGE, b), 0).toString(RADIX);
|
|
22
|
-
|
|
23
|
-
const rr = (r.length < 2 ? '0' : '') + r;
|
|
24
|
-
const gg = (g.length < 2 ? '0' : '') + g;
|
|
25
|
-
const bb = (b.length < 2 ? '0' : '') + b;
|
|
26
|
-
|
|
27
|
-
return `#${rr}${gg}${bb}`;
|
|
28
|
-
};
|
|
3
|
+
export function generateShades(
|
|
4
|
+
baseColor: string,
|
|
5
|
+
prefix: string,
|
|
6
|
+
reverse?: boolean
|
|
7
|
+
): { [key: string]: string } {
|
|
8
|
+
const BASE_SHADE_INDEX = 100;
|
|
9
|
+
const NUMBER_OF_COLORS = 9;
|
|
10
|
+
const SHADING_INCREMENT_MAX = 10; // For bright colors
|
|
11
|
+
const SHADING_INCREMENT_MIN = 6; // For dark colors
|
|
29
12
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(HALF_NUMBER_OF_COLORS - i) * AMT
|
|
44
|
-
),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
if (i === HALF_NUMBER_OF_COLORS) {
|
|
48
|
-
colors = {
|
|
49
|
-
...colors,
|
|
50
|
-
[name + i * COLOR_SUFFIX]: color,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (i > HALF_NUMBER_OF_COLORS) {
|
|
54
|
-
colors = {
|
|
55
|
-
...colors,
|
|
56
|
-
[name + i * COLOR_SUFFIX]: colorShade(
|
|
57
|
-
color,
|
|
58
|
-
-((i - HALF_NUMBER_OF_COLORS) * AMT)
|
|
59
|
-
),
|
|
60
|
-
};
|
|
13
|
+
const HALF_NUMBER_OF_COLORS = 4;
|
|
14
|
+
|
|
15
|
+
const shadeIncrements: number[] = [];
|
|
16
|
+
let increment = 90;
|
|
17
|
+
for (let i = 0; i < NUMBER_OF_COLORS; i++) {
|
|
18
|
+
shadeIncrements.push(increment);
|
|
19
|
+
if (i + 1 === HALF_NUMBER_OF_COLORS) {
|
|
20
|
+
increment = 0;
|
|
21
|
+
} else {
|
|
22
|
+
increment -=
|
|
23
|
+
i >= HALF_NUMBER_OF_COLORS
|
|
24
|
+
? SHADING_INCREMENT_MIN
|
|
25
|
+
: SHADING_INCREMENT_MAX;
|
|
61
26
|
}
|
|
62
27
|
}
|
|
63
28
|
|
|
64
|
-
|
|
65
|
-
|
|
29
|
+
// If 'reverse' is true, that means the color should be from dark to light
|
|
30
|
+
const decrementAmounts = reverse
|
|
31
|
+
? shadeIncrements.slice().reverse()
|
|
32
|
+
: shadeIncrements;
|
|
33
|
+
|
|
34
|
+
const shades: { [key: string]: string } = {};
|
|
35
|
+
|
|
36
|
+
// Generate shades
|
|
37
|
+
for (let i = 0; i < NUMBER_OF_COLORS; i++) {
|
|
38
|
+
const shadeIndex = BASE_SHADE_INDEX + i * BASE_SHADE_INDEX;
|
|
39
|
+
const decrementAmount = decrementAmounts[i];
|
|
40
|
+
|
|
41
|
+
const shade: { [key: string]: string } = {
|
|
42
|
+
[`${prefix}${shadeIndex}`]: generateShade(baseColor, decrementAmount),
|
|
43
|
+
};
|
|
44
|
+
Object.assign(shades, shade);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return { ...shades, [prefix]: baseColor };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function generateShade(
|
|
51
|
+
baseColor: string,
|
|
52
|
+
decrementAmount: number
|
|
53
|
+
): string {
|
|
54
|
+
const [r, g, b] = convertToRGB(baseColor);
|
|
55
|
+
return `#${clamp(r + decrementAmount)}${clamp(g + decrementAmount)}${clamp(
|
|
56
|
+
b + decrementAmount
|
|
57
|
+
)}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function convertToRGB(baseColor: string): number[] {
|
|
61
|
+
const COLOR_SLICE_START = 1;
|
|
62
|
+
const COLOR_SLICE_END = 3;
|
|
63
|
+
const BASE_COLOR_LENGTH = 7;
|
|
64
|
+
|
|
65
|
+
// Convert the base color to RGB components
|
|
66
|
+
const r: number = parseInt(
|
|
67
|
+
baseColor.slice(COLOR_SLICE_START, COLOR_SLICE_END),
|
|
68
|
+
16
|
|
69
|
+
);
|
|
70
|
+
const g: number = parseInt(
|
|
71
|
+
baseColor.slice(COLOR_SLICE_END, COLOR_SLICE_END + 2),
|
|
72
|
+
16
|
|
73
|
+
);
|
|
74
|
+
const b: number = parseInt(
|
|
75
|
+
baseColor.slice(COLOR_SLICE_END + 2, BASE_COLOR_LENGTH),
|
|
76
|
+
16
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return [r, g, b];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Function to clamp color component to valid range [0, 255] and convert to hex
|
|
83
|
+
function clamp(color: number): string {
|
|
84
|
+
const MAX_COLOR_VALUE = 255;
|
|
85
|
+
const HEX_BASE = 16;
|
|
86
|
+
const HEX_LENGTH = -2;
|
|
87
|
+
return (
|
|
88
|
+
'0' + Math.max(0, Math.min(MAX_COLOR_VALUE, color)).toString(HEX_BASE)
|
|
89
|
+
)
|
|
90
|
+
.slice(HEX_LENGTH)
|
|
91
|
+
.toUpperCase();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function isBright(baseColor: string) {
|
|
95
|
+
const BRIGHTNESS_THRESHOLD = 188;
|
|
96
|
+
const RED_COEFFICIENT = 299;
|
|
97
|
+
const GREEN_COEFFICIENT = 587;
|
|
98
|
+
const BLUE_COEFFICIENT = 114;
|
|
99
|
+
const BRIGHTNESS_DIVISOR = 1000;
|
|
100
|
+
|
|
101
|
+
const [r, g, b] = convertToRGB(baseColor);
|
|
102
|
+
const brightness =
|
|
103
|
+
(r * RED_COEFFICIENT + g * GREEN_COEFFICIENT + b * BLUE_COEFFICIENT) /
|
|
104
|
+
BRIGHTNESS_DIVISOR;
|
|
105
|
+
if (brightness > BRIGHTNESS_THRESHOLD) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
66
111
|
export const generateColors = (
|
|
67
112
|
mainColors: { [x: string]: string },
|
|
68
113
|
reverseNeutralRange: boolean,
|
|
@@ -83,25 +128,11 @@ export const generateColors = (
|
|
|
83
128
|
...listOfColors,
|
|
84
129
|
[colorKey]: color,
|
|
85
130
|
};
|
|
86
|
-
} else if (colorKey === 'neutral' && reverseNeutralRange) {
|
|
87
|
-
const range = generateRangeColors(colorKey, color);
|
|
88
|
-
listOfColors = {
|
|
89
|
-
...listOfColors,
|
|
90
|
-
// Reverse the neutral shade
|
|
91
|
-
[`${colorKey}100`]: range[`${colorKey}900`],
|
|
92
|
-
[`${colorKey}200`]: range[`${colorKey}800`],
|
|
93
|
-
[`${colorKey}300`]: range[`${colorKey}700`],
|
|
94
|
-
[`${colorKey}400`]: range[`${colorKey}600`],
|
|
95
|
-
[`${colorKey}500`]: range[`${colorKey}500`],
|
|
96
|
-
[`${colorKey}600`]: range[`${colorKey}400`],
|
|
97
|
-
[`${colorKey}700`]: range[`${colorKey}300`],
|
|
98
|
-
[`${colorKey}800`]: range[`${colorKey}200`],
|
|
99
|
-
[`${colorKey}900`]: range[`${colorKey}100`],
|
|
100
|
-
};
|
|
101
131
|
} else {
|
|
132
|
+
const reverse = colorKey === 'neutral' && reverseNeutralRange;
|
|
102
133
|
listOfColors = {
|
|
103
134
|
...listOfColors,
|
|
104
|
-
...
|
|
135
|
+
...generateShades(color, colorKey, reverse),
|
|
105
136
|
};
|
|
106
137
|
}
|
|
107
138
|
}
|
package/src/utils/configs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Tokens } from '../types';
|
|
1
|
+
import type { Tokens, WidgetVariant } from '../types';
|
|
2
2
|
import type { Asset, BlockchainMeta, Token } from 'rango-sdk';
|
|
3
3
|
|
|
4
4
|
import { RANGO_PUBLIC_API_KEY } from '../constants';
|
|
@@ -79,3 +79,14 @@ export const isBlockchainExcludedInConfig = (
|
|
|
79
79
|
!blockchainsConfig.includes(blockchain.name)
|
|
80
80
|
);
|
|
81
81
|
};
|
|
82
|
+
|
|
83
|
+
export const isVariantExpandable = (
|
|
84
|
+
isLargeScreen: boolean,
|
|
85
|
+
isExtraLargeScreen: boolean,
|
|
86
|
+
variant?: WidgetVariant
|
|
87
|
+
) => {
|
|
88
|
+
return (
|
|
89
|
+
(variant === 'expanded' && (isLargeScreen || isExtraLargeScreen)) ||
|
|
90
|
+
(variant === 'full-expanded' && isExtraLargeScreen)
|
|
91
|
+
);
|
|
92
|
+
};
|
package/src/utils/swap.ts
CHANGED
|
@@ -478,6 +478,7 @@ export function createQuoteRequestBody(params: {
|
|
|
478
478
|
affiliatePercent: number | null;
|
|
479
479
|
affiliateWallets: { [key: string]: string } | null;
|
|
480
480
|
destination?: string;
|
|
481
|
+
enableCentralizedSwappers?: boolean;
|
|
481
482
|
}): BestRouteRequest {
|
|
482
483
|
const {
|
|
483
484
|
fromToken,
|
|
@@ -493,6 +494,7 @@ export function createQuoteRequestBody(params: {
|
|
|
493
494
|
affiliatePercent,
|
|
494
495
|
affiliateWallets,
|
|
495
496
|
destination,
|
|
497
|
+
enableCentralizedSwappers,
|
|
496
498
|
} = params;
|
|
497
499
|
const selectedWalletsMap = selectedWallets?.reduce(
|
|
498
500
|
(
|
|
@@ -544,6 +546,7 @@ export function createQuoteRequestBody(params: {
|
|
|
544
546
|
),
|
|
545
547
|
swappersGroupsExclude: false,
|
|
546
548
|
}),
|
|
549
|
+
enableCentralizedSwappers,
|
|
547
550
|
};
|
|
548
551
|
return requestBody;
|
|
549
552
|
}
|
|
@@ -775,3 +778,11 @@ export function confirmSwapDisabled(
|
|
|
775
778
|
!isValidAddress(lastStepToBlockchain, customDestination))
|
|
776
779
|
);
|
|
777
780
|
}
|
|
781
|
+
|
|
782
|
+
export function isTokensIdentical(tokenA: Token, tokenB: Token) {
|
|
783
|
+
return (
|
|
784
|
+
tokenA.blockchain === tokenB.blockchain &&
|
|
785
|
+
tokenA.symbol === tokenB.symbol &&
|
|
786
|
+
tokenA.address === tokenB.address
|
|
787
|
+
);
|
|
788
|
+
}
|
package/src/utils/ui.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
2
|
import type { WidgetTheme } from '../types';
|
|
3
3
|
import type { createTheme } from '@rango-dev/ui';
|
|
4
|
-
import type React from 'react';
|
|
5
4
|
|
|
6
5
|
import {
|
|
7
6
|
theme as baseThemeTokens,
|
|
8
7
|
darkColors as defaultDarkColors,
|
|
9
8
|
} from '@rango-dev/ui';
|
|
9
|
+
import React from 'react';
|
|
10
10
|
|
|
11
11
|
import { generateColors } from '../utils/colors';
|
|
12
12
|
import { toHash } from '../utils/hash';
|
|
@@ -73,18 +73,20 @@ export function customizedThemeTokens(
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export function joinList(
|
|
76
|
-
list: React.JSX.Element[],
|
|
76
|
+
list: { element: React.JSX.Element; key: string }[],
|
|
77
77
|
divider: React.JSX.Element
|
|
78
78
|
) {
|
|
79
79
|
if (list.length <= 1) {
|
|
80
|
-
return list;
|
|
80
|
+
return list.map(({ element, key }) => React.cloneElement(element, { key }));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const output: React.JSX.Element[] = [];
|
|
84
84
|
list.forEach((item, index) => {
|
|
85
|
-
|
|
85
|
+
const { element, key } = item;
|
|
86
|
+
output.push(React.cloneElement(element, { key }));
|
|
86
87
|
if (index < list.length - 1) {
|
|
87
|
-
|
|
88
|
+
const key = `divider-${index}`;
|
|
89
|
+
output.push(React.cloneElement(divider, { key }));
|
|
88
90
|
}
|
|
89
91
|
});
|
|
90
92
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMobileDetect.d.ts","sourceRoot":"","sources":["../../src/hooks/useMobileDetect.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,eAAe,eAcpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemePage.d.ts","sourceRoot":"","sources":["../../src/pages/ThemePage.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,wBAAgB,SAAS,sBAiExB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
const MIN_WIDTH_WINDOW = 768;
|
|
4
|
-
|
|
5
|
-
const useMobileDetect = () => {
|
|
6
|
-
const [isMobile, setIsMobile] = useState(false);
|
|
7
|
-
|
|
8
|
-
const handleResize = () => {
|
|
9
|
-
setIsMobile(window.innerWidth < MIN_WIDTH_WINDOW);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
handleResize(); // Initial check
|
|
14
|
-
window.addEventListener('resize', handleResize);
|
|
15
|
-
return () => window.removeEventListener('resize', handleResize);
|
|
16
|
-
}, []);
|
|
17
|
-
|
|
18
|
-
return isMobile;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default useMobileDetect;
|
package/src/pages/ThemePage.tsx
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { i18n } from '@lingui/core';
|
|
2
|
-
import {
|
|
3
|
-
AutoThemeIcon,
|
|
4
|
-
DarkModeIcon,
|
|
5
|
-
LightModeIcon,
|
|
6
|
-
List,
|
|
7
|
-
ListItemButton,
|
|
8
|
-
Radio,
|
|
9
|
-
RadioRoot,
|
|
10
|
-
Typography,
|
|
11
|
-
} from '@rango-dev/ui';
|
|
12
|
-
import React from 'react';
|
|
13
|
-
|
|
14
|
-
import { Layout, PageContainer } from '../components/Layout';
|
|
15
|
-
import { useAppStore } from '../store/AppStore';
|
|
16
|
-
|
|
17
|
-
type Theme = 'dark' | 'light' | 'auto';
|
|
18
|
-
|
|
19
|
-
enum Mode {
|
|
20
|
-
DARK = 'dark',
|
|
21
|
-
LIGHT = 'light',
|
|
22
|
-
AUTO = 'auto',
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function ThemePage() {
|
|
26
|
-
const { setTheme, theme } = useAppStore();
|
|
27
|
-
|
|
28
|
-
const themesList = [
|
|
29
|
-
{
|
|
30
|
-
id: Mode.LIGHT,
|
|
31
|
-
value: Mode.LIGHT,
|
|
32
|
-
title: (
|
|
33
|
-
<Typography variant="title" size="xmedium">
|
|
34
|
-
{i18n.t('Light')}
|
|
35
|
-
</Typography>
|
|
36
|
-
),
|
|
37
|
-
onClick: () => setTheme(Mode.LIGHT as Theme),
|
|
38
|
-
start: <LightModeIcon color="gray" />,
|
|
39
|
-
end: <Radio value={Mode.LIGHT} />,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: Mode.DARK,
|
|
43
|
-
value: Mode.DARK,
|
|
44
|
-
title: (
|
|
45
|
-
<Typography variant="title" size="xmedium">
|
|
46
|
-
{i18n.t('Dark')}
|
|
47
|
-
</Typography>
|
|
48
|
-
),
|
|
49
|
-
onClick: () => setTheme(Mode.DARK as Theme),
|
|
50
|
-
start: <DarkModeIcon color="gray" />,
|
|
51
|
-
end: <Radio value={Mode.DARK} />,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: Mode.AUTO,
|
|
55
|
-
value: Mode.AUTO,
|
|
56
|
-
title: (
|
|
57
|
-
<Typography variant="title" size="xmedium">
|
|
58
|
-
{i18n.t('Auto')}
|
|
59
|
-
</Typography>
|
|
60
|
-
),
|
|
61
|
-
onClick: () => setTheme(Mode.AUTO as Theme),
|
|
62
|
-
start: <AutoThemeIcon color="gray" />,
|
|
63
|
-
end: <Radio value={Mode.AUTO} />,
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<Layout
|
|
69
|
-
header={{
|
|
70
|
-
title: i18n.t('Theme'),
|
|
71
|
-
}}>
|
|
72
|
-
<PageContainer>
|
|
73
|
-
<RadioRoot
|
|
74
|
-
onValueChange={(value) => setTheme(value as Theme)}
|
|
75
|
-
value={theme}>
|
|
76
|
-
<List
|
|
77
|
-
type={
|
|
78
|
-
<ListItemButton
|
|
79
|
-
title={i18n.t('Theme')}
|
|
80
|
-
id="_"
|
|
81
|
-
onClick={() => console.log()}
|
|
82
|
-
/>
|
|
83
|
-
}
|
|
84
|
-
items={themesList}
|
|
85
|
-
/>
|
|
86
|
-
</RadioRoot>
|
|
87
|
-
</PageContainer>
|
|
88
|
-
</Layout>
|
|
89
|
-
);
|
|
90
|
-
}
|