@rango-dev/widget-embedded 0.1.16-next.0 → 0.1.16-next.10

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 (62) hide show
  1. package/dist/QueueManager.d.ts.map +1 -1
  2. package/dist/components/Layout.d.ts.map +1 -1
  3. package/dist/components/TokenInfo.d.ts.map +1 -1
  4. package/dist/hooks/useTheme.d.ts.map +1 -1
  5. package/dist/index.d.ts +9 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  8. package/dist/pages/Home.d.ts.map +1 -1
  9. package/dist/pages/SettingsPage.d.ts +2 -1
  10. package/dist/pages/SettingsPage.d.ts.map +1 -1
  11. package/dist/store/wallets.d.ts +6 -15
  12. package/dist/store/wallets.d.ts.map +1 -1
  13. package/dist/types/config.d.ts +11 -1
  14. package/dist/types/config.d.ts.map +1 -1
  15. package/dist/types/index.d.ts +1 -0
  16. package/dist/types/index.d.ts.map +1 -1
  17. package/dist/types/wallets.d.ts +7 -0
  18. package/dist/types/wallets.d.ts.map +1 -0
  19. package/dist/utils/common.d.ts +0 -1
  20. package/dist/utils/common.d.ts.map +1 -1
  21. package/dist/utils/routing.d.ts +2 -3
  22. package/dist/utils/routing.d.ts.map +1 -1
  23. package/dist/utils/swap.d.ts +8 -9
  24. package/dist/utils/swap.d.ts.map +1 -1
  25. package/dist/utils/wallets.d.ts +11 -12
  26. package/dist/utils/wallets.d.ts.map +1 -1
  27. package/dist/widget-embedded.cjs.development.js +161 -197
  28. package/dist/widget-embedded.cjs.development.js.map +1 -1
  29. package/dist/widget-embedded.cjs.production.min.js +161 -197
  30. package/dist/widget-embedded.cjs.production.min.js.map +1 -1
  31. package/dist/widget-embedded.esm.js +162 -198
  32. package/dist/widget-embedded.esm.js.map +1 -1
  33. package/package.json +10 -13
  34. package/src/QueueManager.tsx +4 -6
  35. package/src/components/AppRoutes.tsx +1 -1
  36. package/src/components/BottomLogo.tsx +1 -1
  37. package/src/components/Layout.tsx +27 -23
  38. package/src/components/RoutesOverview.tsx +2 -2
  39. package/src/components/TokenInfo.tsx +14 -13
  40. package/src/components/TokenPreview.tsx +6 -6
  41. package/src/hooks/useConfirmSwap.ts +2 -2
  42. package/src/hooks/useTheme.ts +42 -59
  43. package/src/index.tsx +144 -14
  44. package/src/pages/ConfirmSwapPage.tsx +27 -19
  45. package/src/pages/Home.tsx +5 -3
  46. package/src/pages/SettingsPage.tsx +3 -1
  47. package/src/store/bestRoute.ts +7 -7
  48. package/src/store/wallets.ts +32 -46
  49. package/src/types/config.ts +8 -1
  50. package/src/types/index.ts +1 -0
  51. package/src/types/wallets.ts +7 -0
  52. package/src/utils/common.ts +0 -21
  53. package/src/utils/routing.ts +2 -3
  54. package/src/utils/swap.ts +12 -11
  55. package/src/utils/wallets.ts +60 -63
  56. package/dist/App.d.ts +0 -9
  57. package/dist/App.d.ts.map +0 -1
  58. package/dist/lib.d.ts +0 -10
  59. package/dist/lib.d.ts.map +0 -1
  60. package/src/App.tsx +0 -123
  61. package/src/app.css +0 -12
  62. package/src/lib.tsx +0 -144
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.1.16-next.0",
3
+ "version": "0.1.16-next.10",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -10,11 +10,7 @@
10
10
  ],
11
11
  "browserslist": "> 0.5%, last 2 versions, not dead",
