@rango-dev/widget-embedded 0.12.1-next.12 → 0.12.1-next.14

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 (71) hide show
  1. package/dist/Widget.d.ts.map +1 -1
  2. package/dist/components/BlockchainList/BlockchainList.styles.d.ts +12 -2
  3. package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
  4. package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts +6 -1
  5. package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts.map +1 -1
  6. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +6 -1
  7. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  8. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +90 -15
  9. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  10. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +18 -3
  11. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
  12. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +24 -4
  13. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  14. package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +1 -1
  15. package/dist/components/Layout/Layout.styles.d.ts +18 -3
  16. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  17. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +6 -1
  18. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  19. package/dist/components/NoRoutes/NoRoutes.styles.d.ts +18 -3
  20. package/dist/components/NoRoutes/NoRoutes.styles.d.ts.map +1 -1
  21. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  22. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +24 -4
  23. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  24. package/dist/components/RouteErrors/RouteErrors.styles.d.ts +24 -4
  25. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -1
  26. package/dist/components/SearchInput/SearchInput.styles.d.ts +6 -1
  27. package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  28. package/dist/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts +18 -3
  29. package/dist/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts.map +1 -1
  30. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +30 -5
  31. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  32. package/dist/components/Slippage/Slippage.styles.d.ts +24 -4
  33. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  34. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  35. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +36 -6
  36. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  37. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +6 -1
  38. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
  39. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +6 -1
  40. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
  41. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +1 -1
  42. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
  43. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +24 -4
  44. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
  45. package/dist/components/TokenList/TokenList.styles.d.ts +60 -10
  46. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  47. package/dist/components/WalletModal/WalletModalContent.styles.d.ts +24 -4
  48. package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
  49. package/dist/components/WidgetEvents.d.ts.map +1 -1
  50. package/dist/globalStyles.d.ts +1 -1
  51. package/dist/globalStyles.d.ts.map +1 -1
  52. package/dist/hooks/useTheme.d.ts +3 -6
  53. package/dist/hooks/useTheme.d.ts.map +1 -1
  54. package/dist/index.js +1 -1
  55. package/dist/index.js.map +4 -4
  56. package/dist/types/config.d.ts +3 -0
  57. package/dist/types/config.d.ts.map +1 -1
  58. package/dist/utils/configs.d.ts +2 -0
  59. package/dist/utils/configs.d.ts.map +1 -1
  60. package/package.json +2 -2
  61. package/src/Widget.tsx +2 -1
  62. package/src/components/HeaderButtons/UnreadNotificationsBadge.tsx +1 -2
  63. package/src/components/Layout/Layout.styles.ts +1 -2
  64. package/src/components/NotificationContent/NotificationContent.tsx +1 -6
  65. package/src/components/SwapDetails/SwapDetails.tsx +15 -4
  66. package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +1 -1
  67. package/src/components/WidgetEvents.tsx +9 -3
  68. package/src/globalStyles.ts +1 -4
  69. package/src/hooks/useTheme.ts +37 -75
  70. package/src/types/config.ts +3 -0
  71. package/src/utils/configs.ts +3 -0
