@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.
Files changed (134) hide show
  1. package/dist/components/AppRoutes.d.ts.map +1 -1
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -283
  3. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  4. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  5. package/dist/components/HeaderButtons/HeaderButtons.d.ts.map +1 -1
  6. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +489 -1
  7. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  8. package/dist/components/HeaderButtons/InProgressTransactionBadge.d.ts +4 -0
  9. package/dist/components/HeaderButtons/InProgressTransactionBadge.d.ts.map +1 -0
  10. package/dist/components/HeaderButtons/RefreshButton.d.ts.map +1 -1
  11. package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +1 -1
  12. package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
  13. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  14. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -1
  15. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  16. package/dist/components/NoResult/NoResult.d.ts.map +1 -1
  17. package/dist/components/NoResult/NoResult.helpers.d.ts +8 -0
  18. package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -1
  19. package/dist/components/NoResult/NoResult.styles.d.ts +167 -1
  20. package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
  21. package/dist/components/NoResult/NoResult.types.d.ts +1 -0
  22. package/dist/components/NoResult/NoResult.types.d.ts.map +1 -1
  23. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  24. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +165 -0
  25. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  26. package/dist/components/Quote/Quote.d.ts.map +1 -1
  27. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  28. package/dist/components/Quote/Quote.types.d.ts +1 -0
  29. package/dist/components/Quote/Quote.types.d.ts.map +1 -1
  30. package/dist/components/Quote/QuoteTrigger.d.ts.map +1 -1
  31. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
  32. package/dist/components/Quotes/Quotes.d.ts.map +1 -1
  33. package/dist/components/Quotes/Quotes.types.d.ts +1 -0
  34. package/dist/components/Quotes/Quotes.types.d.ts.map +1 -1
  35. package/dist/components/Quotes/SelectStrategy.d.ts.map +1 -1
  36. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  37. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  38. package/dist/components/common/ActivateTabAlert/ActivateTabAlert.d.ts.map +1 -1
  39. package/dist/constants/navigationRoutes.d.ts +0 -1
  40. package/dist/constants/navigationRoutes.d.ts.map +1 -1
  41. package/dist/constants/settings.d.ts +6 -0
  42. package/dist/constants/settings.d.ts.map +1 -0
  43. package/dist/containers/App/App.styles.d.ts.map +1 -1
  44. package/dist/containers/ExpandedQuotes/ExpandedQuotes.d.ts.map +1 -1
  45. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts +3 -1
  46. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
  47. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
  48. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +1 -0
  49. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
  50. package/dist/containers/Settings/Lists.d.ts +3 -0
  51. package/dist/containers/Settings/Lists.d.ts.map +1 -0
  52. package/dist/hooks/useScreenDetect.d.ts +9 -0
  53. package/dist/hooks/useScreenDetect.d.ts.map +1 -0
  54. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  55. package/dist/index.js +2 -2
  56. package/dist/index.js.map +4 -4
  57. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  58. package/dist/pages/Home.d.ts.map +1 -1
  59. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  60. package/dist/pages/SettingsPage.d.ts.map +1 -1
  61. package/dist/store/slices/data.d.ts.map +1 -1
  62. package/dist/store/slices/settings.d.ts.map +1 -1
  63. package/dist/types/config.d.ts +9 -5
  64. package/dist/types/config.d.ts.map +1 -1
  65. package/dist/utils/colors.d.ts +5 -3
  66. package/dist/utils/colors.d.ts.map +1 -1
  67. package/dist/utils/configs.d.ts +2 -1
  68. package/dist/utils/configs.d.ts.map +1 -1
  69. package/dist/utils/swap.d.ts +2 -0
  70. package/dist/utils/swap.d.ts.map +1 -1
  71. package/dist/utils/ui.d.ts +5 -2
  72. package/dist/utils/ui.d.ts.map +1 -1
  73. package/package.json +6 -6
  74. package/src/components/AppRoutes.tsx +0 -5
  75. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +6 -12
  76. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +7 -11
  77. package/src/components/ConfirmWalletsModal/WalletList.tsx +2 -2
  78. package/src/components/HeaderButtons/HeaderButtons.styles.ts +43 -2
  79. package/src/components/HeaderButtons/HeaderButtons.tsx +2 -0
  80. package/src/components/HeaderButtons/InProgressTransactionBadge.tsx +26 -0
  81. package/src/components/HeaderButtons/RefreshButton.tsx +2 -1
  82. package/src/components/HeaderButtons/UnreadNotificationsBadge.tsx +10 -2
  83. package/src/components/HeaderButtons/WalletButton.tsx +26 -6
  84. package/src/components/Layout/Layout.styles.ts +3 -0
  85. package/src/components/Layout/Layout.tsx +4 -4
  86. package/src/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.ts +1 -1
  87. package/src/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.tsx +4 -4
  88. package/src/components/NoResult/NoResult.helpers.ts +13 -0
  89. package/src/components/NoResult/NoResult.styles.ts +19 -1
  90. package/src/components/NoResult/NoResult.tsx +27 -16
  91. package/src/components/NoResult/NoResult.types.ts +1 -0
  92. package/src/components/NotificationContent/NotificationContent.styles.ts +14 -1
  93. package/src/components/NotificationContent/NotificationContent.tsx +49 -39
  94. package/src/components/Quote/Quote.styles.ts +13 -14
  95. package/src/components/Quote/Quote.tsx +166 -145
  96. package/src/components/Quote/Quote.types.ts +1 -0
  97. package/src/components/Quote/QuoteTrigger.tsx +7 -8
  98. package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +1 -1
  99. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +2 -3
  100. package/src/components/Quotes/Quotes.tsx +21 -10
  101. package/src/components/Quotes/Quotes.types.ts +1 -0
  102. package/src/components/Quotes/SelectStrategy.tsx +3 -11
  103. package/src/components/Slippage/Slippage.tsx +11 -13
  104. package/src/components/SwapDetails/SwapDetails.tsx +1 -1
  105. package/src/components/TokenList/TokenList.tsx +9 -8
  106. package/src/components/common/ActivateTabAlert/ActivateTabAlert.tsx +2 -4
  107. package/src/constants/navigationRoutes.ts +0 -1
  108. package/src/constants/settings.ts +5 -0
  109. package/src/containers/App/App.styles.ts +0 -4
  110. package/src/containers/ExpandedQuotes/ExpandedQuotes.styles.ts +13 -0
  111. package/src/containers/ExpandedQuotes/ExpandedQuotes.tsx +5 -0
  112. package/src/containers/QuoteInfo/QuoteInfo.tsx +2 -0
  113. package/src/containers/QuoteInfo/QuoteInfo.types.ts +1 -0
  114. package/src/containers/Settings/Lists.tsx +264 -0
  115. package/src/hooks/useScreenDetect.ts +49 -0
  116. package/src/hooks/useSwapInput.ts +7 -2
  117. package/src/pages/ConfirmSwapPage.tsx +7 -3
  118. package/src/pages/Home.tsx +31 -7
  119. package/src/pages/LiquiditySourcePage.tsx +4 -3
  120. package/src/pages/SettingsPage.tsx +6 -185
  121. package/src/store/slices/config.ts +2 -2
  122. package/src/store/slices/data.ts +8 -5
  123. package/src/store/slices/settings.ts +7 -3
  124. package/src/types/config.ts +9 -5
  125. package/src/utils/colors.ts +106 -75
  126. package/src/utils/configs.ts +12 -1
  127. package/src/utils/swap.ts +11 -0
  128. package/src/utils/ui.ts +7 -5
  129. package/dist/hooks/useMobileDetect.d.ts +0 -3
  130. package/dist/hooks/useMobileDetect.d.ts.map +0 -1
  131. package/dist/pages/ThemePage.d.ts +0 -3
  132. package/dist/pages/ThemePage.d.ts.map +0 -1
  133. package/src/hooks/useMobileDetect.ts +0 -21
  134. package/src/pages/ThemePage.tsx +0 -90