12
12
  "scripts": {
13
- "watch-tsc": "tsc --watch --noEmit",
14
- "dev": "parcel public/index.html -p 3001 --no-cache",
15
- "dev-tsc": "npm-run-all --parallel watch-tsc dev",
16
- "build:app": "parcel build --cache-dir=.parcel-cache",
17
- "build": "tsdx build --entry ./src/lib.tsx"
13
+ "build": "tsdx build --tsconfig ./tsconfig.json"
18
14
  },
19
15
  "husky": {
20
16
  "hooks": {
@@ -28,13 +24,13 @@
28
24
  "trailingComma": "es5"
29
25
  },
30
26
  "dependencies": {
31
- "@rango-dev/provider-all": "^0.1.12",
32
- "@rango-dev/queue-manager-core": "^0.1.12",
33
- "@rango-dev/queue-manager-rango-preset": "^0.1.12",
34
- "@rango-dev/queue-manager-react": "^0.1.11",
35
- "@rango-dev/ui": "^0.1.13",
36
- "@rango-dev/wallets-core": "^0.1.12",
37
- "@rango-dev/wallets-shared": "^0.1.11",
27
+ "@rango-dev/provider-all": "^0.1.14-next.4",
28
+ "@rango-dev/queue-manager-core": "^0.1.13-next.0",
29
+ "@rango-dev/queue-manager-rango-preset": "^0.1.13-next.1",
30
+ "@rango-dev/queue-manager-react": "^0.1.12-next.0",
31
+ "@rango-dev/ui": "^0.1.14-next.1",
32
+ "@rango-dev/wallets-core": "^0.1.14-next.0",
33
+ "@rango-dev/wallets-shared": "^0.1.13-next.0",
38
34
  "bignumber.js": "^9.1.1",
39
35
  "copy-to-clipboard": "^3.3.3",
40
36
  "dayjs": "^1.11.7",
@@ -50,6 +46,7 @@
50
46
  "react-dom": "^18.2.0",
51
47
  "react-i18next": "^12.2.0",
52
48
  "react-router-dom": "^6.8.0",
49
+ "values.js": "2.1.1",
53
50
  "zustand": "^4.3.2"
54
51
  },
55
52
  "publishConfig": {
@@ -34,13 +34,12 @@ function QueueManager(props: PropsWithChildren<{}>) {
34
34
  });
35
35
  }, []);
36
36
  const getOneOfWalletsDetails = useWalletsStore.use.getOneOfWalletsDetails();
37
- const accounts = useWalletsStore.use.accounts();
38
37
 
39
38
  const { blockchains } = useMetaStore.use.meta();
40
- const balances = useWalletsStore.use.balances();
39
+ const connectedWallets = useWalletsStore.use.connectedWallets();
41
40
 
