@rango-dev/widget-embedded 0.14.1-next.5 → 0.14.1-next.7

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 (66) hide show
  1. package/dist/components/BlockchainList/BlockchainList.styles.d.ts +6 -0
  2. package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
  3. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +3 -0
  4. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  5. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +45 -0
  6. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  7. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +9 -0
  8. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
  9. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +12 -0
  10. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  11. package/dist/components/Layout/Layout.styles.d.ts +9 -0
  12. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  13. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +3 -0
  14. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  15. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +9 -0
  16. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
  17. package/dist/components/NoRoutes/NoRoutes.styles.d.ts +9 -0
  18. package/dist/components/NoRoutes/NoRoutes.styles.d.ts.map +1 -1
  19. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +12 -0
  20. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  21. package/dist/components/RouteErrors/RouteErrors.styles.d.ts +12 -0
  22. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -1
  23. package/dist/components/SearchInput/SearchInput.styles.d.ts +3 -0
  24. package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  25. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +12 -0
  26. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  27. package/dist/components/Slippage/Slippage.styles.d.ts +12 -0
  28. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  29. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +18 -0
  30. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  31. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +3 -0
  32. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
  33. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +3 -0
  34. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
  35. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +12 -0
  36. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
  37. package/dist/components/TokenList/TokenList.styles.d.ts +30 -0
  38. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  39. package/dist/components/WalletModal/WalletModalContent.styles.d.ts +12 -0
  40. package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
  41. package/dist/constants/fonts.d.ts +2 -0
  42. package/dist/constants/fonts.d.ts.map +1 -0
  43. package/dist/{constants.d.ts → constants/index.d.ts} +1 -1
  44. package/dist/constants/index.d.ts.map +1 -0
  45. package/dist/hooks/useTheme.d.ts +1 -1
  46. package/dist/hooks/useTheme.d.ts.map +1 -1
  47. package/dist/index.d.ts +9 -6
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +1 -1
  50. package/dist/index.js.map +4 -4
  51. package/dist/types/config.d.ts +4 -10
  52. package/dist/types/config.d.ts.map +1 -1
  53. package/dist/utils/colors.d.ts +11 -0
  54. package/dist/utils/colors.d.ts.map +1 -0
  55. package/dist/utils/common.d.ts +0 -4
  56. package/dist/utils/common.d.ts.map +1 -1
  57. package/package.json +5 -5
  58. package/src/components/TokenList/TokenList.tsx +1 -1
  59. package/src/constants/fonts.ts +1 -0
  60. package/src/hooks/useTheme.ts +51 -11
  61. package/src/index.ts +33 -26
  62. package/src/types/config.ts +4 -10
  63. package/src/utils/colors.ts +93 -0
  64. package/src/utils/common.ts +0 -49
  65. package/dist/constants.d.ts.map +0 -1
  66. /package/src/{constants.ts → constants/index.ts} +0 -0
@@ -7,22 +7,16 @@ import type { Asset } from 'rango-sdk';
7
7
  * @property {string} background
8
8
  * @property {string} foreground
9
9
  * @property {string} primary
10
- * @property {string} success
11
- * @property {string} error
12
- * @property {string} warning
13
- * @property {string} surface
14
- * @property {string} neutral
10
+ * @property {string} secondary
15
11
  *
16
12
  */
13
+ export type WidgetColorsKeys = keyof WidgetColors;
17
14
  export type WidgetColors = {
18
15
  background?: string;
19
16
  foreground?: string;
20
- primary?: string;
21
- success?: string;
22
- error?: string;
23
- warning?: string;
24
- surface?: string;
25
17
  neutral?: string;
18
+ primary?: string;
19
+ secondary?: string;
26
20
  };
