@rango-dev/widget-embedded 0.1.16-next.2 → 0.1.16-next.8
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/TokenInfo.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +2 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/types/config.d.ts +11 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +0 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +78 -110
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +78 -110
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +79 -111
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +9 -8
- package/src/components/AppRoutes.tsx +1 -1
- package/src/components/BottomLogo.tsx +1 -1
- package/src/components/RoutesOverview.tsx +2 -2
- package/src/components/TokenInfo.tsx +9 -8
- package/src/components/TokenPreview.tsx +6 -6
- package/src/hooks/useTheme.ts +42 -59
- package/src/pages/ConfirmSwapPage.tsx +25 -17
- package/src/pages/SettingsPage.tsx +3 -1
- package/src/types/config.ts +8 -1
- package/src/utils/common.ts +0 -21
- package/src/utils/wallets.ts +1 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletState, InfoCircleIcon, Typography, Button, Image, Spacer, styled, ChevronRightIcon, GasIcon, Alert, ConfirmSwap, LoadingFailedAlert, History, AngleDownIcon, TextField, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, Wallet, useCopyToClipboard, SwapHistory, AddWalletIcon, globalCss, createTheme, SwapContainer } from '@rango-dev/ui';
|
|
1
|
+
import { WalletState, InfoCircleIcon, Typography, Button, Image, Spacer, styled, ChevronRightIcon, GasIcon, Alert, ConfirmSwap, LoadingFailedAlert, History, AngleDownIcon, TextField, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, Wallet, useCopyToClipboard, SwapHistory, AddWalletIcon, globalCss, generateRangeColors, createTheme, SwapContainer } from '@rango-dev/ui';
|
|
2
2
|
import React, { useRef, useEffect, Fragment, useState, useLayoutEffect, useMemo } from 'react';
|
|
3
3
|
import { useInRouterContext, MemoryRouter } from 'react-router';
|
|
4
4
|
import { PendingSwapNetworkStatus, useQueueManager, calculatePendingSwap, getCurrentStep, getCurrentBlockchainOfOrNull, getRelatedWalletOrNull, cancelSwap, makeQueueDefinition, checkWaitingForNetworkChange } from '@rango-dev/queue-manager-rango-preset';
|
|
@@ -29,24 +29,6 @@ function removeDuplicateFrom(array) {
|
|
|
29
29
|
function areEqual(array1, array2) {
|
|
30
30
|
return array1.length === array2.length && array1.every((v, i) => v === array2[i]);
|
|
31
31
|
}
|
|
32
|
-
function shadeColor(color, percent) {
|
|
33
|
-
var R = parseInt(color.substring(1, 3), 16);
|
|
34
|
-
var G = parseInt(color.substring(3, 5), 16);
|
|
35
|
-
var B = parseInt(color.substring(5, 7), 16);
|
|
36
|
-
R = R * (100 + percent) / 100;
|
|
37
|
-
G = G * (100 + percent) / 100;
|
|
38
|
-
B = B * (100 + percent) / 100;
|
|
39
|
-
R = R < 255 ? R : 255;
|
|
40
|
-
G = G < 255 ? G : 255;
|
|
41
|
-
B = B < 255 ? B : 255;
|
|
42
|
-
R = Math.round(R);
|
|
43
|
-
G = Math.round(G);
|
|
44
|
-
B = Math.round(B);
|
|
45
|
-
var RR = R.toString(16).length == 1 ? '0' + R.toString(16) : R.toString(16);
|
|
46
|
-
var GG = G.toString(16).length == 1 ? '0' + G.toString(16) : G.toString(16);
|
|
47
|
-
var BB = B.toString(16).length == 1 ? '0' + B.toString(16) : B.toString(16);
|
|
48
|
-
return '#' + RR + GG + BB;
|
|
49
|
-
}
|
|
50
32
|
function debounce(fn, time) {
|
|
51
33
|
let timeoutId;
|
|
52
34
|
return wrapper;
|
|
@@ -310,8 +292,8 @@ function getStateWallet(state) {
|
|
|
310
292
|
return WalletState.DISCONNECTED;
|
|
311
293
|
}
|
|
312
294
|
}
|
|
295
|
+
const excludedWallets = [WalletType.UNKNOWN, WalletType.LEAP];
|
|
313
296
|
function getlistWallet(getState, getWalletInfo, list) {
|
|
314
|
-
const excludedWallets = [WalletType.UNKNOWN, WalletType.TERRA_STATION, WalletType.LEAP];
|
|
315
297
|
return list.filter(wallet => !excludedWallets.includes(wallet)).map(type => {
|
|
316
298
|
const {
|
|
317
299
|
name,
|
|
@@ -1359,10 +1341,10 @@ const Container = /*#__PURE__*/styled('div', {
|
|
|
1359
1341
|
variants: {
|
|
1360
1342
|
type: {
|
|
1361
1343
|
filled: {
|
|
1362
|
-
backgroundColor: '$
|
|
1344
|
+
backgroundColor: '$neutral100'
|
|
1363
1345
|
},
|
|
1364
1346
|
outlined: {
|
|
1365
|
-
border: '1px solid $
|
|
1347
|
+
border: '1px solid $neutral100'
|
|
1366
1348
|
}
|
|
1367
1349
|
}
|
|
1368
1350
|
},
|
|
@@ -1398,14 +1380,14 @@ const Container = /*#__PURE__*/styled('div', {
|
|
|
1398
1380
|
const ImagePlaceholder = /*#__PURE__*/styled('span', {
|
|
1399
1381
|
width: '24px',
|
|
1400
1382
|
height: '24px',
|
|
1401
|
-
backgroundColor: '$
|
|
1383
|
+
backgroundColor: '$neutral100',
|
|
1402
1384
|
borderRadius: '99999px'
|
|
1403
1385
|
});
|
|
1404
1386
|
const OutputContainer = /*#__PURE__*/styled('div', {
|
|
1405
1387
|
windth: '100%',
|
|
1406
1388
|
height: '$48',
|
|
1407
1389
|
borderRadius: '$5',
|
|
1408
|
-
backgroundColor: '$
|
|
1390
|
+
backgroundColor: '$surface',
|
|
1409
1391
|
border: '1px solid transparent',
|
|
1410
1392
|
position: 'relative',
|
|
1411
1393
|
display: 'flex',
|
|
@@ -1439,10 +1421,10 @@ function TokenPreview(props) {
|
|
|
1439
1421
|
className: "head"
|
|
1440
1422
|
}, React.createElement(Typography, {
|
|
1441
1423
|
variant: "body2",
|
|
1442
|
-
color: "
|
|
1424
|
+
color: "neutral800"
|
|
1443
1425
|
}, props.label), React.createElement("div", null, percentageChange, props.usdValue && React.createElement(Typography, {
|
|
1444
1426
|
variant: "caption",
|
|
1445
|
-
color: "
|
|
1427
|
+
color: "neutral600",
|
|
1446
1428
|
className: "usd-value"
|
|
1447
1429
|
}, `$${numberToString(props.usdValue)}`))), React.createElement("div", {
|
|
1448
1430
|
className: "form"
|
|
@@ -1485,8 +1467,8 @@ const Container$1 = /*#__PURE__*/styled('div', {
|
|
|
1485
1467
|
justifyContent: 'space-between',
|
|
1486
1468
|
padding: '$8',
|
|
1487
1469
|
borderRadius: '$5',
|
|
1488
|
-
backgroundColor: '$
|
|
1489
|
-
color: '$
|
|
1470
|
+
backgroundColor: '$neutral100',
|
|
1471
|
+
color: '$neutral800',
|
|
1490
1472
|
fontSize: '$12',
|
|
1491
1473
|
'.routes': {
|
|
1492
1474
|
display: 'flex',
|
|
@@ -1838,6 +1820,7 @@ function ConfirmSwapPage() {
|
|
|
1838
1820
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1839
1821
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
1840
1822
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1823
|
+
const [dbErrorMessage, setDbErrorMessage] = useState('');
|
|
1841
1824
|
const bestRouteloadingStatus = getBestRouteStatus(fetchingBestRoute, !!fetchingBestRouteError);
|
|
1842
1825
|
const {
|
|
1843
1826
|
manager
|
|
@@ -1872,21 +1855,25 @@ function ConfirmSwapPage() {
|
|
|
1872
1855
|
requiredWallets: getRequiredChains(bestRoute),
|
|
1873
1856
|
selectableWallets: selectableWallets,
|
|
1874
1857
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
1875
|
-
onConfirm: () => {
|
|
1876
|
-
confirmSwap?.().then(swap => {
|
|
1858
|
+
onConfirm: async () => {
|
|
1859
|
+
confirmSwap?.().then(async swap => {
|
|
1877
1860
|
if (swap) {
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1861
|
+
try {
|
|
1862
|
+
await manager?.create('swap', {
|
|
1863
|
+
swapDetails: swap
|
|
1864
|
+
}, {
|
|
1865
|
+
id: swap.requestId
|
|
1866
|
+
});
|
|
1867
|
+
setSelectedSwap(swap.requestId);
|
|
1868
|
+
navigate('/' + navigationRoutes.swaps + `/${swap.requestId}`, {
|
|
1869
|
+
replace: true
|
|
1870
|
+
});
|
|
1871
|
+
setTimeout(() => {
|
|
1872
|
+
setInputAmount('');
|
|
1873
|
+
}, 0);
|
|
1874
|
+
} catch (e) {
|
|
1875
|
+
setDbErrorMessage('Error: ' + e?.message);
|
|
1876
|
+
}
|
|
1890
1877
|
}
|
|
1891
1878
|
});
|
|
1892
1879
|
},
|
|
@@ -1933,7 +1920,7 @@ function ConfirmSwapPage() {
|
|
|
1933
1920
|
totalFee: numberToString(totalFeeInUsd, 0, 2)
|
|
1934
1921
|
}),
|
|
1935
1922
|
loading: fetchingConfirmedRoute,
|
|
1936
|
-
errors: ConfirmSwapErrors(errors),
|
|
1923
|
+
errors: dbErrorMessage ? [dbErrorMessage, ...ConfirmSwapErrors(errors)] : ConfirmSwapErrors(errors),
|
|
1937
1924
|
warnings: ConfirmSwapWarnings(warnings),
|
|
1938
1925
|
extraMessages: React.createElement(React.Fragment, null, loadingMetaStatus === 'failed' && React.createElement(LoadingFailedAlert, null), loadingMetaStatus === 'failed' && showHighSlippageWarning && React.createElement(Spacer, {
|
|
1939
1926
|
direction: "vertical"
|
|
@@ -2027,10 +2014,11 @@ const Container$2 = /*#__PURE__*/styled('div', {
|
|
|
2027
2014
|
variants: {
|
|
2028
2015
|
type: {
|
|
2029
2016
|
filled: {
|
|
2030
|
-
backgroundColor: '$
|
|
2017
|
+
backgroundColor: '$neutral100'
|
|
2031
2018
|
},
|
|
2032
2019
|
outlined: {
|
|
2033
|
-
border: '1px solid $
|
|
2020
|
+
border: '1px solid $neutral100',
|
|
2021
|
+
backgroundColor: '$surface'
|
|
2034
2022
|
}
|
|
2035
2023
|
}
|
|
2036
2024
|
},
|
|
@@ -2078,14 +2066,14 @@ const Options = /*#__PURE__*/styled('div', {
|
|
|
2078
2066
|
const ImagePlaceholder$1 = /*#__PURE__*/styled('span', {
|
|
2079
2067
|
width: '24px',
|
|
2080
2068
|
height: '24px',
|
|
2081
|
-
backgroundColor: '$
|
|
2069
|
+
backgroundColor: '$neutral100',
|
|
2082
2070
|
borderRadius: '99999px'
|
|
2083
2071
|
});
|
|
2084
2072
|
const OutputContainer$1 = /*#__PURE__*/styled('div', {
|
|
2085
2073
|
windth: '100%',
|
|
2086
2074
|
height: '$48',
|
|
2087
2075
|
borderRadius: '$5',
|
|
2088
|
-
backgroundColor: '$
|
|
2076
|
+
backgroundColor: '$surface',
|
|
2089
2077
|
border: '1px solid transparent',
|
|
2090
2078
|
position: 'relative',
|
|
2091
2079
|
display: 'flex',
|
|
@@ -2131,7 +2119,7 @@ function TokenInfo(props) {
|
|
|
2131
2119
|
className: "head"
|
|
2132
2120
|
}, React.createElement(Typography, {
|
|
2133
2121
|
variant: "body2",
|
|
2134
|
-
color: "
|
|
2122
|
+
color: "neutral800"
|
|
2135
2123
|
}, t(type)), props.type === 'From' ? React.createElement(Options, null, React.createElement("div", {
|
|
2136
2124
|
className: "balance",
|
|
2137
2125
|
onClick: () => {
|
|
@@ -2139,7 +2127,7 @@ function TokenInfo(props) {
|
|
|
2139
2127
|
}
|
|
2140
2128
|
}, React.createElement(Typography, {
|
|
2141
2129
|
variant: "body3",
|
|
2142
|
-
color: "
|
|
2130
|
+
color: "neutral600"
|
|
2143
2131
|
}, `${t('Balance')}: ${tokenBalance} ${fromToken?.symbol || ''}`), React.createElement(Spacer, {
|
|
2144
2132
|
size: 4
|
|
2145
2133
|
}), React.createElement(Button, {
|
|
@@ -2153,7 +2141,7 @@ function TokenInfo(props) {
|
|
|
2153
2141
|
outputUsdValue: props.outputUsdValue
|
|
2154
2142
|
}), React.createElement("div", null, React.createElement(Typography, {
|
|
2155
2143
|
variant: "caption",
|
|
2156
|
-
color: "
|
|
2144
|
+
color: "neutral600"
|
|
2157
2145
|
}, `$${numberToString(props.outputUsdValue)}`)))), React.createElement("div", {
|
|
2158
2146
|
className: "form"
|
|
2159
2147
|
}, React.createElement(Button, {
|
|
@@ -2209,7 +2197,7 @@ function TokenInfo(props) {
|
|
|
2209
2197
|
}
|
|
2210
2198
|
}, React.createElement(Typography, {
|
|
2211
2199
|
variant: "caption",
|
|
2212
|
-
color: "
|
|
2200
|
+
color: "neutral800"
|
|
2213
2201
|
}, `$${numberToString(inputUsdValue)}`)),
|
|
2214
2202
|
value: props.inputAmount || '',
|
|
2215
2203
|
min: 0,
|
|
@@ -2245,7 +2233,7 @@ function BottomLogo() {
|
|
|
2245
2233
|
} = useTranslation();
|
|
2246
2234
|
return React.createElement(Container$3, null, React.createElement(Typography, {
|
|
2247
2235
|
variant: "caption",
|
|
2248
|
-
color: "$
|
|
2236
|
+
color: "$neutral600"
|
|
2249
2237
|
}, t('Powered By')), React.createElement(StyledAnchor, {
|
|
2250
2238
|
href: "https://rango.exchange",
|
|
2251
2239
|
target: "_blank"
|
|
@@ -2563,7 +2551,8 @@ function SelectTokenPage(props) {
|
|
|
2563
2551
|
|
|
2564
2552
|
function SettingsPage(_ref) {
|
|
2565
2553
|
let {
|
|
2566
|
-
supportedSwappers
|
|
2554
|
+
supportedSwappers,
|
|
2555
|
+
singleTheme
|
|
2567
2556
|
} = _ref;
|
|
2568
2557
|
const slippage = useSettingsStore.use.slippage();
|
|
2569
2558
|
const setSlippage = useSettingsStore.use.setSlippage();
|
|
@@ -2605,6 +2594,7 @@ function SettingsPage(_ref) {
|
|
|
2605
2594
|
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2606
2595
|
liquiditySources: supportedUniqueSwappersGroups,
|
|
2607
2596
|
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
2597
|
+
singleTheme: singleTheme,
|
|
2608
2598
|
customSlippage: customSlippage || NaN,
|
|
2609
2599
|
onCustomSlippageChange: setCustomSlippage,
|
|
2610
2600
|
minSlippage: MIN_SLIPPGAE,
|
|
@@ -2916,6 +2906,7 @@ function AppRoutes(props) {
|
|
|
2916
2906
|
}, {
|
|
2917
2907
|
path: navigationRoutes.settings,
|
|
2918
2908
|
element: React.createElement(SettingsPage, {
|
|
2909
|
+
singleTheme: config?.theme?.singleTheme,
|
|
2919
2910
|
supportedSwappers: config?.liquiditySources
|
|
2920
2911
|
})
|
|
2921
2912
|
}, {
|
|
@@ -3063,89 +3054,66 @@ function useTheme(_ref) {
|
|
|
3063
3054
|
const theme = useSettingsStore.use.theme();
|
|
3064
3055
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
3065
3056
|
const setTheme = useSettingsStore.use.setTheme();
|
|
3066
|
-
const
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
primary700: shadeColor(primary, -35),
|
|
3089
|
-
primary800: shadeColor(primary, -40),
|
|
3090
|
-
primary900: shadeColor(primary, -45),
|
|
3057
|
+
const light = themeColors?.light;
|
|
3058
|
+
const dark = themeColors?.dark;
|
|
3059
|
+
const neutral = light?.neutral || '#fafafa';
|
|
3060
|
+
const background = light?.background || '#fff';
|
|
3061
|
+
const foreground = light?.foreground || '#000';
|
|
3062
|
+
const darkColors = {
|
|
3063
|
+
...generateRangeColors('primary', 'dark', dark?.primary),
|
|
3064
|
+
...generateRangeColors('error', 'dark', dark?.error),
|
|
3065
|
+
...generateRangeColors('warning', 'dark', dark?.warning),
|
|
3066
|
+
...generateRangeColors('success', 'dark', dark?.success),
|
|
3067
|
+
...generateRangeColors('neutral', 'dark', dark?.neutral),
|
|
3068
|
+
surface: dark?.surface,
|
|
3069
|
+
background: dark?.background,
|
|
3070
|
+
foreground: dark?.foreground
|
|
3071
|
+
};
|
|
3072
|
+
const lightColors = {
|
|
3073
|
+
surface: light?.surface || '#fff',
|
|
3074
|
+
...generateRangeColors('primary', 'light', light?.primary || '#5FA425'),
|
|
3075
|
+
...generateRangeColors('error', 'light', light?.error || '#FF0000'),
|
|
3076
|
+
...generateRangeColors('warning', 'light', light?.warning || '#F5A623'),
|
|
3077
|
+
...generateRangeColors('success', 'light', light?.success || '#0070F3'),
|
|
3078
|
+
...generateRangeColors('neutral', 'light', neutral),
|
|
3091
3079
|
background,
|
|
3092
|
-
foreground
|
|
3093
|
-
error,
|
|
3094
|
-
error100: shadeColor(error, 50),
|
|
3095
|
-
error300: shadeColor(error, -10),
|
|
3096
|
-
error500: shadeColor(error, -20),
|
|
3097
|
-
error700: shadeColor(error, -30),
|
|
3098
|
-
warning,
|
|
3099
|
-
warning100: shadeColor(warning, 50),
|
|
3100
|
-
warning300: shadeColor(warning, -10),
|
|
3101
|
-
warning500: shadeColor(warning, -20),
|
|
3102
|
-
warning700: shadeColor(warning, -30),
|
|
3103
|
-
success,
|
|
3104
|
-
success100: shadeColor(success, 50),
|
|
3105
|
-
success300: shadeColor(success, -10),
|
|
3106
|
-
success500: shadeColor(success, -20),
|
|
3107
|
-
success700: shadeColor(success, -30)
|
|
3080
|
+
foreground
|
|
3108
3081
|
};
|
|
3109
3082
|
const customeLightTheme = createTheme({
|
|
3110
|
-
colors,
|
|
3083
|
+
colors: lightColors,
|
|
3111
3084
|
radii: {
|
|
3112
3085
|
5: `${borderRadius}px`
|
|
3113
3086
|
},
|
|
3114
3087
|
shadows: {
|
|
3115
|
-
s:
|
|
3088
|
+
s: `0px 3px 5px 3px ${light?.neutral || '#f0f2f5'} ,0px 6px 10px 3px ${light?.neutral || '#f0f2f5'}, 0px 1px 18px 3px ${light?.neutral || '#f0f2f5'}`
|
|
3116
3089
|
}
|
|
3117
3090
|
});
|
|
3118
3091
|
const customeDarkTheme = createTheme({
|
|
3119
3092
|
colors: {
|
|
3120
|
-
...
|
|
3121
|
-
|
|
3122
|
-
neutrals300: '#333333',
|
|
3123
|
-
neutrals400: '#444444',
|
|
3124
|
-
neutrals500: '#acacac',
|
|
3125
|
-
neutrals600: '#cccccc',
|
|
3126
|
-
neutrals700: '#dedede',
|
|
3127
|
-
neutrals800: '#f2f2f2',
|
|
3128
|
-
neutrals900: '#FAFAFA',
|
|
3093
|
+
...lightColors,
|
|
3094
|
+
...generateRangeColors('neutral', 'dark', '#111111'),
|
|
3129
3095
|
foreground: background,
|
|
3130
|
-
background: foreground
|
|
3096
|
+
background: foreground,
|
|
3097
|
+
surface: '#000',
|
|
3098
|
+
...JSON.parse(JSON.stringify(darkColors))
|
|
3131
3099
|
},
|
|
3132
3100
|
radii: {
|
|
3133
3101
|
5: `${borderRadius}px`
|
|
3134
3102
|
},
|
|
3135
3103
|
shadows: {
|
|
3136
|
-
s:
|
|
3104
|
+
s: `0px 3px 5px 3px ${dark?.neutral || '#222'}, 0px 6px 10px 3px ${dark?.neutral || '#222'}, 0px 1px 18px 3px ${dark?.neutral || '#222'}`
|
|
3137
3105
|
}
|
|
3138
3106
|
});
|
|
3139
|
-
const [OSTheme, setOSTheme] = useState(
|
|
3107
|
+
const [OSTheme, setOSTheme] = useState('light');
|
|
3140
3108
|
useEffect(() => {
|
|
3141
3109
|
(async () => {
|
|
3142
3110
|
await fetchMeta();
|
|
3143
3111
|
})();
|
|
3144
3112
|
const switchTheme = event => {
|
|
3145
|
-
if (event.matches) setOSTheme(
|
|
3113
|
+
if (event.matches) setOSTheme('dark');else setOSTheme('light');
|
|
3146
3114
|
};
|
|
3147
3115
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
3148
|
-
setOSTheme(
|
|
3116
|
+
setOSTheme('dark');
|
|
3149
3117
|
}
|
|
3150
3118
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', switchTheme);
|
|
3151
3119
|
return () => {
|
|
@@ -3164,7 +3132,7 @@ function useTheme(_ref) {
|
|
|
3164
3132
|
classList.add(`font_${fontFamily.replace(/ /g, '')}`);
|
|
3165
3133
|
}, [fontFamily]);
|
|
3166
3134
|
const getActiveTheme = () => {
|
|
3167
|
-
if (theme === 'auto') return OSTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
3135
|
+
if (theme === 'auto') return OSTheme === 'dark' ? customeDarkTheme : customeLightTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
3168
3136
|
};
|
|
3169
3137
|
return {
|
|
3170
3138
|
activeTheme: getActiveTheme()
|