@@ -1,68 +1,113 @@
1
1
  import type { WidgetColors, WidgetColorsKeys } from '../types';
2
2
 
3
- export const colorShade = (col: string, amt: number) => {
4
- const RANGE = 255;
5
- const COL = 3;
6
- const RADIX = 16;
7
-
8
- col = col.replace(/^#/, '');
9
- if (col.length === COL) {
10
- col = col[0] + col[0] + col[1] + col[1] + col[2] + col[2];
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
- export const generateRangeColors = (name: string, color: string) => {
31
- const NUMBER_OF_COLORS = 10;
32
- const HALF_NUMBER_OF_COLORS = 5;
33
- const COLOR_SUFFIX = 100;
34
- const AMT = 25;
35
-
36
- let colors = { [name]: color };
37
- for (let i = 1; i < NUMBER_OF_COLORS; i++) {
38
- if (i < HALF_NUMBER_OF_COLORS) {
39
- colors = {
40
- ...colors,
41
- [name + i * COLOR_SUFFIX]: colorShade(
42
- color,
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
- return colors;
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
- ...generateRangeColors(colorKey, color),
135
+ ...generateShades(color, colorKey, reverse),
105
136
  };
106
137
  }
107
138
  }
@@ -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
- output.push(item);
85
+ const { element, key } = item;
86
+ output.push(React.cloneElement(element, { key }));
86
87
  if (index < list.length - 1) {
87
- output.push(divider);
88
+ const key = `divider-${index}`;
89
+ output.push(React.cloneElement(divider, { key }));
88
90
  }
89
91
  });
90
92
 
@@ -1,3 +0,0 @@
1
- declare const useMobileDetect: () => boolean;
2
- export default useMobileDetect;
3
- //# sourceMappingURL=useMobileDetect.d.ts.map
@@ -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,3 +0,0 @@
1
- import React from 'react';
2
- export declare function ThemePage(): React.JSX.Element;
3
- //# sourceMappingURL=ThemePage.d.ts.map
@@ -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;
@@ -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
- }