27
21
  /**
28
22
  * The `WidgetTheme` defines the properties of a widget theme, including mode, font family, colors, border
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EA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vB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;CACxB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { WidgetColors } from '../types';
2
+ export declare const colorShade: (col: string, amt: number) => string;
3
+ export declare const generateRangeColors: (name: string, color: string) => {
4
+ [x: string]: string;
5
+ };
6
+ export declare const generateColors: (mainColors: {
7
+ [x: string]: string;
8
+ }, colors?: WidgetColors) => {
9
+ [x: string]: string;
10
+ };
11
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/utils/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,UAAU,CAAC;AAE/D,eAAO,MAAM,UAAU,QAAS,MAAM,OAAO,MAAM,WAyBlD,CAAC;AAEF,eAAO,MAAM,mBAAmB,SAAU,MAAM,SAAS,MAAM;;CAkC9D,CAAC;AACF,eAAO,MAAM,cAAc;;YAEhB,YAAY;;CA0BtB,CAAC"}
@@ -2,9 +2,5 @@ export declare function removeDuplicateFrom<T>(array: T[]): T[];
2
2
  export declare function areEqual(array1: (number | string)[], array2: (number | string)[]): boolean;
3
3
  export declare function debounce(fn: Function, time: number): (...args: any) => void;
4
4
  export declare function containsText(text: string, searchText: string): boolean;
5
- export declare const colorShade: (col: string, amt: number) => string;
6
- export declare const generateRangeColors: (name: string, color: string) => {
7
- [x: string]: string;
8
- };
9
5
  export declare const getContainer: () => HTMLElement;
10
6
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AACA,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEtD;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC3B,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,WAK5B;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAGvB,GAAG,UAS9B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED,eAAO,MAAM,UAAU,QAAS,MAAM,OAAO,MAAM,WAqBlD,CAAC;AAEF,eAAO,MAAM,mBAAmB,SAAU,MAAM,SAAS,MAAM;;CAuB9D,CAAC;AAEF,eAAO,MAAM,YAAY,mBAC2B,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEtD;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC3B,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,WAK5B;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAGvB,GAAG,UAS9B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED,eAAO,MAAM,YAAY,mBAC2B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.14.1-next.5",
3
+ "version": "0.14.1-next.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,12 +19,12 @@
19
19
  "dependencies": {
20
20
  "@lingui/core": "4.2.1",
21
21
  "@lingui/react": "4.2.1",
22
- "@rango-dev/provider-all": "^0.17.1-next.0",
22
+ "@rango-dev/provider-all": "^0.17.1-next.1",
23
23
  "@rango-dev/queue-manager-core": "^0.17.0",
24
- "@rango-dev/queue-manager-rango-preset": "^0.17.1-next.0",
24
+ "@rango-dev/queue-manager-rango-preset": "^0.17.1-next.1",
25
25
  "@rango-dev/queue-manager-react": "^0.17.0",
26
- "@rango-dev/ui": "^0.17.1-next.2",
27
- "@rango-dev/wallets-react": "^0.3.0",
26
+ "@rango-dev/ui": "^0.17.1-next.4",
27
+ "@rango-dev/wallets-react": "^0.3.1-next.0",
28
28
  "@rango-dev/wallets-shared": "^0.17.0",
29
29
  "bignumber.js": "^9.1.1",
30
30
  "copy-to-clipboard": "^3.3.3",
@@ -24,7 +24,7 @@ import React, { forwardRef, useEffect, useState } from 'react';
24
24
  import { useAppStore } from '../../store/app';
25
25
  import { useMetaStore } from '../../store/meta';
26
26
  import { useWalletsStore } from '../../store/wallets';
27
- import { generateRangeColors } from '../../utils/common';
27
+ import { generateRangeColors } from '../../utils/colors';
28
28
 
29
29
  import { LoadingTokenList } from './LoadingTokenList';
30
30
  import {
@@ -0,0 +1 @@
1
+ export const DEFAULT_FONT_FAMILY = 'Roboto';
@@ -1,26 +1,36 @@
1
1
  import type { WidgetTheme } from '../types';
2
2
 
3
- import { createTheme, darkTheme, lightTheme } from '@rango-dev/ui';
3
+ import {
4
+ createTheme,
5
+ darkTheme,
6
+ lightTheme,
7
+ darkColors as mainDarkColors,
8
+ theme as mainTheme,
9
+ } from '@rango-dev/ui';
4
10
  import { useEffect, useState } from 'react';
5
11
 
12
+ import { DEFAULT_FONT_FAMILY } from '../constants/fonts';
6
13
  import { useMetaStore } from '../store/meta';
7
14
  import { useSettingsStore } from '../store/settings';
15
+ import { generateColors } from '../utils/colors';
8
16
  import {
9
17
  DEFAULT_PRIMARY_RADIUS,
10
18
  DEFAULT_SECONDARY_RADIUS,
11
19
  } from '../utils/configs';
12
20
 
13
- export function useTheme({
14
- // colors,
15
- fontFamily = 'Roboto',
16
- borderRadius = DEFAULT_PRIMARY_RADIUS,
17
- secondaryBorderRadius = DEFAULT_SECONDARY_RADIUS,
18
- mode = 'auto',
19
- }: WidgetTheme) {
21
+ export function useTheme(props: WidgetTheme) {
22
+ const {
23
+ colors,
24
+ fontFamily = DEFAULT_FONT_FAMILY,
25
+ borderRadius = DEFAULT_PRIMARY_RADIUS,
26
+ secondaryBorderRadius = DEFAULT_SECONDARY_RADIUS,
27
+ mode = 'auto',
28
+ } = props;
20
29
  const theme = useSettingsStore.use.theme();
30
+ const mainColors = mainTheme.colors;
31
+
21
32
  const fetchMeta = useMetaStore.use.fetchMeta();
22
33
  const setTheme = useSettingsStore.use.setTheme();
23
-
24
34
  const customTheme = createTheme({
25
35
  radii: {
26
36
  primary: `${borderRadius}px`,
@@ -31,8 +41,38 @@ export function useTheme({
31
41
  },
32
42
  });
33
43
 
34
- const lightClassName = `${customTheme.className} ${lightTheme.className}`;
35
- const darkClassName = `${customTheme.className} ${darkTheme.className}`;
44
+ const darkColors = generateColors(
45
+ {
46
+ ...mainColors,
47
+ ...mainDarkColors,
48
+ },
49
+ colors?.dark
50
+ );
51
+ const lightColors = generateColors(mainColors, colors?.light);
52
+ const customLightTheme = Object.keys(lightColors).length
53
+ ? createTheme({
54
+ colors: lightColors,
55
+ })
56
+ : lightTheme;
57
+ const customDarkTheme = Object.keys(darkColors).length
58
+ ? createTheme({
59
+ colors: {
60
+ ...darkColors,
61
+ neutral100: darkColors.neutral900,
62
+ neutral200: darkColors.neutral800,
63
+ neutral300: darkColors.neutral700,
64
+ neutral400: darkColors.neutral600,
65
+ neutral500: darkColors.neutral500,
66
+ neutral600: darkColors.neutral400,
67
+ neutral700: darkColors.neutral300,
68
+ neutral800: darkColors.neutral200,
69
+ neutral900: darkColors.neutral100,
70
+ },
71
+ })
72
+ : darkTheme;
73
+
74
+ const lightClassName = `${customTheme.className} ${customLightTheme.className}`;
75
+ const darkClassName = `${customTheme.className} ${customDarkTheme.className}`;
36
76
 
37
77
  const [OSTheme, setOSTheme] = useState('light');
38
78
 
package/src/index.ts CHANGED
@@ -1,46 +1,53 @@
1
- import {
2
- WidgetTheme,
3
- WidgetConfig,
4
- WidgetColors,
1
+ import type {
5
2
  BlockchainAndTokenConfig,
3
+ WidgetColors,
4
+ WidgetColorsKeys,
5
+ WidgetConfig,
6
+ WidgetTheme,
6
7
  } from './types';
7
- import { WidgetProps, Widget } from './Widget';
8
- import { WalletType } from '@rango-dev/wallets-shared';
9
- import { WidgetWallets } from './Wallets';
10
- import {
11
- useWallets,
12
- ProviderInterface,
13
- EventHandler as HandleWalletsUpdate,
14
- } from '@rango-dev/wallets-react';
15
- import {
16
- useEvents as useWidgetEvents,
17
- MainEvents,
18
- RouteEvent,
19
- StepEvent,
8
+ import type { WidgetProps } from './Widget';
9
+ import type {
20
10
  Route,
21
- Step,
11
+ RouteEvent,
12
+ RouteFailedEvent,
22
13
  RouteStartedEvent,
23
14
  RouteSucceededEvent,
24
- RouteFailedEvent,
25
- RouteEventType,
15
+ Step,
16
+ StepApprovalTxSucceededEvent,
17
+ StepCheckStatusEvent,
18
+ StepEvent,
19
+ StepFailedEvent,
20
+ StepOutputRevealedEvent,
26
21
  StepStartedEvent,
27
22
  StepSucceededEvent,
28
- StepFailedEvent,
29
- StepTxExecutionUpdatedEvent,
30
23
  StepTxExecutionBlockedEvent,
31
- StepCheckStatusEvent,
32
- StepApprovalTxSucceededEvent,
33
- StepOutputRevealedEvent,
24
+ StepTxExecutionUpdatedEvent,
25
+ } from '@rango-dev/queue-manager-rango-preset';
26
+ import type {
27
+ EventHandler as HandleWalletsUpdate,
28
+ ProviderInterface,
29
+ } from '@rango-dev/wallets-react';
30
+ import type { WalletType } from '@rango-dev/wallets-shared';
31
+
32
+ import {
33
+ MainEvents,
34
+ RouteEventType,
34
35
  StepEventType,
35
- StepExecutionEventStatus,
36
36
  StepExecutionBlockedEventStatus,
37
+ StepExecutionEventStatus,
38
+ useEvents as useWidgetEvents,
37
39
  } from '@rango-dev/queue-manager-rango-preset';
40
+ import { useWallets } from '@rango-dev/wallets-react';
41
+
42
+ import { WidgetWallets } from './Wallets';
43
+ import { Widget } from './Widget';
38
44
 
39
45
  export type {
40
46
  WidgetConfig,
41
47
  WalletType,
42
48
  WidgetTheme,
43
49
  WidgetColors,
50
+ WidgetColorsKeys,
44
51
  ProviderInterface,
45
52
  BlockchainAndTokenConfig,
46
53
  WidgetProps,
@@ -8,22 +8,16 @@ import type { Asset } from 'rango-sdk';
8
8
  * @property {string} background
9
9
  * @property {string} foreground
10
10
  * @property {string} primary
11
- * @property {string} success
12
- * @property {string} error
13
- * @property {string} warning
14
- * @property {string} surface
15
- * @property {string} neutral
11
+ * @property {string} secondary
16
12
  *
17
13
  */