@@ -36,6 +36,8 @@ export type WidgetColors = {
36
36
  * border color
37
37
  * @property {number} borderRadius - `borderRadius` is a property of the `WidgetTheme` type that
38
38
  * specifies the radius of the corners of a widget.
39
+ * @property {number} secondaryBorderRadius - `secondaryBorderRadius` is a property of the `WidgetTheme` type that
40
+ * specifies the radius of the buttons of a widget.
39
41
  * @property {number} width - The `width` property is a number that represents the width of the widget.
40
42
  * @property {number} height - The `height` property is a number that specifies the height of the widget.
41
43
  * @property {boolean} singleTheme - The `singleTheme` property is a boolean that specifies the theme is support dark and light or only light.
@@ -48,6 +50,7 @@ export type WidgetTheme = {
48
50
  dark: WidgetColors;
49
51
  };
50
52
  borderRadius?: number;
53
+ secondaryBorderRadius?: number;
51
54
  width?: number;
52
55
  height?: number;
53
56
  singleTheme?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts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AoCG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,wBAAwB,CAAC;IAChC,EAAE,CAAC,EAAE,wBAAwB,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,UAAU,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,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"}
@@ -4,4 +4,6 @@ export interface Configs {
4
4
  export declare function getConfig(name: keyof Configs): string;
5
5
  export declare function setConfig(name: keyof Configs, value: any): any;
6
6
  export declare function initConfig(nextConfigs: Configs): Configs;
7
+ export declare const DEFAULT_PRIMARY_RADIUS = 20;
8
+ export declare const DEFAULT_SECONDARY_RADIUS = 25;
7
9
  //# sourceMappingURL=configs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/utils/configs.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAQD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,OAAO,UAE5C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,OAAO,EAAE,KAAK,EAAE,GAAG,OAIxD;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,OAAO,WAS9C"}
1
+ {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/utils/configs.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAQD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,OAAO,UAE5C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,OAAO,EAAE,KAAK,EAAE,GAAG,OAIxD;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,OAAO,WAS9C;AAED,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,wBAAwB,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.12.1-next.12",
3
+ "version": "0.12.1-next.14",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "@rango-dev/queue-manager-core": "^0.15.1-next.1",
24
24
  "@rango-dev/queue-manager-rango-preset": "^0.15.1-next.5",
25
25
  "@rango-dev/queue-manager-react": "^0.15.1-next.3",
26
- "@rango-dev/ui": "^0.15.1-next.9",
26
+ "@rango-dev/ui": "^0.15.1-next.10",
27
27
  "@rango-dev/wallets-react": "^0.1.1-next.5",
28
28
  "@rango-dev/wallets-shared": "^0.15.1-next.3",
29
29
  "bignumber.js": "^9.1.1",
package/src/Widget.tsx CHANGED
@@ -21,6 +21,7 @@ const MainContainer = styled('div', {
21
21
  display: 'flex',
22
22
  justifyContent: 'center',
23
23
  alignItems: 'center',
24
+ fontFamily: '$widget',
24
25
  });
25
26
 
26
27
  export type WidgetProps = {
@@ -29,7 +30,7 @@ export type WidgetProps = {
29
30
 
30
31
  export function Main(props: PropsWithChildren<WidgetProps>) {
31
32
  const { config } = props;
32
- globalFont(config?.theme?.fontFamily || 'Roboto');
33
+ globalFont();
33
34
 
34
35
  const { activeTheme } = useTheme(config?.theme || {});
35
36
  const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
@@ -6,8 +6,7 @@ import { useNotificationStore } from '../../store/notification';
6
6
  import { NotificationsBadgeContainer } from './HeaderButtons.styles';
7
7
 
8
8
  export function UnreadNotificationsBadge() {
9
- const getUnreadNotifications =
10
- useNotificationStore.use.getUnreadNotifications();
9
+ const { getUnreadNotifications } = useNotificationStore();
11
10
 
12
11
  const notificationsCount = getUnreadNotifications().length;
13
12
 
@@ -4,8 +4,7 @@ export const Container = styled('div', {
4
4
  position: 'relative',
5
5
  display: 'flex',
6
6
  flexDirection: 'column',
7
- //TODO: add radii theme token for 20px
8
- borderRadius: '20px',
7
+ borderRadius: '$primary',
9
8
  overflow: 'hidden !important',
10
9
  boxShadow: '15px 15px 15px 0px rgba(0, 0, 0, 0.05)',
11
10
  width: '95vw',
@@ -22,20 +22,15 @@ export function NotificationContent() {
22
22
  const navigate = useNavigate();
23
23
  const setSelectedSwap = useUiStore.use.setSelectedSwap();
24
24
 
25
- const getUnreadNotifications =
26
- useNotificationStore.use.getUnreadNotifications();
25
+ const { getUnreadNotifications } = useNotificationStore();
27
26
 
28
27
  const notifications: Notification[] = getUnreadNotifications();
29
-
30
- const setAsRead = useNotificationStore.use.setAsRead();
31
-
32
28
  const { tokens, blockchains } = useMetaStore.use.meta();
33
29
  const sortedNotification = notifications
34
30
  .sort((a, b) => b.creationTime - a.creationTime)
35
31
  .slice(0, MAX_NOTIFICATIONS_DISPLAYED);
36
32
 
37
33
  const handleOnClick = (requestId: Notification['requestId']) => {
38
- setAsRead(requestId);
39
34
  setSelectedSwap(requestId);
40
35
  navigate(`/swaps/${requestId}`);
41
36
  };
@@ -39,6 +39,7 @@ import {
39
39
  import { useNavigateBack } from '../../hooks/useNavigateBack';
40
40
  import { useBestRouteStore } from '../../store/bestRoute';
41
41
  import { useMetaStore } from '../../store/meta';
42
+ import { useNotificationStore } from '../../store/notification';
42
43
  import { numberToString } from '../../utils/numbers';
43
44
  import { getPriceImpactLevel } from '../../utils/routing';
44
45
  import {
@@ -90,12 +91,22 @@ export function SwapDetails(props: SwapDetailsProps) {
90
91
  setModalState(null);
91
92
  };
92
93
 
94
+ const getUnreadNotifications =
95
+ useNotificationStore.use.getUnreadNotifications();
96
+ const setAsRead = useNotificationStore.use.setAsRead();
97
+ const unreadNotifications = getUnreadNotifications();
93
98
  const currentStep = getCurrentStep(swap);
94
99
  const currentStepNetworkStatus = currentStep?.networkStatus;
95
100
 
96
101
  useEffect(() => {
97
- if (swap.status === 'success' || swap.status === 'failed') {
98
- setShowCompletedModal(swap.status);
102
+ const existNotification = unreadNotifications.find(
103
+ (n) => n.requestId === swap.requestId
104
+ );
105
+ if (existNotification) {
106
+ if (swap.status === 'success' || swap.status === 'failed') {
107
+ setShowCompletedModal(swap.status);
108
+ setAsRead(swap.requestId);
109
+ }
99
110
  }
100
111
  }, [swap.status]);
101
112
 
@@ -207,7 +218,7 @@ export function SwapDetails(props: SwapDetailsProps) {
207
218
  const percentageChange = getPercentageChange(inputUsdValue, outputUsdValue);
208
219
 
209
220
  const completeModalDesc =
210
- showCompletedModal === 'success'
221
+ swap.status === 'success'
211
222
  ? `You have received ${numberToString(
212
223
  outputAmount,
213
224
  TOKEN_AMOUNT_MIN_DECIMALS,
@@ -389,7 +400,7 @@ export function SwapDetails(props: SwapDetailsProps) {
389
400
  open={!!showCompletedModal}
390
401
  diagnosisUrl={diagnosisUrl}
391
402
  onClose={() => setShowCompletedModal(null)}
392
- status={showCompletedModal}
403
+ status={swap.status === 'success' ? 'success' : 'failed'}
393
404
  priceValue={numberToString(
394
405
  outputAmount,
395
406
  TOKEN_AMOUNT_MIN_DECIMALS,
@@ -22,7 +22,7 @@ export interface ModalPropTypes {
22
22
  export interface CompleteModalPropTypes {
23
23
  open: boolean;
24
24
  onClose: () => void;
25
- status: 'success' | 'failed' | null;
25
+ status: 'success' | 'failed';
26
26
  priceValue: string;
27
27
  usdValue: string;
28
28
  percentageChange: string;
@@ -16,7 +16,7 @@ export function WidgetEvents() {
16
16
  const connectedWallets = useWalletsStore.use.connectedWallets();
17
17
  const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
18
18
  const setNotification = useNotificationStore.use.setNotification();
19
-
19
+ const setAsRead = useNotificationStore.use.setAsRead();
20
20
  const widgetEvents = useEvents();
21
21
 
22
22
  useEffect(() => {
@@ -42,10 +42,16 @@ export function WidgetEvents() {
42
42
  toAccount && getWalletsDetails([toAccount]);
43
43
  }
44
44
  if (
45
- event.type === StepEventType.TX_EXECUTION_BLOCKED &&
46
- validBlockedStatuses.includes(event.status)
45
+ (event.type === StepEventType.TX_EXECUTION_BLOCKED &&
46
+ validBlockedStatuses.includes(event.status)) ||
47
+ event.type === StepEventType.FAILED
47
48
  ) {
48
49
  setNotification(event, route);
50
+ } else if (
51
+ event.type === StepEventType.TX_EXECUTION ||
52
+ event.type === StepEventType.CHECK_STATUS
53
+ ) {
54
+ setAsRead(route.requestId);
49
55
  }
50
56
  });
51
57
 
@@ -1,12 +1,9 @@
1
1
  import { globalCss } from '@rango-dev/ui';
2
2
 
3
- export const globalFont = (fontFamily: string) =>
3
+ export const globalFont = () =>
4
4
  globalCss({
5
5
  '@import': [
6
6
  "url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')",
7
7
  "url('https://fonts.cdnfonts.com/css/times-new-roman')",
8
8
  ],
9
- body: {
10
- fontFamily,
11
- },
12
9
  })();
@@ -1,87 +1,53 @@
1
- import { darkTheme, lightTheme } from '@rango-dev/ui';
2
- import { useState, useEffect, useLayoutEffect } from 'react';
1
+ import type { WidgetTheme } from '../types';
2
+
3
+ import { createTheme, darkTheme, lightTheme } from '@rango-dev/ui';
4
+ import { useEffect, useState } from 'react';
5
+
3
6
  import { useMetaStore } from '../store/meta';
4
7
  import { useSettingsStore } from '../store/settings';
5
- import { WidgetTheme } from '../types';
6
- import usePrevious from './usePrevious';
8
+ import {
9
+ DEFAULT_PRIMARY_RADIUS,
10
+ DEFAULT_SECONDARY_RADIUS,
11
+ } from '../utils/configs';
7
12
 
8
13
  export function useTheme({
9
14
  // colors,
10
15
  fontFamily = 'Roboto',
11
- // borderRadius = 8,
16
+ borderRadius = DEFAULT_PRIMARY_RADIUS,
17
+ secondaryBorderRadius = DEFAULT_SECONDARY_RADIUS,
12
18
  mode = 'auto',
13
19
  }: WidgetTheme) {
14
20
  const theme = useSettingsStore.use.theme();
15
21
  const fetchMeta = useMetaStore.use.fetchMeta();
16
22
  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';
22
23
 
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
- // };
24
+ const customTheme = createTheme({
25
+ radii: {
26
+ primary: `${borderRadius}px`,
27
+ secondary: `${secondaryBorderRadius}px`,
28
+ },
29
+ fonts: {
30
+ widget: fontFamily,
31
+ },
32
+ });
33
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),
41
- // background,
42
- // foreground,
43
- // };
34
+ const lightClassName = `${customTheme.className} ${lightTheme.className}`;
35
+ const darkClassName = `${customTheme.className} ${darkTheme.className}`;
44
36
 
45
- // const customLightTheme = createTheme({
46
- // colors: lightColors,
47
- // radii: {
48
- // xs: `${borderRadius}px`,
49
- // },
50
- // shadows: {
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'}`,
54
- // },
55
- // });
56
-
57
- // const customDarkTheme = createTheme({
58
- // colors: {
59
- // ...lightColors,
60
- // ...generateRangeColors('neutral', 'dark', '#111111'),
61
- // foreground: background,
62
- // background: foreground,
63
- // surface: '#000',
64
- // ...JSON.parse(JSON.stringify(darkColors)),
65
- // },
66
- // radii: {
67
- // xs: `${borderRadius}px`,
68
- // },
69
- // shadows: {
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'}`,
73
- // },
74
- // });
75
37
  const [OSTheme, setOSTheme] = useState('light');
76
38
 
77
39
  useEffect(() => {
78
- (async () => {
40
+ const fetchData = async () => {
79
41
  await fetchMeta();
80
- })();
42
+ };
43
+ void fetchData();
81
44
 
82
45
  const switchTheme = (event: MediaQueryListEvent) => {
83
- if (event.matches) setOSTheme('dark');
84
- else setOSTheme('light');
46
+ if (event.matches) {
47
+ setOSTheme('dark');
48
+ } else {
49
+ setOSTheme('light');
50
+ }
85
51
  };
86
52
 
87
53
  if (
@@ -101,20 +67,16 @@ export function useTheme({
101
67
  };
102
68
  }, []);
103
69
  useEffect(() => {
104
- if (mode !== 'auto') setTheme(mode);
70
+ if (mode !== 'auto') {
71
+ setTheme(mode);
72
+ }
105
73
  }, [mode]);
106
- const prevFont = usePrevious(fontFamily);
107
-
108
- useLayoutEffect(() => {
109
- const { classList } = document.body;
110
-
111
- if (prevFont) classList.remove(`font_${prevFont.replace(/ /g, '')}`);
112
- classList.add(`font_${fontFamily.replace(/ /g, '')}`);
113
- }, [fontFamily]);
114
74
 
115
75
  const getActiveTheme = () => {
116
- if (theme === 'auto') return OSTheme === 'dark' ? darkTheme : lightTheme;
117
- else return theme === 'dark' ? darkTheme : lightTheme;
76
+ if (theme === 'auto') {
77
+ return OSTheme === 'dark' ? darkClassName : lightClassName;
78
+ }
79
+ return theme === 'dark' ? darkClassName : lightClassName;
118
80
  };
119
81
 
120
82
  return { activeTheme: getActiveTheme() };
@@ -38,6 +38,8 @@ export type WidgetColors = {
38
38
  * border color
39
39
  * @property {number} borderRadius - `borderRadius` is a property of the `WidgetTheme` type that
40
40
  * specifies the radius of the corners of a widget.
41
+ * @property {number} secondaryBorderRadius - `secondaryBorderRadius` is a property of the `WidgetTheme` type that
42
+ * specifies the radius of the buttons of a widget.
41
43
  * @property {number} width - The `width` property is a number that represents the width of the widget.
42
44
  * @property {number} height - The `height` property is a number that specifies the height of the widget.
43
45
  * @property {boolean} singleTheme - The `singleTheme` property is a boolean that specifies the theme is support dark and light or only light.
@@ -47,6 +49,7 @@ export type WidgetTheme = {
47
49
  fontFamily?: string;
48
50
  colors?: { light: WidgetColors; dark: WidgetColors };
49
51
  borderRadius?: number;
52
+ secondaryBorderRadius?: number;
50
53
  width?: number;
51
54
  height?: number;
52
55
  singleTheme?: boolean;
@@ -28,3 +28,6 @@ export function initConfig(nextConfigs: Configs) {
28
28
  configs = clonedConfigs;
29
29
  return configs;
30
30
  }
31
+
32
+ export const DEFAULT_PRIMARY_RADIUS = 20;
33
+ export const DEFAULT_SECONDARY_RADIUS = 25;