@layerswap/widget 0.1.16 → 0.1.17-beta.9
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/Models/Theme.d.ts +1 -1
- package/dist/Models/Theme.js +75 -75
- package/dist/components/ColorSchema.js +1 -0
- package/dist/components/Common/{AddressIcon.js → AddressIcon/index.js} +1 -1
- package/dist/components/Common/AddressIcon/jazzicon/colors.d.ts +2 -0
- package/dist/components/Common/AddressIcon/jazzicon/colors.js +12 -0
- package/dist/components/Common/AddressIcon/jazzicon/index.d.ts +2 -0
- package/dist/components/Common/AddressIcon/jazzicon/index.js +62 -0
- package/dist/components/Common/AddressIcon/jazzicon/mersenne-twister.d.ts +28 -0
- package/dist/components/Common/AddressIcon/jazzicon/mersenne-twister.js +201 -0
- package/dist/components/Common/AddressIcon/jazzicon/paper.d.ts +4 -0
- package/dist/components/Common/AddressIcon/jazzicon/paper.js +15 -0
- package/dist/components/HeaderWithMenu/index.js +1 -1
- package/dist/components/Input/Address/AddressNote.js +1 -1
- package/dist/components/Modal/leaflet.js +2 -2
- package/dist/components/Modal/modal.js +3 -3
- package/dist/components/Modal/vaulModal.js +10 -4
- package/dist/components/Pages/SwapPages/Form/FeeDetails/RefuelModal.js +6 -6
- package/dist/components/Pages/SwapPages/Form/Form.js +1 -1
- package/dist/components/Pages/SwapPages/Form/SecondaryComponents/FormButton.js +1 -1
- package/dist/components/Pages/SwapPages/Form/Select/Command/commandSelect.js +2 -2
- package/dist/components/Wallet/WalletModal/ConnectorsList.js +1 -1
- package/dist/components/Widget/Footer.js +2 -2
- package/dist/components/WidgetLoading.d.ts +2 -1
- package/dist/components/WidgetLoading.js +6 -4
- package/dist/components/themeWrapper.js +12 -12
- package/dist/context/LayerswapProvider.d.ts +3 -1
- package/dist/context/LayerswapProvider.js +11 -11
- package/dist/hooks/useWindowDimensions.d.ts +1 -0
- package/dist/hooks/useWindowDimensions.js +6 -2
- package/dist/index.css +5325 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +5 -4
- /package/dist/components/Common/{AddressIcon.d.ts → AddressIcon/index.d.ts} +0 -0
|
@@ -9,8 +9,9 @@ import { SnapPointsProvider, useSnapPoints } from '../../context/snapPointsConte
|
|
|
9
9
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
10
10
|
import { createPortal } from 'react-dom';
|
|
11
11
|
import { Drawer } from './vaul';
|
|
12
|
+
import AppSettings from '../../lib/AppSettings';
|
|
12
13
|
const Comp = ({ children, show, setShow, header, description, onClose, onAnimationEnd }) => {
|
|
13
|
-
const { isMobile } = useWindowDimensions();
|
|
14
|
+
const { isMobileWithPortal: isMobile } = useWindowDimensions();
|
|
14
15
|
let [headerRef, { height }] = useMeasure();
|
|
15
16
|
const { setHeaderHeight } = useSnapPoints();
|
|
16
17
|
const expandRef = useRef(null);
|
|
@@ -61,8 +62,9 @@ const Comp = ({ children, show, setShow, header, description, onClose, onAnimati
|
|
|
61
62
|
expandRef.current?.classList.add('hidden');
|
|
62
63
|
}, modal: isMobile ? true : false, repositionInputs: false, onAnimationEnd: onAnimationEnd, handleOnly: isMobile, children: _jsxs(Drawer.Portal, { children: [_jsx(Drawer.Close, { asChild: true, children: isMobile
|
|
63
64
|
? _jsx(Drawer.Overlay, { className: 'fixed inset-0 z-50 bg-black/50 block' })
|
|
64
|
-
: _jsx(motion.div, { className: 'absolute inset-0 z-50 bg-black/50 block', initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 } }, "backdrop") }), _jsxs(Drawer.Content, { "data-testid": "content", className: clsx('
|
|
65
|
+
: _jsx(motion.div, { className: 'absolute inset-0 z-50 bg-black/50 block', initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 } }, "backdrop") }), _jsxs(Drawer.Content, { "data-testid": "content", className: clsx('absolute flex flex-col bg-secondary-900 rounded-t-xl bottom-0 left-0 right-0 h-full z-50 pb-6 text-primary-text !ring-0 !outline-none ', {
|
|
65
66
|
'!border-none !rounded-none': snap === 1,
|
|
67
|
+
'!fixed sm:!absolute': AppSettings.ThemeData?.enablePortal == true,
|
|
66
68
|
}), children: [_jsxs("div", { ref: headerRef, className: 'w-full relative', children: [isMobile &&
|
|
67
69
|
_jsx("div", { className: "absolute top-2 left-[calc(50%-24px)]", children: _jsx(Drawer.Handle, { className: '!w-12 bg-primary-text-muted' }) }), _jsxs("div", { className: 'flex items-center w-full text-left justify-between px-6 pt-3 pb-2', children: [_jsx(Drawer.Title, { className: "text-lg text-secondary-text font-semibold", children: header }), _jsx(Drawer.Close, { asChild: true, children: _jsx("div", { className: '-mr-2', children: _jsx(IconButton, { icon: _jsx(X, { strokeWidth: 3 }) }) }) })] }), description &&
|
|
68
70
|
_jsx(Drawer.Description, { className: "text-sm mt-2 text-secondary-text px-6", children: description })] }), _jsxs("div", { className: clsx('flex flex-col w-full h-fit max-h-[90dvh] px-6 styled-scroll overflow-x-hidden relative ', {
|
|
@@ -96,10 +98,14 @@ const VaulDrawerSnap = (props) => {
|
|
|
96
98
|
return (_jsx("div", { ...props, className: props.className ?? 'pb-6', id: props.id, ref: ref, children: props.children }));
|
|
97
99
|
};
|
|
98
100
|
const VaulDrawer = (props) => {
|
|
99
|
-
const {
|
|
100
|
-
return (_jsx(SnapPointsProvider, { isMobile:
|
|
101
|
+
const { isMobileWithPortal } = useWindowDimensions();
|
|
102
|
+
return (_jsx(SnapPointsProvider, { isMobile: isMobileWithPortal, children: _jsx(Comp, { ...props, children: props.children }) }));
|
|
101
103
|
};
|
|
102
104
|
VaulDrawer.Snap = VaulDrawerSnap;
|
|
105
|
+
// type Props = {
|
|
106
|
+
// children: React.ReactNode,
|
|
107
|
+
// isWalletModalOpen?: boolean
|
|
108
|
+
// }
|
|
103
109
|
// export const WalletFooterPortal: FC<Props> = ({ children, isWalletModalOpen }) => {
|
|
104
110
|
export const WalletFooterPortal = ({ children, isWalletModalOpen }) => {
|
|
105
111
|
const ref = useRef(null);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Modal from '../../../../Modal/modal';
|
|
3
2
|
import { Fuel } from 'lucide-react';
|
|
4
3
|
import { roundDecimals, truncateDecimals } from '../../../../utils/RoundDecimals';
|
|
5
4
|
import SubmitButton from '../../../../Buttons/submitButton';
|
|
@@ -7,6 +6,7 @@ import SecondaryButton from '../../../../Buttons/secondaryButton';
|
|
|
7
6
|
import { useFormikContext } from 'formik';
|
|
8
7
|
import { useFee } from '../../../../../context/feeContext';
|
|
9
8
|
import useSWRBalance from '../../../../../lib/balances/useSWRBalance';
|
|
9
|
+
import VaulDrawer from '../../../../Modal/vaulModal';
|
|
10
10
|
const RefuelModal = ({ openModal, setOpenModal }) => {
|
|
11
11
|
const { values, setFieldValue } = useFormikContext();
|
|
12
12
|
const { to, toCurrency, refuel, destination_address } = values || {};
|
|
@@ -23,10 +23,10 @@ const RefuelModal = ({ openModal, setOpenModal }) => {
|
|
|
23
23
|
setFieldValue('refuel', true);
|
|
24
24
|
setOpenModal(false);
|
|
25
25
|
};
|
|
26
|
-
return (_jsx(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
return (_jsx(VaulDrawer, { show: openModal, setShow: setOpenModal, modalId: "refuel", children: _jsx(VaulDrawer.Snap, { id: 'item-1', children: _jsxs("div", { className: "flex flex-col items-center gap-6 mt-2", children: [_jsx("div", { className: "relative z-10 flex h-28 w-28 items-center justify-center rounded-xl p-2 bg-primary/20", children: _jsx(Fuel, { className: "h-16 w-16 text-primary", "aria-hidden": "true" }) }), _jsxs("div", { className: "text-center max-w-72", children: [_jsx("p", { className: "text-2xl", children: "About Refuel" }), _jsxs("p", { className: "text-secondary-text", children: [_jsx("span", { children: "You can get a small amount of" }), " ", _jsx("span", { children: nativeAsset?.symbol }), " ", _jsx("span", { children: "that can be used for covering gas fees on" }), " ", _jsxs("span", { children: [to?.display_name, "."] })] })] }), (values.refuel || destNativeTokenBalance) &&
|
|
27
|
+
_jsxs("div", { className: "flex flex-col divide-y-2 divide-secondary-900 w-full rounded-lg bg-secondary-700 overflow-hidden", children: [destNativeTokenBalance &&
|
|
28
|
+
_jsx("div", { className: "gap-4 flex relative items-center outline-none w-full text-primary-text px-4 py-3", children: _jsxs("div", { className: "flex items-center justify-between w-full", children: [_jsx("div", { className: "text-secondary-text", children: _jsx("span", { children: "Your current balance" }) }), _jsxs("p", { className: 'text-end', children: [_jsxs("span", { children: [truncateDecimals(destNativeTokenBalance.amount, nativeAsset?.precision), " ", nativeAsset?.symbol] }), " ", _jsxs("span", { className: "text-secondary-text", children: ["($", amountInUsd, ")"] })] })] }) }), toCurrency?.refuel && nativeAsset &&
|
|
29
|
+
_jsx("div", { className: "gap-4 flex relative items-center outline-none w-full text-primary-text px-4 py-3", children: _jsxs("div", { className: "flex items-center justify-between w-full", children: [_jsx("div", { className: "text-secondary-text", children: "You will receive" }), _jsxs("p", { children: [_jsxs("span", { children: [roundDecimals(toCurrency.refuel?.amount, nativeAsset.precision), " ", nativeAsset?.symbol] }), " ", _jsxs("span", { className: "text-secondary-text", children: ["($", toCurrency.refuel?.amount_in_usd, ")"] })] })] }) })] }), _jsxs("div", { className: 'flex flex-col gap-3 w-full h-full', children: [!refuel &&
|
|
30
|
+
_jsx(SubmitButton, { type: "button", onClick: enabldeRefuel, children: "Enable Refuel" }), _jsx(SecondaryButton, { type: "button", className: 'h-full w-full py-3', onClick: closeModal, children: "Close" })] })] }) }) }));
|
|
31
31
|
};
|
|
32
32
|
export default RefuelModal;
|
|
@@ -126,7 +126,7 @@ const SwapForm = ({ partner }) => {
|
|
|
126
126
|
}, [values.amount]);
|
|
127
127
|
const sourceWalletNetwork = values.fromExchange ? undefined : values.from;
|
|
128
128
|
const shouldConnectWallet = (sourceWalletNetwork && values.from?.deposit_methods?.includes('wallet') && values.depositMethod !== 'deposit_address' && !selectedSourceAccount) || (!values.from && !values.fromExchange && !wallets.length && values.depositMethod !== 'deposit_address' && !(!values.from && values.to));
|
|
129
|
-
return _jsx(Widget, { className: "sm:min-h-[450px] h-full", children: _jsxs(Form, { className: `h-full grow flex flex-col justify-between ${(isSubmitting) ? 'pointer-events-none' : 'pointer-events-auto'}`, children: [_jsxs(Widget.Content, { children: [_jsxs("div", { className: 'flex-col relative flex justify-between gap-1.5 w-full mb-3.5 leading-4 bg-secondary-700 rounded-xl', children: [!(query?.hideFrom && values?.from) && _jsx("div", { className: "flex flex-col w-full", children: _jsx(NetworkFormField, { direction: "from", label: "From", className: "rounded-t-lg pt-2.5", partner: partner }) }), !query?.hideFrom && !query?.hideTo &&
|
|
129
|
+
return _jsx(Widget, { className: "sm:min-h-[450px] h-full", children: _jsxs(Form, { className: `h-full grow flex flex-col justify-between space-y-3 ${(isSubmitting) ? 'pointer-events-none' : 'pointer-events-auto'}`, children: [_jsxs(Widget.Content, { children: [_jsxs("div", { className: 'flex-col relative flex justify-between gap-1.5 w-full mb-3.5 leading-4 bg-secondary-700 rounded-xl', children: [!(query?.hideFrom && values?.from) && _jsx("div", { className: "flex flex-col w-full", children: _jsx(NetworkFormField, { direction: "from", label: "From", className: "rounded-t-lg pt-2.5", partner: partner }) }), !query?.hideFrom && !query?.hideTo &&
|
|
130
130
|
_jsx("button", { type: "button", "aria-label": "Reverse the source and destination", disabled: valuesSwapperDisabled, onClick: valuesSwapper, className: `hover:text-primary absolute right-[calc(50%-16px)] top-[122px] z-10 border-2 border-secondary-700 bg-secondary-600 rounded-lg disabled:cursor-not-allowed disabled:text-secondary-text duration-200 transition disabled:pointer-events-none`, children: _jsx(motion.div, { animate: animate, transition: { duration: 0.3 }, onTap: () => !valuesSwapperDisabled && cycle(), children: _jsx(ArrowUpDown, { className: classNames(valuesSwapperDisabled && 'opacity-50', "w-7 h-auto p-1 bg-secondary-500 rounded-lg disabled:opacity-30") }) }) }), !(query?.hideTo && values?.to) && _jsx("div", { className: "flex flex-col w-full", children: _jsx(NetworkFormField, { direction: "to", label: "To", className: "rounded-b-lg", partner: partner }) })] }), (((fromExchange && destination) || (toExchange && source)) && currencyGroup) ?
|
|
131
131
|
_jsx("div", { className: "mb-6 leading-4", children: _jsx(ResizablePanel, { children: _jsx(CEXNetworkFormField, { direction: fromExchange ? 'from' : 'to', partner: partner }) }) })
|
|
132
132
|
: _jsx(_Fragment, {}), _jsx("div", { className: "mb-6 leading-4", children: _jsx(AmountField, {}) }), _jsxs("div", { className: "w-full", children: [validationMessage ?
|
|
@@ -11,7 +11,7 @@ const FormButton = ({ shouldConnectWallet, values, isValid, errors, isSubmitting
|
|
|
11
11
|
return _jsx(FormSourceWalletButton, {});
|
|
12
12
|
}
|
|
13
13
|
if (values?.to && !values?.destination_address) {
|
|
14
|
-
return (_jsx("div", { children: _jsx(Address, { partner: partner, children: () => (_jsxs("div", { className: "border border-primary disabled:border-primary-900 items-center space-x-1 disabled:text-opacity-40 disabled:bg-primary-900 disabled:cursor-not-allowed relative w-full flex justify-center font-semibold rounded-md transform hover:brightness-125 transition duration-200 ease-in-out bg-primary text-primary-actionButtonText py-3 px-2 md:px-3
|
|
14
|
+
return (_jsx("div", { children: _jsx(Address, { partner: partner, children: () => (_jsxs("div", { className: "border border-primary disabled:border-primary-900 items-center space-x-1 disabled:text-opacity-40 disabled:bg-primary-900 disabled:cursor-not-allowed relative w-full flex justify-center font-semibold rounded-md transform hover:brightness-125 transition duration-200 ease-in-out bg-primary text-primary-actionButtonText py-3 px-2 md:px-3", children: [_jsx("span", { className: "order-first absolute left-0 inset-y-0 flex items-center pl-3", children: _jsx(PlusIcon, { className: "stroke-1" }) }), _jsx("span", { className: "grow text-center", children: "Enter destination address" })] })) }) }));
|
|
15
15
|
}
|
|
16
16
|
return (_jsx(SwapButton, { className: "plausible-event-name=Swap+initiated", type: "submit", isDisabled: !isValid, isSubmitting: isSubmitting, children: ActionText(errors, actionDisplayName) }));
|
|
17
17
|
};
|
|
@@ -11,14 +11,14 @@ export class SelectMenuItemGroup {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
export default function CommandSelect({ values, setValue, show, setShow, searchHint, valueGrouper, isLoading, modalHeight = 'full', modalContent, header }) {
|
|
14
|
-
const { isDesktop,
|
|
14
|
+
const { isDesktop, isMobileWithPortal, windowSize } = useWindowDimensions();
|
|
15
15
|
let groups = valueGrouper(values);
|
|
16
16
|
const handleSelectValue = useCallback((item) => {
|
|
17
17
|
setValue(item);
|
|
18
18
|
setShow(false);
|
|
19
19
|
}, [setValue, setShow]);
|
|
20
20
|
const inputRef = React.useRef(null);
|
|
21
|
-
return (_jsx(VaulDrawer, { header: header, show: show, setShow: setShow, modalId: 'comandSelect', onAnimationEnd: () => { isDesktop && show && inputRef.current?.focus(); }, children: _jsx(VaulDrawer.Snap, { id: 'item-1', style: { height:
|
|
21
|
+
return (_jsx(VaulDrawer, { header: header, show: show, setShow: setShow, modalId: 'comandSelect', onAnimationEnd: () => { isDesktop && show && inputRef.current?.focus(); }, children: _jsx(VaulDrawer.Snap, { id: 'item-1', style: { height: isMobileWithPortal && windowSize.height ? `${(windowSize.height * 0.8).toFixed()}px` : '' }, fullheight: isDesktop, children: _jsxs(CommandWrapper, { children: [searchHint &&
|
|
22
22
|
_jsx(CommandInput, { ref: inputRef, placeholder: searchHint }), modalContent, !isLoading ?
|
|
23
23
|
_jsxs(CommandList, { children: [_jsx(CommandEmpty, { children: "No results found." }), groups.filter(g => g.items?.length > 0).map((group) => {
|
|
24
24
|
return (_jsx(CommandGroup, { heading: group.name, children: group.items.map(item => {
|
|
@@ -16,7 +16,7 @@ import VaulDrawer from "../../Modal/vaulModal";
|
|
|
16
16
|
import CopyButton from "../../Buttons/copyButton";
|
|
17
17
|
import LayerSwapLogoSmall from "../../Icons/layerSwapLogoSmall";
|
|
18
18
|
const ConnectorsLsit = ({ onFinish }) => {
|
|
19
|
-
const { isMobile } = useWindowDimensions();
|
|
19
|
+
const { isMobileWithPortal: isMobile } = useWindowDimensions();
|
|
20
20
|
const { providers } = useWallet();
|
|
21
21
|
const { setSelectedConnector, selectedProvider, setSelectedProvider, selectedConnector } = useConnectModal();
|
|
22
22
|
let [recentConnectors, setRecentConnectors] = usePersistedState([], 'recentConnectors', 'localStorage');
|
|
@@ -30,7 +30,7 @@ const Comp = ({ children, hidden, sticky = true }) => {
|
|
|
30
30
|
return (sticky ?
|
|
31
31
|
_jsxs(_Fragment, { children: [_jsx(motion.div, { ref: footerRef, transition: {
|
|
32
32
|
duration: 0.15,
|
|
33
|
-
}, custom: { direction: -1, width: 100 }, variants: variants, className: `text-primary-text text-base
|
|
33
|
+
}, custom: { direction: -1, width: 100 }, variants: variants, className: `text-primary-text text-base
|
|
34
34
|
max-sm:fixed
|
|
35
35
|
max-sm:inset-x-0
|
|
36
36
|
max-sm:bottom-0
|
|
@@ -49,7 +49,7 @@ const Comp = ({ children, hidden, sticky = true }) => {
|
|
|
49
49
|
const Footer = ({ children, hidden, sticky }) => {
|
|
50
50
|
const isFooterVisible = LayerSwapApiClient.apiKey !== AppSettings.LayerswapApiKeys['mainnet'] &&
|
|
51
51
|
LayerSwapApiClient.apiKey !== AppSettings.LayerswapApiKeys['testnet'];
|
|
52
|
-
const isFooterSticky = AppSettings.ThemeData?.
|
|
52
|
+
const isFooterSticky = (AppSettings.ThemeData?.enablePortal && AppSettings.ThemeData?.enablePortal == true) ?? false;
|
|
53
53
|
return (_jsxs(Comp, { hidden: hidden, sticky: isFooterSticky ? sticky : false, children: [children, isFooterVisible &&
|
|
54
54
|
_jsxs("a", { target: "_blank", href: 'https://layerswap.io/', className: "flex justify-center text-primary-text-placeholder mt-3 -mb-1.5 sm:-mb-3", children: [_jsx("span", { className: "text-xs content-center", children: "Powered by" }), " ", _jsx(GoHomeButton, { className: 'ml-1 fill-primary-text-placeholder h-5 w-auto cursor-pointer' })] })] }));
|
|
55
55
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
export declare const WidgetLoading: FC;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { MenuIcon } from "lucide-react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import ColorSchema from "./ColorSchema";
|
|
4
|
+
import AppSettings from "../lib/AppSettings";
|
|
5
|
+
export const WidgetLoading = () => {
|
|
6
|
+
return (_jsxs(_Fragment, { children: [_jsx(ColorSchema, { themeData: AppSettings.ThemeData }), _jsx("div", { className: "layerswap-styles w-full h-full z-[1] sm:mb-6 mx-auto", children: _jsx("div", { className: "flex h-full content-center items-center justify-center flex-col container mx-auto", children: _jsx("div", { className: "flex h-full flex-col w-full", children: _jsx("div", { className: "bg-secondary-900 rounded-lg w-full sm:overflow-hidden relative text-left", children: _jsx("div", { className: "relative", children: _jsx("div", { className: "flex items-start", children: _jsx("div", { className: "flex flex-nowrap grow w-full", children: _jsx("div", { className: "w-full pb-6 flex flex-col justify-between text-secondary-500 sm:min-h-[500px] h-full", children: _jsxs("div", { className: "flex flex-col", children: [_jsx("div", { className: "w-full grid grid-cols-5 px-6 mt-3 pb-1", children: _jsx("div", { className: "col-start-5 justify-self-end self-center flex items-center gap-x-1 -mr-2", children: _jsx("div", { className: "mx-2 space-y-1 py-1.5", children: _jsx(MenuIcon, { strokeWidth: "2" }) }) }) }), _jsxs("div", { className: "px-6", children: [_jsxs("div", { className: "bg-secondary-700 pt-8 grid grid-cols-6 gap-2 space-y-1 items-end p-3 rounded-xl my-4 mb-12", children: [_jsx("div", { className: "col-span-4 h-12 bg-secondary-600 rounded-lg animate-pulse mt-6", children: "\u00A0" }), _jsx("div", { className: "col-span-2 h-12 bg-secondary-600 rounded-lg animate-pulse mt-6", children: "\u00A0" }), _jsx("div", { className: "col-start-4 col-span-1 flex justify-start items-center py-2", children: _jsx("div", { className: "w-8 h-8 bg-secondary-600 rounded-lg animate-pulse" }) }), _jsx("div", { className: "col-span-4 h-12 bg-secondary-600 rounded-lg animate-pulse", children: "\u00A0" }), _jsx("div", { className: "col-span-2 h-12 bg-secondary-600 rounded-lg animate-pulse", children: "\u00A0" })] }), _jsx("div", { className: "w-full h-12 bg-secondary-600 rounded-lg animate-pulse mt-2", children: "\u00A0" }), _jsx("div", { className: "mt-10", children: _jsx("div", { className: "w-full h-[50px] bg-primary animate-pulse rounded-lg" }) })] })] }) }) }) }) }) }) }) }) })] }));
|
|
7
|
+
};
|
|
@@ -2,16 +2,16 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { X } from "lucide-react";
|
|
3
3
|
import toast, { ToastBar, Toaster } from "react-hot-toast";
|
|
4
4
|
export default function ThemeWrapper({ children }) {
|
|
5
|
-
return _jsx("
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
return _jsx("main", { className: "styled-scroll", children: _jsxs("div", { className: `flex flex-col items-center overflow-hidden relative font-robo`, children: [_jsx(Toaster, { containerStyle: {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
}, toastOptions: {
|
|
8
|
+
duration: 5000,
|
|
9
|
+
style: {
|
|
10
|
+
background: '#131E36',
|
|
11
|
+
color: '#a4afc8'
|
|
12
|
+
},
|
|
13
|
+
error: {
|
|
14
|
+
duration: Infinity,
|
|
15
|
+
},
|
|
16
|
+
}, children: (t) => (_jsx(ToastBar, { toast: t, children: ({ icon, message }) => (_jsxs(_Fragment, { children: [icon, message, t.type !== 'loading' && (_jsx("button", { type: "button", onClick: () => toast.dismiss(t.id), children: _jsx(X, { className: "h-5" }) }))] })) })) }), _jsx("div", { className: "w-full h-full z-[1]", children: _jsx("div", { className: "flex h-full content-center items-center justify-center space-y-5 flex-col container mx-auto", children: _jsx("div", { className: "flex h-full flex-col w-full text-primary-text", children: children }) }) }), _jsx("div", { id: "offset-for-stickyness", className: "block md:hidden" })] }) });
|
|
17
17
|
}
|
|
@@ -16,4 +16,6 @@ export type LayerswapContextProps = {
|
|
|
16
16
|
icons?: string[];
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
declare const LayerswapProviderComponent: FC<LayerswapContextProps>;
|
|
20
|
+
export declare const LayerswapProvider: typeof LayerswapProviderComponent;
|
|
21
|
+
export {};
|
|
@@ -10,20 +10,20 @@ import ErrorFallback from "../components/ErrorFallback";
|
|
|
10
10
|
import QueryProvider from "./query";
|
|
11
11
|
import { THEME_COLORS } from "../Models/Theme";
|
|
12
12
|
import { TooltipProvider } from "../components/shadcn/tooltip";
|
|
13
|
-
import ColorSchema from "../components/ColorSchema";
|
|
14
13
|
import { AsyncModalProvider } from "./asyncModal";
|
|
15
14
|
import WalletsProviders from "../components/Wallet/WalletProviders";
|
|
16
15
|
import { IntercomProvider } from 'react-use-intercom';
|
|
17
16
|
import AppSettings from "../lib/AppSettings";
|
|
18
17
|
import { getSettings } from "../helpers/getSettings";
|
|
19
|
-
import WidgetLoading from "../components/WidgetLoading";
|
|
18
|
+
import { WidgetLoading } from "../components/WidgetLoading";
|
|
20
19
|
import LayerSwapApiClient from "../lib/layerSwapApiClient";
|
|
20
|
+
import ColorSchema from "../components/ColorSchema";
|
|
21
21
|
const INTERCOM_APP_ID = 'h5zisg78';
|
|
22
|
-
|
|
22
|
+
const LayerswapProviderComponent = ({ children, settings: _settings, themeData, apiKey, integrator, version, walletConnect }) => {
|
|
23
23
|
const [fetchedSettings, setFetchedSettings] = useState(null);
|
|
24
24
|
AppSettings.ApiVersion = version;
|
|
25
25
|
AppSettings.Integrator = integrator;
|
|
26
|
-
AppSettings.ThemeData = themeData;
|
|
26
|
+
AppSettings.ThemeData = { ...THEME_COLORS['default'], ...themeData };
|
|
27
27
|
LayerSwapApiClient.apiKey = apiKey;
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
if (!_settings) {
|
|
@@ -36,12 +36,12 @@ export const LayerswapProvider = ({ children, settings: _settings, themeData, ap
|
|
|
36
36
|
}
|
|
37
37
|
}, []);
|
|
38
38
|
const settings = _settings || fetchedSettings;
|
|
39
|
-
if (!settings)
|
|
40
|
-
return
|
|
41
|
-
_jsx(ColorSchema, { themeData: themeData }), _jsx(WidgetLoading, {})] });
|
|
42
|
-
}
|
|
39
|
+
if (!settings)
|
|
40
|
+
return _jsx(WidgetLoading, {});
|
|
43
41
|
let appSettings = new LayerSwapAppSettings(settings);
|
|
44
|
-
themeData =
|
|
45
|
-
return (
|
|
46
|
-
|
|
42
|
+
themeData = { ...THEME_COLORS['default'], ...themeData };
|
|
43
|
+
return (_jsx(IntercomProvider, { appId: INTERCOM_APP_ID, initializeDelay: 2500, children: _jsx(QueryProvider, { query: {}, children: _jsx(SettingsProvider, { data: appSettings, children: _jsx(AuthProvider, { children: _jsx(TooltipProvider, { delayDuration: 500, children: _jsx(ErrorBoundary, { FallbackComponent: ErrorFallback, children: _jsx(ThemeWrapper, { children: _jsx(WalletsProviders, { themeData: themeData, children: _jsx(AsyncModalProvider, { children: children }) }) }) }) }) }) }) }) }));
|
|
44
|
+
};
|
|
45
|
+
export const LayerswapProvider = (props) => {
|
|
46
|
+
return (_jsxs(_Fragment, { children: [_jsx(ColorSchema, { themeData: props.themeData }), _jsx("div", { style: { backgroundColor: 'transparent' }, className: "layerswap-styles", children: _jsx(LayerswapProviderComponent, { ...props, children: props.children }) })] }));
|
|
47
47
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
+
import AppSettings from "../lib/AppSettings";
|
|
2
3
|
export default function useWindowDimensions() {
|
|
3
4
|
const [windowSize, setWindowSize] = useState({
|
|
4
5
|
width: undefined,
|
|
@@ -20,9 +21,12 @@ export default function useWindowDimensions() {
|
|
|
20
21
|
// Remove event listener on cleanup
|
|
21
22
|
return () => window.removeEventListener("resize", handleResize);
|
|
22
23
|
}, []); // Empty array ensures that effect is only run on mount
|
|
24
|
+
const isMobile = typeof windowSize?.width === "number" && windowSize?.width < 768;
|
|
25
|
+
const isDesktop = typeof windowSize?.width === "number" && windowSize?.width >= 768;
|
|
23
26
|
return {
|
|
24
27
|
windowSize,
|
|
25
|
-
isMobile
|
|
26
|
-
|
|
28
|
+
isMobile,
|
|
29
|
+
isMobileWithPortal: isMobile && AppSettings.ThemeData?.enablePortal == true,
|
|
30
|
+
isDesktop
|
|
27
31
|
};
|
|
28
32
|
}
|