14
+ export type WidgetColorsKeys = keyof WidgetColors;
18
15
  export type WidgetColors = {
19
16
  background?: string;
20
17
  foreground?: string;
21
- primary?: string;
22
- success?: string;
23
- error?: string;
24
- warning?: string;
25
- surface?: string;
26
18
  neutral?: string;
19
+ primary?: string;
20
+ secondary?: string;
27
21
  };
28
22
 
29
23
  /**
@@ -0,0 +1,93 @@
1
+ import type { WidgetColors, WidgetColorsKeys } from '../types';
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
+ };
29
+
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 = 32;
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
+ };
61
+ }
62
+ }
63
+ return colors;
64
+ };
65
+ export const generateColors = (
66
+ mainColors: { [x: string]: string },
67
+ colors?: WidgetColors
68
+ ) => {
69
+ if (!colors || !Object.entries(colors).length) {
70
+ return {};
71
+ }
72
+ let changeColors = false;
73
+ let listOfColors = { ...mainColors };
74
+ for (const colorKey in colors) {
75
+ const color = colors[colorKey as WidgetColorsKeys];
76
+
77
+ if (!!color && color !== mainColors[colorKey]) {
78
+ changeColors = true;
79
+ if (colorKey === 'background' || colorKey === 'foreground') {
80
+ listOfColors = {
81
+ ...listOfColors,
82
+ [colorKey]: color,
83
+ };
84
+ } else {
85
+ listOfColors = {
86
+ ...listOfColors,
87
+ ...generateRangeColors(colorKey, color),
88
+ };
89
+ }
90
+ }
91
+ }
92
+ return changeColors ? listOfColors : {};
93
+ };
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-magic-numbers */
2
1
  export function removeDuplicateFrom<T>(array: T[]): T[] {
3
2
  return Array.from(new Set(array));
4
3
  }