42
41
  const wallets = {
43
- blockchains: balances.map((wallet) => ({
42
+ blockchains: connectedWallets.map((wallet) => ({
44
43
  accounts: [wallet],
45
44
  name: wallet.chain,
46
45
  })),
@@ -79,12 +78,12 @@ function QueueManager(props: PropsWithChildren<{}>) {
79
78
  lastStep?.id !== data.step?.id) ||
80
79
  !!outputAmount
81
80
  ) {
82
- const fromAccount = accounts.find(
81
+ const fromAccount = connectedWallets.find(
83
82
  (account) => account.chain === step?.fromBlockchain
84
83
  );
85
84
  const toAccount =
86
85
  step?.fromBlockchain !== step?.toBlockchain &&
87
- accounts.find((account) => account.chain === step?.toBlockchain);
86
+ connectedWallets.find((wallet) => wallet.chain === step?.toBlockchain);
88
87
 
89
88
  fromAccount && getOneOfWalletsDetails(fromAccount);
90
89
  toAccount && getOneOfWalletsDetails(toAccount);
@@ -112,7 +111,6 @@ function QueueManager(props: PropsWithChildren<{}>) {
112
111
 
113
112
  return (
114
113
  <ManagerProvider
115
- //@ts-ignore
116
114
  queuesDefs={[swapQueueDef]}
117
115
  context={context}
118
116
  onPersistedDataLoaded={(manager) => {
@@ -55,7 +55,7 @@ export function AppRoutes(props: PropTypes) {
55
55
  },
56
56
  {
57
57
  path: navigationRoutes.settings,
58
- element: <SettingsPage supportedSwappers={config?.liquiditySources} />,
58
+ element: <SettingsPage singleTheme= {config?.theme?.singleTheme} supportedSwappers={config?.liquiditySources} />,
59
59
  },
60
60
  {
61
61
  path: navigationRoutes.liquiditySources,
@@ -29,7 +29,7 @@ export function BottomLogo() {
29
29
 
30
30
  return (
31
31
  <Container>
32
- <Typography variant="caption" color="$neutrals600">
32
+ <Typography variant="caption" color="$neutral600">
33
33
  {t('Powered By')}
34
34
  </Typography>
35
35
  <StyledAnchor href="https://rango.exchange" target="_blank">
@@ -39,7 +39,7 @@ const WalletImageContainer = styled('div', {
39
39
  marginRight: '$6',
40
40
  '& img': {
41
41
  borderRadius: '50%',
42
- }
42
+ },
43
43
  });
44
44
 
45
45
  export type LayoutProps = {
@@ -48,10 +48,10 @@ export type LayoutProps = {
48
48
 
49
49
  export function Layout({ config }: LayoutProps) {
50
50
  const navigate = useNavigate();
51
- const { balances, accounts, selectedWallets } = useWalletsStore();
51
+ const { connectedWallets, selectedWallets } = useWalletsStore();
52
52
  const { getWalletInfo } = useWallets();
53
53
  const connectedWalletsImages = removeDuplicateFrom(
54
- getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(
54
+ getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo).map(
55
55
  (w) => w.image
56
56
  )
57
57
  );
@@ -63,7 +63,7 @@ export function Layout({ config }: LayoutProps) {
63
63
  const setInputAmount = useBestRouteStore.use.setInputAmount();
64
64
  const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
65
65
 
66
- const totalBalance = calculateWalletUsdValue(balances);
66
+ const totalBalance = calculateWalletUsdValue(connectedWallets);
67
67
  const connectWalletsButtonDisabled =
68
68
  useUiStore.use.connectWalletsButtonDisabled();
69
69
  const loadingMetaStatus = useMetaStore.use.loadingStatus();
@@ -71,31 +71,35 @@ export function Layout({ config }: LayoutProps) {
71
71
 
72
72
  const { t } = useTranslation();
73
73
  useEffect(() => {
74
- const chain = blockchains.find(
75
- (chain) => chain.name === config?.to?.blockchain
76
- );
77
- const token = tokens.find((t) =>
78
- tokensAreEqual(t, config?.to?.token || null)
79
- );
80
- setToChain(chain || null);
81
- setToToken(token || null);
82
- }, [config?.to?.token, config?.to?.blockchain]);
74
+ if (loadingMetaStatus === 'success') {
75
+ const chain = blockchains.find(
76
+ (chain) => chain.name === config?.to?.blockchain
77
+ );
78
+ const token = tokens.find((t) =>
79
+ tokensAreEqual(t, config?.to?.token || null)
80
+ );
81
+ setToChain(chain || null);
82
+ setToToken(token || null);
83
+ }
84
+ }, [config?.to?.token, config?.to?.blockchain, loadingMetaStatus]);
83
85
 
84
86
  useEffect(() => {
85
87
  setInputAmount(config?.amount?.toString() || '');
86
88
  }, [config?.amount]);
87
89
 
88
90
  useEffect(() => {
89
- const chain = blockchains.find(
90
- (chain) => chain.name === config?.from?.blockchain
91
- );
92
- const token = tokens.find((t) =>
93
- tokensAreEqual(t, config?.from?.token || null)
94
- );
91
+ if (loadingMetaStatus === 'success') {
92
+ const chain = blockchains.find(
93
+ (chain) => chain.name === config?.from?.blockchain
94
+ );
95
+ const token = tokens.find((t) =>
96
+ tokensAreEqual(t, config?.from?.token || null)
97
+ );
95
98
 
96
- setFromChain(chain || null);
97
- setFromToken(token || null);
98
- }, [config?.from?.token, config?.from?.blockchain]);
99
+ setFromChain(chain || null);
100
+ setFromToken(token || null);
101
+ }
102
+ }, [config?.from?.token, config?.from?.blockchain, loadingMetaStatus]);
99
103
 
100
104
  useEffect(() => {
101
105
  setAffiliateRef(config?.affiliateRef || null);
@@ -126,7 +130,7 @@ export function Layout({ config }: LayoutProps) {
126
130
  )}
127
131
  <div className="balance">
128
132
  <Typography variant="body2">
129
- {!accounts?.length
133
+ {!connectedWallets?.length
130
134
  ? t('Connect Wallet')
131
135
  : `$${totalBalance || 0}`}
132
136
  </Typography>
@@ -8,8 +8,8 @@ export const Container = styled('div', {
8
8
  justifyContent: 'space-between',
9
9
  padding: '$8',
10
10
  borderRadius: '$5',
11
- backgroundColor: '$neutrals300',
12
- color: '$neutrals800',
11
+ backgroundColor: '$neutral100',
12
+ color: '$neutral800',
13
13
  fontSize: '$12',
14
14
 
15
15
  '.routes': {
@@ -37,7 +37,7 @@ const Box = styled('div', {
37
37
  display: 'flex',
38
38
  flexDirection: 'column',
39
39
  width: '100%',
40
- overflow: 'hidden'
40
+ overflow: 'hidden',
41
41
  });
42
42
 
43
43
  const Container = styled('div', {
@@ -48,10 +48,11 @@ const Container = styled('div', {
48
48
  variants: {
49
49
  type: {
50
50
  filled: {
51
- backgroundColor: '$neutrals300',
51
+ backgroundColor: '$neutral100',
52
52
  },
53
53
  outlined: {
54
- border: '1px solid $neutrals300',
54
+ border: '1px solid $neutral100',
55
+ backgroundColor: '$surface',
55
56
  },
56
57
  },
57
58
  },
@@ -105,7 +106,7 @@ const Options = styled('div', {
105
106
  const ImagePlaceholder = styled('span', {
106
107
  width: '24px',
107
108
  height: '24px',
108
- backgroundColor: '$neutrals300',
109
+ backgroundColor: '$neutral100',
109
110
  borderRadius: '99999px',
110
111
  });
111
112
 
@@ -113,7 +114,7 @@ const OutputContainer = styled('div', {
113
114
  windth: '100%',
114
115
  height: '$48',
115
116
  borderRadius: '$5',
116
- backgroundColor: '$background',
117
+ backgroundColor: '$surface',
117
118
  border: '1px solid transparent',
118
119
  position: 'relative',
119
120
  display: 'flex',
@@ -132,7 +133,7 @@ export function TokenInfo(props: PropTypes) {
132
133
  const setInputAmount = useBestRouteStore.use.setInputAmount();
133
134
  const bestRoute = useBestRouteStore.use.bestRoute();
134
135
  const inputAmount = useBestRouteStore.use.inputAmount();
135
- const balances = useWalletsStore.use.balances();
136
+ const connectedWallets = useWalletsStore.use.connectedWallets();
136
137
  const fetchingBestRoute = useBestRouteStore.use.loading();
137
138
  const navigate = useNavigate();
138
139
  const { t } = useTranslation();
@@ -141,7 +142,7 @@ export function TokenInfo(props: PropTypes) {
141
142
  !!fromChain && !!fromToken
142
143
  ? numberToString(
143
144
  getBalanceFromWallet(
144
- balances,
145
+ connectedWallets,
145
146
  fromChain?.name,
146
147
  fromToken?.symbol,
147
148
  fromToken?.address
@@ -154,13 +155,13 @@ export function TokenInfo(props: PropTypes) {
154
155
  !!fromChain && !!fromToken
155
156
  ? numberToString(
156
157
  getBalanceFromWallet(
157
- balances,
158
+ connectedWallets,
158
159
  fromChain?.name,
159
160
  fromToken?.symbol,
160
161
  fromToken?.address
161
162
  )?.amount || '0',
162
163
  getBalanceFromWallet(
163
- balances,
164
+ connectedWallets,
164
165
  fromChain?.name,
165
166
  fromToken?.symbol,
166
167
  fromToken?.address
@@ -185,7 +186,7 @@ export function TokenInfo(props: PropTypes) {
185
186
  <Box>
186
187
  <Container type={props.type === 'From' ? 'filled' : 'outlined'}>
187
188
  <div className="head">
188
- <Typography variant="body2" color="neutrals800">
189
+ <Typography variant="body2" color="neutral800">
189
190
  {t(type)}
190
191
  </Typography>
191
192
  {props.type === 'From' ? (
@@ -197,7 +198,7 @@ export function TokenInfo(props: PropTypes) {
197
198
  setInputAmount(tokenBalanceReal.split(',').join(''));
198
199
  }}
199
200
  >
200
- <Typography variant="body3" color="neutrals600">{`${t(
201
+ <Typography variant="body3" color="neutral600">{`${t(
201
202
  'Balance'
202
203
  )}: ${tokenBalance} ${fromToken?.symbol || ''}`}</Typography>
203
204
  <Spacer size={4} />
@@ -215,7 +216,7 @@ export function TokenInfo(props: PropTypes) {
215
216
  <div>
216
217
  <Typography
217
218
  variant="caption"
218
- color="neutrals600"
219
+ color="neutral600"
219
220
  >{`$${numberToString(props.outputUsdValue)}`}</Typography>
220
221
  </div>
221
222
  </div>
@@ -293,7 +294,7 @@ export function TokenInfo(props: PropTypes) {
293
294
  >
294
295
  <Typography
295
296
  variant="caption"
296
- color="neutrals800"
297
+ color="neutral800"
297
298
  >{`$${numberToString(inputUsdValue)}`}</Typography>
298
299
  </span>
299
300
  }
@@ -27,10 +27,10 @@ const Container = styled('div', {
27
27
  variants: {
28
28
  type: {
29
29
  filled: {
30
- backgroundColor: '$neutrals300',
30
+ backgroundColor: '$neutral100',
31
31
  },
32
32
  outlined: {
33
- border: '1px solid $neutrals300',
33
+ border: '1px solid $neutral100',
34
34
  },
35
35
  },
36
36
  },
@@ -70,7 +70,7 @@ const Container = styled('div', {
70
70
  const ImagePlaceholder = styled('span', {
71
71
  width: '24px',
72
72
  height: '24px',
73
- backgroundColor: '$neutrals300',
73
+ backgroundColor: '$neutral100',
74
74
  borderRadius: '99999px',
75
75
  });
76
76
 
@@ -78,7 +78,7 @@ const OutputContainer = styled('div', {
78
78
  windth: '100%',
79
79
  height: '$48',
80
80
  borderRadius: '$5',
81
- backgroundColor: '$background',
81
+ backgroundColor: '$surface',
82
82
  border: '1px solid transparent',
83
83
  position: 'relative',
84
84
  display: 'flex',
@@ -123,7 +123,7 @@ export function TokenPreview(props: PropTypes) {
123
123
  <Box>
124
124
  <Container type={'outlined'}>
125
125
  <div className="head">
126
- <Typography variant="body2" color="neutrals800">
126
+ <Typography variant="body2" color="neutral800">
127
127
  {props.label}
128
128
  </Typography>
129
129
  <div>
@@ -131,7 +131,7 @@ export function TokenPreview(props: PropTypes) {
131
131
  {props.usdValue && (
132
132
  <Typography
133
133
  variant="caption"
134
- color="neutrals600"
134
+ color="neutral600"
135
135
  className="usd-value"
136
136
  >{`$${numberToString(props.usdValue)}`}</Typography>
137
137
  )}
@@ -51,7 +51,7 @@ export function useConfirmSwap(): ConfirmSwap {
51
51
  const inputUsdValue = useBestRouteStore.use.inputUsdValue();
52
52
  const affiliateRef = useSettingsStore.use.affiliateRef();
53
53
 
54
- const accounts = useWalletsStore.use.accounts();
54
+ const connectedWallets = useWalletsStore.use.connectedWallets();
55
55
  const selectedWallets = useWalletsStore.use.selectedWallets();
56
56
  const meta = useMetaStore.use.meta();
57
57
  const customSlippage = useSettingsStore.use.customSlippage();
@@ -108,7 +108,7 @@ export function useConfirmSwap(): ConfirmSwap {
108
108
  fromToken,
109
109
  toToken,
110
110
  inputAmount,
111
- accounts,
111
+ connectedWallets,
112
112
  selectedWallets,
113
113
  disabledLiquiditySources,
114
114
  userSlippage,
@@ -1,9 +1,8 @@
1
- import { createTheme } from '@rango-dev/ui';
1
+ import { createTheme, generateRangeColors } from '@rango-dev/ui';
2
2
  import { useState, useEffect, useLayoutEffect } from 'react';
3
3
  import { useMetaStore } from '../store/meta';
4
4
  import { useSettingsStore } from '../store/settings';
5
5
  import { WidgetTheme } from '../types';
6
- import { shadeColor } from '../utils/common';
7
6
  import usePrevious from './usePrevious';
8
7
 
9
8
  export function useTheme({
@@ -15,98 +14,81 @@ export function useTheme({
15
14
  const theme = useSettingsStore.use.theme();
16
15
  const fetchMeta = useMetaStore.use.fetchMeta();
17
16
  const setTheme = useSettingsStore.use.setTheme();
17
+ const light = themeColors?.light;
18
+ const dark = themeColors?.dark;
19
+ const neutral = light?.neutral || '#fafafa';
20
+ const background = light?.background || '#fff';
21
+ const foreground = light?.foreground || '#000';
18
22
 
19
- const primary = themeColors?.primary || '#5FA425',
20
- background = themeColors?.background || '#fff',
21
- foreground = themeColors?.foreground || '#000',
22
- error = themeColors?.error || '#FF0000',
23
- warning = themeColors?.warning || '#F5A623',
24
- success = themeColors?.success || '#0070F3';
25
- const colors = {
26
- neutrals200: '#FAFAFA',
27
- neutrals300: '#f2f2f2',
28
- neutrals400: '#dedede',
29
- neutrals500: '#cccccc',
30
- neutrals600: '#acacac',
31
- neutrals700: '#444444',
32
- neutrals800: '#333333',
33
- neutrals900: '#111111',
34
- primary,
35
- primary100: shadeColor(primary, 15),
36
- primary200: shadeColor(primary, -10),
37
- primary300: shadeColor(primary, -15),
38
- primary400: shadeColor(primary, -20),
39
- primary500: shadeColor(primary, -25),
40
- primary600: shadeColor(primary, -30),
41
- primary700: shadeColor(primary, -35),
42
- primary800: shadeColor(primary, -40),
43
- primary900: shadeColor(primary, -45),
23
+ const darkColors = {
24
+ ...generateRangeColors('primary', 'dark', dark?.primary),
25
+ ...generateRangeColors('error', 'dark', dark?.error),
26
+ ...generateRangeColors('warning', 'dark', dark?.warning),
27
+ ...generateRangeColors('success', 'dark', dark?.success),
28
+ ...generateRangeColors('neutral', 'dark', dark?.neutral),
29
+ surface: dark?.surface,
30
+ background: dark?.background,
31
+ foreground: dark?.foreground,
32
+ };
33
+
34
+ const lightColors = {
35
+ surface: light?.surface || '#fff',
36
+ ...generateRangeColors('primary', 'light', light?.primary || '#5FA425'),
37
+ ...generateRangeColors('error', 'light', light?.error || '#FF0000'),
38
+ ...generateRangeColors('warning', 'light', light?.warning || '#F5A623'),
39
+ ...generateRangeColors('success', 'light', light?.success || '#0070F3'),
40
+ ...generateRangeColors('neutral', 'light', neutral),
44
41
  background,
45
42
  foreground,
46
- error,
47
- error100: shadeColor(error, 50),
48
- error300: shadeColor(error, -10),
49
- error500: shadeColor(error, -20),
50
- error700: shadeColor(error, -30),
51
- warning,
52
- warning100: shadeColor(warning, 50),
53
- warning300: shadeColor(warning, -10),
54
- warning500: shadeColor(warning, -20),
55
- warning700: shadeColor(warning, -30),
56
- success,
57
- success100: shadeColor(success, 50),
58
- success300: shadeColor(success, -10),
59
- success500: shadeColor(success, -20),
60
- success700: shadeColor(success, -30),
61
43
  };
62
44
 
63
45
  const customeLightTheme = createTheme({
64
- colors,
46
+ colors: lightColors,
65
47
  radii: {
66
48
  5: `${borderRadius}px`,
67
49
  },
68
50
  shadows: {
69
- s: '0px 3px 5px 3px #f0f2f5, 0px 6px 10px 3px #f0f2f5, 0px 1px 18px 3px #f0f2f5',
51
+ s: `0px 3px 5px 3px ${light?.neutral || '#f0f2f5'} ,0px 6px 10px 3px ${
52
+ light?.neutral || '#f0f2f5'
53
+ }, 0px 1px 18px 3px ${light?.neutral || '#f0f2f5'}`,
70
54
  },
71
55
  });
72
56
 
73
57
  const customeDarkTheme = createTheme({
74
58
  colors: {
75
- ...colors,
76
- neutrals200: '#111111',
77
- neutrals300: '#333333',
78
- neutrals400: '#444444',
79
- neutrals500: '#acacac',
80
- neutrals600: '#cccccc',
81
- neutrals700: '#dedede',
82
- neutrals800: '#f2f2f2',
83
- neutrals900: '#FAFAFA',
59
+ ...lightColors,
60
+ ...generateRangeColors('neutral', 'dark', '#111111'),
84
61
  foreground: background,
85
62
  background: foreground,
63
+ surface: '#000',
64
+ ...JSON.parse(JSON.stringify(darkColors)),
86
65
  },
87
66
  radii: {
88
67
  5: `${borderRadius}px`,
89
68
  },
90
69
  shadows: {
91
- s: '0px 3px 5px 3px #222, 0px 6px 10px 3px #222, 0px 1px 18px 3px #222',
70
+ s: `0px 3px 5px 3px ${dark?.neutral || '#222'}, 0px 6px 10px 3px ${
71
+ dark?.neutral || '#222'
72
+ }, 0px 1px 18px 3px ${dark?.neutral || '#222'}`,
92
73
  },
93
74
  });
94
- const [OSTheme, setOSTheme] = useState(customeLightTheme);
75
+ const [OSTheme, setOSTheme] = useState('light');
76
+
95
77
  useEffect(() => {
96
78
  (async () => {
97
79
  await fetchMeta();
98
80
  })();
99
81
 
100
82
  const switchTheme = (event: MediaQueryListEvent) => {
101
- if (event.matches) setOSTheme(customeDarkTheme);
102
- else setOSTheme(customeLightTheme);
83
+ if (event.matches) setOSTheme('dark');
84
+ else setOSTheme('light');
103
85
  };
104
86
 
105
87
  if (
106
88
  window.matchMedia &&
107
89
  window.matchMedia('(prefers-color-scheme: dark)').matches
108
90
  ) {
109
- setOSTheme(customeDarkTheme);
91
+ setOSTheme('dark');
110
92
  }
111
93
 
112
94
  window
@@ -131,7 +113,8 @@ export function useTheme({
131
113
  }, [fontFamily]);
132
114
 
133
115
  const getActiveTheme = () => {
134
- if (theme === 'auto') return OSTheme;
116
+ if (theme === 'auto')
117
+ return OSTheme === 'dark' ? customeDarkTheme : customeLightTheme;
135
118
  else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
136
119
  };
137
120