@@ -31,53 +30,5 @@ export function containsText(text: string, searchText: string): boolean {
31
30
  return text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
32
31
  }
33
32
 
34
- export const colorShade = (col: string, amt: number) => {
35
- col = col.replace(/^#/, '');
36
- if (col.length === 3) {
37
- col = col[0] + col[0] + col[1] + col[1] + col[2] + col[2];
38
- }
39
- let [r, g, b]: any = col.match(/.{2}/g);
40
- [r, g, b] = [
41
- parseInt(r, 16) + amt,
42
- parseInt(g, 16) + amt,
43
- parseInt(b, 16) + amt,
44
- ];
45
-
46
- r = Math.max(Math.min(255, r), 0).toString(16);
47
- g = Math.max(Math.min(255, g), 0).toString(16);
48
- b = Math.max(Math.min(255, b), 0).toString(16);
49
-
50
- const rr = (r.length < 2 ? '0' : '') + r;
51
- const gg = (g.length < 2 ? '0' : '') + g;
52
- const bb = (b.length < 2 ? '0' : '') + b;
53
-
54
- return `#${rr}${gg}${bb}`;
55
- };
56
-
57
- export const generateRangeColors = (name: string, color: string) => {
58
- let colors = { [name]: color };
59
- for (let i = 1; i < 10; i++) {
60
- if (i < 5) {
61
- colors = {
62
- ...colors,
63
- [name + i * 100]: colorShade(color, (5 - i) * 32),
64
- };
65
- }
66
- if (i === 5) {
67
- colors = {
68
- ...colors,
69
- [name + i * 100]: color,
70
- };
71
- }
72
- if (i > 5) {
73
- colors = {
74
- ...colors,
75
- [name + i * 100]: colorShade(color, -((i - 5) * 32)),
76
- };
77
- }
78
- }
79
- return colors;
80
- };
81
-
82
33
  export const getContainer = () =>
83
34
  document.getElementById('swap-box') as HTMLElement;
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,yCAAyC,CAAC"}
File without changes