rujira.ui 0.1.0
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/.eslintrc.cjs +21 -0
- package/.tool-versions +1 -0
- package/i18n/.github/workflows/validate.yml +13 -0
- package/i18n/README.md +7 -0
- package/i18n/translations/template.json +448 -0
- package/i18n/update-template.js +19 -0
- package/i18n/validate.js +10 -0
- package/lib/esm/i18n/translations/template.json +448 -0
- package/lib/esm/src/components/buttons/Button.js +37 -0
- package/lib/esm/src/components/buttons/Popout.js +56 -0
- package/lib/esm/src/components/buttons/TxButton.js +42 -0
- package/lib/esm/src/components/buttons/__Popout.js +34 -0
- package/lib/esm/src/components/cards/Card.js +8 -0
- package/lib/esm/src/components/cards/GradientCard.js +8 -0
- package/lib/esm/src/components/footer/Footer.js +11 -0
- package/lib/esm/src/components/header/Accounts.js +211 -0
- package/lib/esm/src/components/header/Header.js +69 -0
- package/lib/esm/src/components/header/QuickLauncher.js +10 -0
- package/lib/esm/src/components/header/ResolveLink.js +13 -0
- package/lib/esm/src/components/icons/IconDenom.js +358 -0
- package/lib/esm/src/components/icons/Icons.js +228 -0
- package/lib/esm/src/components/icons/Networks.js +32 -0
- package/lib/esm/src/components/icons/Wallets.js +62 -0
- package/lib/esm/src/components/inputs/Checkbox.js +12 -0
- package/lib/esm/src/components/inputs/DecimalInput.js +35 -0
- package/lib/esm/src/components/inputs/DenomInput.js +22 -0
- package/lib/esm/src/components/inputs/DenomSelect.js +66 -0
- package/lib/esm/src/components/inputs/Input.js +25 -0
- package/lib/esm/src/components/inputs/Numeric.js +18 -0
- package/lib/esm/src/components/inputs/Radio.js +12 -0
- package/lib/esm/src/components/inputs/Select.js +29 -0
- package/lib/esm/src/components/inputs/Textarea.js +25 -0
- package/lib/esm/src/components/inputs/Toggle.js +13 -0
- package/lib/esm/src/components/loader/Loader.js +3 -0
- package/lib/esm/src/components/logos/RujiraLogo.js +2 -0
- package/lib/esm/src/components/notices/Warning.js +10 -0
- package/lib/esm/src/components/numbers/Decimal.js +14 -0
- package/lib/esm/src/components/numbers/Fiat.js +19 -0
- package/lib/esm/src/components/progress/Progress.js +9 -0
- package/lib/esm/src/components/slider/Slider.js +5 -0
- package/lib/esm/src/context/Affiliate.js +34 -0
- package/lib/esm/src/context/GlobalModal.js +35 -0
- package/lib/esm/src/d.js +1 -0
- package/lib/esm/src/helpers/index.js +65 -0
- package/lib/esm/src/helpers/number.js +8 -0
- package/lib/esm/src/hooks/useClickOutside.js +19 -0
- package/lib/esm/src/hooks/useLocalStorage.js +12 -0
- package/lib/esm/src/hooks/useQueryParam.js +31 -0
- package/lib/esm/src/hooks/useWindowSize.js +19 -0
- package/lib/esm/src/i18n/i18n.js +90 -0
- package/lib/esm/src/i18n/index.js +1 -0
- package/lib/esm/src/index.js +38 -0
- package/lib/esm/src/services/account.js +42 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/package.json +47 -0
- package/src/assets/ghost-tokens/akt.png +0 -0
- package/src/assets/ghost-tokens/ampkuji.png +0 -0
- package/src/assets/ghost-tokens/arb.png +0 -0
- package/src/assets/ghost-tokens/atom.png +0 -0
- package/src/assets/ghost-tokens/axlusdc.png +0 -0
- package/src/assets/ghost-tokens/cro.png +0 -0
- package/src/assets/ghost-tokens/dot.png +0 -0
- package/src/assets/ghost-tokens/fet.png +0 -0
- package/src/assets/ghost-tokens/fuzn.png +0 -0
- package/src/assets/ghost-tokens/glmr.png +0 -0
- package/src/assets/ghost-tokens/gpaxg.png +0 -0
- package/src/assets/ghost-tokens/inj.png +0 -0
- package/src/assets/ghost-tokens/juno.png +0 -0
- package/src/assets/ghost-tokens/kuji.png +0 -0
- package/src/assets/ghost-tokens/luna.png +0 -0
- package/src/assets/ghost-tokens/lunc.png +0 -0
- package/src/assets/ghost-tokens/mnta.png +0 -0
- package/src/assets/ghost-tokens/ntrn.png +0 -0
- package/src/assets/ghost-tokens/osmo.png +0 -0
- package/src/assets/ghost-tokens/scrt.png +0 -0
- package/src/assets/ghost-tokens/shd.png +0 -0
- package/src/assets/ghost-tokens/sol.png +0 -0
- package/src/assets/ghost-tokens/stars.png +0 -0
- package/src/assets/ghost-tokens/statom.png +0 -0
- package/src/assets/ghost-tokens/stosmo.png +0 -0
- package/src/assets/ghost-tokens/usdc.png +0 -0
- package/src/assets/ghost-tokens/usk.png +0 -0
- package/src/assets/ghost-tokens/wavax.png +0 -0
- package/src/assets/ghost-tokens/wbnb.png +0 -0
- package/src/assets/ghost-tokens/wbtc.png +0 -0
- package/src/assets/ghost-tokens/weth.png +0 -0
- package/src/assets/ghost-tokens/wftm.png +0 -0
- package/src/assets/ghost-tokens/wglmr.png +0 -0
- package/src/assets/ghost-tokens/wmatic.png +0 -0
- package/src/assets/mono.woff +0 -0
- package/src/assets/tokens/acre.png +0 -0
- package/src/assets/tokens/akt.png +0 -0
- package/src/assets/tokens/amber.png +0 -0
- package/src/assets/tokens/ampkuji.png +0 -0
- package/src/assets/tokens/ampluna.png +0 -0
- package/src/assets/tokens/ampmnta.png +0 -0
- package/src/assets/tokens/ampwhale.png +0 -0
- package/src/assets/tokens/andr.png +0 -0
- package/src/assets/tokens/aqla.png +0 -0
- package/src/assets/tokens/aqua.png +0 -0
- package/src/assets/tokens/arb.png +0 -0
- package/src/assets/tokens/arch.png +0 -0
- package/src/assets/tokens/astro.png +0 -0
- package/src/assets/tokens/atom.png +0 -0
- package/src/assets/tokens/auto.png +0 -0
- package/src/assets/tokens/avax.png +0 -0
- package/src/assets/tokens/axl.png +0 -0
- package/src/assets/tokens/axlusdc.png +0 -0
- package/src/assets/tokens/axlusdt.png +0 -0
- package/src/assets/tokens/bad.png +0 -0
- package/src/assets/tokens/bch.png +0 -0
- package/src/assets/tokens/bfit.png +0 -0
- package/src/assets/tokens/bnb.png +0 -0
- package/src/assets/tokens/btc.png +0 -0
- package/src/assets/tokens/cheq.png +0 -0
- package/src/assets/tokens/cmdx.png +0 -0
- package/src/assets/tokens/cmst.png +0 -0
- package/src/assets/tokens/cnto.png +0 -0
- package/src/assets/tokens/core.png +0 -0
- package/src/assets/tokens/crbrus.png +0 -0
- package/src/assets/tokens/cre.png +0 -0
- package/src/assets/tokens/cro.png +0 -0
- package/src/assets/tokens/cub.png +0 -0
- package/src/assets/tokens/dai.png +0 -0
- package/src/assets/tokens/default.png +0 -0
- package/src/assets/tokens/doge.png +0 -0
- package/src/assets/tokens/dot.png +0 -0
- package/src/assets/tokens/dvpn.png +0 -0
- package/src/assets/tokens/dydx.png +0 -0
- package/src/assets/tokens/dym.png +0 -0
- package/src/assets/tokens/eth.png +0 -0
- package/src/assets/tokens/evmos.png +0 -0
- package/src/assets/tokens/flix.png +0 -0
- package/src/assets/tokens/frnz.png +0 -0
- package/src/assets/tokens/fury.legacy.png +0 -0
- package/src/assets/tokens/fury.png +0 -0
- package/src/assets/tokens/fuzn.png +0 -0
- package/src/assets/tokens/glmr.png +0 -0
- package/src/assets/tokens/glto.png +0 -0
- package/src/assets/tokens/gpaxg.png +0 -0
- package/src/assets/tokens/grav.png +0 -0
- package/src/assets/tokens/inj.png +0 -0
- package/src/assets/tokens/jkl.png +0 -0
- package/src/assets/tokens/juno.png +0 -0
- package/src/assets/tokens/kart.png +0 -0
- package/src/assets/tokens/kuji.png +0 -0
- package/src/assets/tokens/kune.png +0 -0
- package/src/assets/tokens/link.png +0 -0
- package/src/assets/tokens/loop.png +0 -0
- package/src/assets/tokens/ltc.png +0 -0
- package/src/assets/tokens/luna.png +0 -0
- package/src/assets/tokens/lunc.png +0 -0
- package/src/assets/tokens/lvn.png +0 -0
- package/src/assets/tokens/mars.png +0 -0
- package/src/assets/tokens/mnta.png +0 -0
- package/src/assets/tokens/mntl.png +0 -0
- package/src/assets/tokens/nami.png +0 -0
- package/src/assets/tokens/nausd.png +0 -0
- package/src/assets/tokens/nbtc.png +0 -0
- package/src/assets/tokens/neok.png +0 -0
- package/src/assets/tokens/newt.png +0 -0
- package/src/assets/tokens/nstk.png +0 -0
- package/src/assets/tokens/ntrn.png +0 -0
- package/src/assets/tokens/odin.png +0 -0
- package/src/assets/tokens/osmo.png +0 -0
- package/src/assets/tokens/pepe.png +0 -0
- package/src/assets/tokens/plnk.png +0 -0
- package/src/assets/tokens/plq.png +0 -0
- package/src/assets/tokens/qcaqla.png +0 -0
- package/src/assets/tokens/qcatom.png +0 -0
- package/src/assets/tokens/qcfuzn.png +0 -0
- package/src/assets/tokens/qckuji.png +0 -0
- package/src/assets/tokens/qcmnta.png +0 -0
- package/src/assets/tokens/rac.legacy.png +0 -0
- package/src/assets/tokens/rac.png +0 -0
- package/src/assets/tokens/ratom.png +0 -0
- package/src/assets/tokens/regen.png +0 -0
- package/src/assets/tokens/rfuzn.png +0 -0
- package/src/assets/tokens/rio.png +0 -0
- package/src/assets/tokens/rkuji.png +0 -0
- package/src/assets/tokens/roar.png +0 -0
- package/src/assets/tokens/ruji.png +0 -0
- package/src/assets/tokens/rune.png +0 -0
- package/src/assets/tokens/sayve.png +0 -0
- package/src/assets/tokens/scrt.png +0 -0
- package/src/assets/tokens/shd.legacy.png +0 -0
- package/src/assets/tokens/shd.png +0 -0
- package/src/assets/tokens/silk.png +0 -0
- package/src/assets/tokens/sol.png +0 -0
- package/src/assets/tokens/somm.png +0 -0
- package/src/assets/tokens/stars.png +0 -0
- package/src/assets/tokens/statom.png +0 -0
- package/src/assets/tokens/stinj.png +0 -0
- package/src/assets/tokens/stluna.png +0 -0
- package/src/assets/tokens/stosmo.png +0 -0
- package/src/assets/tokens/strd.png +0 -0
- package/src/assets/tokens/swth.png +0 -0
- package/src/assets/tokens/tia.png +0 -0
- package/src/assets/tokens/tori.png +0 -0
- package/src/assets/tokens/umee.png +0 -0
- package/src/assets/tokens/uni.png +0 -0
- package/src/assets/tokens/usdc.png +0 -0
- package/src/assets/tokens/usk.png +0 -0
- package/src/assets/tokens/usk_black.png +0 -0
- package/src/assets/tokens/ustc.png +0 -0
- package/src/assets/tokens/wavax.png +0 -0
- package/src/assets/tokens/wbtc.png +0 -0
- package/src/assets/tokens/wftm.png +0 -0
- package/src/assets/tokens/whale.png +0 -0
- package/src/assets/tokens/whlocal.png +0 -0
- package/src/assets/tokens/wink.png +0 -0
- package/src/assets/tokens/wmatic.png +0 -0
- package/src/assets/tokens/wsteth.png +0 -0
- package/src/assets/tokens/wtao.png +0 -0
- package/src/assets/tokens/xastro.png +0 -0
- package/src/assets/tokens/yieldeth.png +0 -0
- package/src/assets/tokens/yum.png +0 -0
- package/src/components/buttons/Button.tsx +80 -0
- package/src/components/buttons/Popout.tsx +74 -0
- package/src/components/buttons/TxButton.tsx +103 -0
- package/src/components/buttons/__Popout.tsx +56 -0
- package/src/components/cards/Card.tsx +17 -0
- package/src/components/cards/GradientCard.tsx +17 -0
- package/src/components/footer/Footer.tsx +117 -0
- package/src/components/header/Accounts.tsx +1021 -0
- package/src/components/header/Header.tsx +745 -0
- package/src/components/header/QuickLauncher.tsx +67 -0
- package/src/components/header/ResolveLink.tsx +81 -0
- package/src/components/icons/IconDenom.tsx +400 -0
- package/src/components/icons/Icons.tsx +686 -0
- package/src/components/icons/Networks.tsx +687 -0
- package/src/components/icons/Wallets.tsx +947 -0
- package/src/components/inputs/Checkbox.tsx +35 -0
- package/src/components/inputs/DecimalInput.tsx +72 -0
- package/src/components/inputs/DenomInput.tsx +65 -0
- package/src/components/inputs/DenomSelect.tsx +178 -0
- package/src/components/inputs/Input.tsx +66 -0
- package/src/components/inputs/Numeric.tsx +49 -0
- package/src/components/inputs/Radio.tsx +33 -0
- package/src/components/inputs/Select.tsx +69 -0
- package/src/components/inputs/Textarea.tsx +65 -0
- package/src/components/inputs/Toggle.tsx +38 -0
- package/src/components/loader/Loader.tsx +103 -0
- package/src/components/logos/RujiraLogo.tsx +83 -0
- package/src/components/notices/Warning.tsx +42 -0
- package/src/components/numbers/Decimal.tsx +43 -0
- package/src/components/numbers/Fiat.tsx +56 -0
- package/src/components/progress/Progress.tsx +40 -0
- package/src/components/slider/Slider.tsx +12 -0
- package/src/context/Affiliate.tsx +65 -0
- package/src/context/GlobalModal.tsx +115 -0
- package/src/d.ts +4 -0
- package/src/helpers/index.ts +73 -0
- package/src/helpers/number.ts +12 -0
- package/src/hooks/useClickOutside.ts +27 -0
- package/src/hooks/useLocalStorage.ts +20 -0
- package/src/hooks/useQueryParam.ts +46 -0
- package/src/hooks/useWindowSize.ts +26 -0
- package/src/i18n/i18n.tsx +102 -0
- package/src/i18n/index.ts +1 -0
- package/src/index.ts +54 -0
- package/src/scss/base/_colors.scss +23 -0
- package/src/scss/base/_display.scss +85 -0
- package/src/scss/base/_filters.scss +20 -0
- package/src/scss/base/_flex.scss +612 -0
- package/src/scss/base/_important.scss +3 -0
- package/src/scss/base/_normalize.scss +351 -0
- package/src/scss/base/_spacing.scss +290 -0
- package/src/scss/base/_tooltip.scss +9 -0
- package/src/scss/base/_typography.scss +279 -0
- package/src/scss/base/_variables.scss +72 -0
- package/src/scss/components/_button-group.scss +61 -0
- package/src/scss/components/_button.scss +459 -0
- package/src/scss/components/_decimal.scss +40 -0
- package/src/scss/components/_denom-select.scss +270 -0
- package/src/scss/components/_fiat.scss +34 -0
- package/src/scss/components/_footer.scss +27 -0
- package/src/scss/components/_header.scss +665 -0
- package/src/scss/components/_input.scss +82 -0
- package/src/scss/components/_loader.scss +20 -0
- package/src/scss/components/_modal.scss +138 -0
- package/src/scss/components/_numeric-input.scss +98 -0
- package/src/scss/components/_popout.scss +63 -0
- package/src/scss/components/_progress.scss +62 -0
- package/src/scss/components/_radio-checkbox.scss +79 -0
- package/src/scss/components/_select.scss +106 -0
- package/src/scss/components/_slider.scss +34 -0
- package/src/scss/components/_toggle.scss +120 -0
- package/src/scss/components/_warning.scss +65 -0
- package/src/scss/index.scss +37 -0
- package/src/scss/styledcomponents/_card.scss +130 -0
- package/src/scss/styledcomponents/_drawer.scss +36 -0
- package/src/scss/styledcomponents/_general.scss +20 -0
- package/src/scss/styledcomponents/_table.scss +302 -0
- package/src/scss/styledcomponents/_tabs.scss +97 -0
- package/src/scss/styledcomponents/_tag.scss +155 -0
- package/src/scss/unsorted/_general.scss +259 -0
- package/src/services/account.ts +53 -0
- package/tsconfig.json +25 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.ts +7 -0
- package/vitest-setup.js +1 -0
- package/vitest.config.js +13 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useMemo, } from "react";
|
|
3
|
+
const AFFILIATE = "rujira";
|
|
4
|
+
const FEE = 50;
|
|
5
|
+
const KEY = "refs";
|
|
6
|
+
const load = () => {
|
|
7
|
+
const json = localStorage.getItem(KEY) || "{}";
|
|
8
|
+
return JSON.parse(json);
|
|
9
|
+
};
|
|
10
|
+
const store = (ref) => {
|
|
11
|
+
const current = load();
|
|
12
|
+
if (!!current[ref.name])
|
|
13
|
+
return;
|
|
14
|
+
localStorage.setItem(KEY, JSON.stringify({ ...current, [ref.name]: ref }));
|
|
15
|
+
};
|
|
16
|
+
const context = createContext({
|
|
17
|
+
base: { name: AFFILIATE, fee: FEE },
|
|
18
|
+
});
|
|
19
|
+
export const AffiliateContext = ({ children }) => {
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const q = new URLSearchParams(window.location.search);
|
|
22
|
+
const aff = q.get("aff");
|
|
23
|
+
const split = aff?.split("-");
|
|
24
|
+
if (split?.length === 2) {
|
|
25
|
+
store({ name: split[0], fee: parseInt(split[1]), firstSeen: new Date() });
|
|
26
|
+
}
|
|
27
|
+
}, []);
|
|
28
|
+
const stored = useMemo(load, []);
|
|
29
|
+
const affiliate = Object.values(stored)
|
|
30
|
+
.sort((a, b) => a.firstSeen.getTime() - b.firstSeen.getTime())
|
|
31
|
+
.at(0);
|
|
32
|
+
return (_jsx(context.Provider, { value: { base: { name: AFFILIATE, fee: FEE }, affiliate }, children: children }));
|
|
33
|
+
};
|
|
34
|
+
export const useAffiliate = () => useContext(context);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useState, } from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
import { Xmark } from "../components/icons/Icons";
|
|
6
|
+
import { isEmpty } from "../helpers";
|
|
7
|
+
import { Button } from "../components/buttons/Button";
|
|
8
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
9
|
+
const initalState = {
|
|
10
|
+
showModal: () => { },
|
|
11
|
+
hideModal: () => { },
|
|
12
|
+
};
|
|
13
|
+
const GlobalModalContext = createContext(initalState);
|
|
14
|
+
export const useGlobalModalContext = () => useContext(GlobalModalContext);
|
|
15
|
+
export const GlobalModal = ({ children, }) => {
|
|
16
|
+
const [modalProps, setModalProps] = useState({});
|
|
17
|
+
const showModal = (modalProps) => {
|
|
18
|
+
setModalProps(modalProps);
|
|
19
|
+
};
|
|
20
|
+
const hideModal = () => {
|
|
21
|
+
setModalProps({});
|
|
22
|
+
};
|
|
23
|
+
const dest = document.getElementById("modal");
|
|
24
|
+
const renderComponent = () => {
|
|
25
|
+
return dest
|
|
26
|
+
? ReactDOM.createPortal(_jsx(AnimatePresence, { children: !isEmpty(modalProps) && (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, className: clsx({
|
|
27
|
+
modal: true,
|
|
28
|
+
[`${modalProps.className}`]: modalProps.className,
|
|
29
|
+
}), onClick: () => modalProps.backgroundClose ? hideModal() : null, children: _jsxs(motion.div, { initial: { scale: 0.9 }, animate: { scale: 1 }, exit: { scale: 0.9 }, className: "modal__window", onClick: (e) => {
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
}, children: [_jsxs("button", { className: "transparent modal__close fs-12 color-white fw-600 flex ai-c mr-1 mb-1 hover-primary1", onClick: hideModal, children: [_jsx(Xmark, { className: "w-2 h-a mr-1" }), "Close"] }), modalProps.title && (_jsx("div", { className: "modal__header", children: _jsx("h2", { children: modalProps.title }) })), modalProps.children && modalProps.children, modalProps.confirm && (_jsxs("div", { className: "modal__footer mt-4 px-3 py-2 text-right", children: [_jsx(Button, { className: "button--grey button--outline", onClick: hideModal, label: "Cancel" }), _jsx(Button, { className: "button ml-1", onClick: modalProps.confirm, label: "Confirm" })] }))] }) })) }), dest)
|
|
32
|
+
: null;
|
|
33
|
+
};
|
|
34
|
+
return (_jsxs(GlobalModalContext.Provider, { value: { showModal, hideModal }, children: [children, renderComponent()] }));
|
|
35
|
+
};
|
package/lib/esm/src/d.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const getLang = () => {
|
|
2
|
+
if (navigator.languages != undefined)
|
|
3
|
+
return navigator.languages[0];
|
|
4
|
+
return navigator.language;
|
|
5
|
+
};
|
|
6
|
+
export const whatDecimalSeparator = () => {
|
|
7
|
+
const n = 1.1;
|
|
8
|
+
const s = n.toLocaleString().substring(1, 2);
|
|
9
|
+
return s;
|
|
10
|
+
};
|
|
11
|
+
export const isEmpty = (obj) => {
|
|
12
|
+
for (const prop in obj) {
|
|
13
|
+
if (Object.hasOwn(obj, prop)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
export const uuidv4 = () => {
|
|
20
|
+
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => (+c ^
|
|
21
|
+
(crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))).toString(16));
|
|
22
|
+
};
|
|
23
|
+
export const nFormatter = (bigint, digits, decimals = 6) => {
|
|
24
|
+
const num = Number(bigint / BigInt(10 ** decimals));
|
|
25
|
+
const lookup = [
|
|
26
|
+
{ value: 1, symbol: "" },
|
|
27
|
+
{ value: 1e3, symbol: "k" },
|
|
28
|
+
{ value: 1e6, symbol: "M" },
|
|
29
|
+
{ value: 1e9, symbol: "G" },
|
|
30
|
+
{ value: 1e12, symbol: "T" },
|
|
31
|
+
{ value: 1e15, symbol: "P" },
|
|
32
|
+
{ value: 1e18, symbol: "E" },
|
|
33
|
+
];
|
|
34
|
+
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
|
|
35
|
+
var item = lookup
|
|
36
|
+
.slice()
|
|
37
|
+
.reverse()
|
|
38
|
+
.find(function (item) {
|
|
39
|
+
return num >= item.value;
|
|
40
|
+
});
|
|
41
|
+
return item
|
|
42
|
+
? (num / item.value).toFixed(digits).replace(rx, "$1") + item.symbol
|
|
43
|
+
: "0";
|
|
44
|
+
};
|
|
45
|
+
export const nFormatterInt = (num, digits) => {
|
|
46
|
+
const lookup = [
|
|
47
|
+
{ value: 1, symbol: "" },
|
|
48
|
+
{ value: 1e3, symbol: "k" },
|
|
49
|
+
{ value: 1e6, symbol: "M" },
|
|
50
|
+
{ value: 1e9, symbol: "G" },
|
|
51
|
+
{ value: 1e12, symbol: "T" },
|
|
52
|
+
{ value: 1e15, symbol: "P" },
|
|
53
|
+
{ value: 1e18, symbol: "E" },
|
|
54
|
+
];
|
|
55
|
+
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
|
|
56
|
+
var item = lookup
|
|
57
|
+
.slice()
|
|
58
|
+
.reverse()
|
|
59
|
+
.find(function (item) {
|
|
60
|
+
return num >= item.value;
|
|
61
|
+
});
|
|
62
|
+
return item
|
|
63
|
+
? (num / item.value).toFixed(digits).replace(rx, "$1") + item.symbol
|
|
64
|
+
: "0";
|
|
65
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
export const useClickOutside = (callback, isActive) => {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const handleClickOutside = (e) => {
|
|
6
|
+
const target = e.target;
|
|
7
|
+
if (ref.current && !ref.current.contains(target)) {
|
|
8
|
+
callback();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
if (isActive) {
|
|
12
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
13
|
+
}
|
|
14
|
+
return () => {
|
|
15
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
16
|
+
};
|
|
17
|
+
}, [isActive, callback]);
|
|
18
|
+
return ref;
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
export const useLocalStorage = (key, def) => {
|
|
3
|
+
const initial = useMemo(() => localStorage.getItem(key), [key]);
|
|
4
|
+
const [val, setLocalVal] = useState(initial ? JSON.parse(initial) : def);
|
|
5
|
+
const setVal = (v) => {
|
|
6
|
+
setLocalVal(v);
|
|
7
|
+
v
|
|
8
|
+
? localStorage.setItem(key, JSON.stringify(v))
|
|
9
|
+
: localStorage.removeItem(key);
|
|
10
|
+
};
|
|
11
|
+
return [val, setVal];
|
|
12
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useNavigate, useLocation } from "react-router-dom";
|
|
3
|
+
const useQuery = () => {
|
|
4
|
+
const { search } = useLocation();
|
|
5
|
+
return useMemo(() => new URLSearchParams(search), [search]);
|
|
6
|
+
};
|
|
7
|
+
export const useQueryParam = (key, initial) => {
|
|
8
|
+
const location = useLocation();
|
|
9
|
+
const navigate = useNavigate();
|
|
10
|
+
const q = useQuery();
|
|
11
|
+
const val = q.get(key) || initial;
|
|
12
|
+
const setVal = (s) => {
|
|
13
|
+
s ? q.set(key, s) : q.delete(key);
|
|
14
|
+
navigate(`${location.pathname}?${q.toString()}`);
|
|
15
|
+
};
|
|
16
|
+
return [val, setVal];
|
|
17
|
+
};
|
|
18
|
+
export const useQueryParams = (vals) => {
|
|
19
|
+
const location = useLocation();
|
|
20
|
+
const navigate = useNavigate();
|
|
21
|
+
const q = useQuery();
|
|
22
|
+
const val = Object.entries(vals).reduce((a, [k, v]) => ({ ...a, [k]: q.get(k) || v }), {});
|
|
23
|
+
const setVal = (s) => {
|
|
24
|
+
const r = Object.entries(s).reduce((a, [k, v]) => {
|
|
25
|
+
v ? a.set(k, v) : a.delete(k);
|
|
26
|
+
return a;
|
|
27
|
+
}, q);
|
|
28
|
+
navigate(`${location.pathname}?${r.toString()}`);
|
|
29
|
+
};
|
|
30
|
+
return [val, setVal];
|
|
31
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
export function useWindowSize() {
|
|
3
|
+
const [windowSize, setWindowSize] = useState({
|
|
4
|
+
width: window.outerWidth,
|
|
5
|
+
height: window.outerHeight,
|
|
6
|
+
});
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
function handleResize() {
|
|
9
|
+
setWindowSize({
|
|
10
|
+
width: window.innerWidth,
|
|
11
|
+
height: window.innerHeight,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
window.addEventListener("resize", handleResize);
|
|
15
|
+
handleResize();
|
|
16
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
17
|
+
}, []);
|
|
18
|
+
return windowSize;
|
|
19
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import template from "../../i18n/translations/template.json";
|
|
3
|
+
const replace = (string, replacements) => {
|
|
4
|
+
const r = replacements.pop();
|
|
5
|
+
if (r) {
|
|
6
|
+
return replace(string.replace("{}", r), replacements);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
return string;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const t = (string, replacements = []) => {
|
|
13
|
+
const lang = navigator.language;
|
|
14
|
+
const txs = translations(lang);
|
|
15
|
+
if (txs) {
|
|
16
|
+
const tx = replace(txs[string], replacements.reverse());
|
|
17
|
+
if (!tx)
|
|
18
|
+
txs[string] = "";
|
|
19
|
+
return tx || string;
|
|
20
|
+
}
|
|
21
|
+
return string;
|
|
22
|
+
};
|
|
23
|
+
const translations = (language) => {
|
|
24
|
+
switch (language) {
|
|
25
|
+
/* case "de":
|
|
26
|
+
case "de-DE":
|
|
27
|
+
return de;
|
|
28
|
+
case "tr":
|
|
29
|
+
case "tr-TR":
|
|
30
|
+
return tr;
|
|
31
|
+
case "es":
|
|
32
|
+
case "es-ES":
|
|
33
|
+
return es;
|
|
34
|
+
case "it":
|
|
35
|
+
case "it-IT":
|
|
36
|
+
return it;
|
|
37
|
+
case "ru":
|
|
38
|
+
case "ru-RU":
|
|
39
|
+
return ru;
|
|
40
|
+
case "ar":
|
|
41
|
+
case "ar-AE":
|
|
42
|
+
case "ar-BH":
|
|
43
|
+
case "ar-DZ":
|
|
44
|
+
case "ar-EG":
|
|
45
|
+
case "ar-IQ":
|
|
46
|
+
case "ar-JO":
|
|
47
|
+
case "ar-KW":
|
|
48
|
+
case "ar-LB":
|
|
49
|
+
case "ar-LY":
|
|
50
|
+
case "ar-MA":
|
|
51
|
+
case "ar-OM":
|
|
52
|
+
case "ar-QA":
|
|
53
|
+
case "ar-SA":
|
|
54
|
+
case "ar-SY":
|
|
55
|
+
case "ar-TN":
|
|
56
|
+
case "ar-YE":
|
|
57
|
+
return ar; */
|
|
58
|
+
default:
|
|
59
|
+
return template;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const comp = (tag) => (props) => createElement(tag, props, typeof props.children === "string" ? t(props.children) : props.children);
|
|
63
|
+
export const a = comp("a");
|
|
64
|
+
export const strong = comp("strong");
|
|
65
|
+
export const label = comp("label");
|
|
66
|
+
export const li = comp("li");
|
|
67
|
+
export const h1 = comp("h1");
|
|
68
|
+
export const h2 = comp("h2");
|
|
69
|
+
export const h3 = comp("h3");
|
|
70
|
+
export const h4 = comp("h4");
|
|
71
|
+
export const th = comp("th");
|
|
72
|
+
export const td = comp("td");
|
|
73
|
+
export const div = comp("div");
|
|
74
|
+
export const span = comp("span");
|
|
75
|
+
export const small = comp("small");
|
|
76
|
+
export const p = comp("p");
|
|
77
|
+
export const button = comp("button");
|
|
78
|
+
document.onkeyup = function (e) {
|
|
79
|
+
if (e.ctrlKey && e.shiftKey && e.key == "E") {
|
|
80
|
+
const lang = navigator.language;
|
|
81
|
+
const txs = translations(lang);
|
|
82
|
+
var a = document.createElement("a");
|
|
83
|
+
var file = new Blob([JSON.stringify(txs, null, 2)], {
|
|
84
|
+
type: "application/json",
|
|
85
|
+
});
|
|
86
|
+
a.href = URL.createObjectURL(file);
|
|
87
|
+
a.download = `${lang}.json`;
|
|
88
|
+
a.click();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as i18n from './i18n';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* global BigInt */
|
|
2
|
+
import "./helpers/number";
|
|
3
|
+
export * from "./components/buttons/Button";
|
|
4
|
+
export * from "./components/buttons/Popout";
|
|
5
|
+
export * from "./components/buttons/TxButton";
|
|
6
|
+
export * from "./components/cards/Card";
|
|
7
|
+
export * from "./components/cards/GradientCard";
|
|
8
|
+
export * from "./components/footer/Footer";
|
|
9
|
+
export { Header } from "./components/header/Header";
|
|
10
|
+
export * from "./components/header/ResolveLink";
|
|
11
|
+
export * from "./components/icons/IconDenom";
|
|
12
|
+
export * as Icons from "./components/icons/Icons";
|
|
13
|
+
export * as NetworkIcons from "./components/icons/Networks";
|
|
14
|
+
export * as WalletIcons from "./components/icons/Wallets";
|
|
15
|
+
export * from "./components/inputs/Checkbox";
|
|
16
|
+
export * from "./components/inputs/DenomInput";
|
|
17
|
+
export * from "./components/inputs/DenomSelect";
|
|
18
|
+
export * from "./components/inputs/Input";
|
|
19
|
+
export * from "./components/inputs/Numeric";
|
|
20
|
+
export * from "./components/inputs/Radio";
|
|
21
|
+
export * from "./components/inputs/Select";
|
|
22
|
+
export * from "./components/inputs/Textarea";
|
|
23
|
+
export * from "./components/inputs/Toggle";
|
|
24
|
+
export * from "./components/loader/Loader";
|
|
25
|
+
export * from "./components/logos/RujiraLogo";
|
|
26
|
+
export * from "./components/notices/Warning";
|
|
27
|
+
export * from "./components/numbers/Decimal";
|
|
28
|
+
export * from "./components/numbers/Fiat";
|
|
29
|
+
export * from "./components/progress/Progress";
|
|
30
|
+
export * from "./components/slider/Slider";
|
|
31
|
+
export * from "./hooks/useClickOutside";
|
|
32
|
+
export * from "./hooks/useLocalStorage";
|
|
33
|
+
export * from "./hooks/useQueryParam";
|
|
34
|
+
export * from "./hooks/useWindowSize";
|
|
35
|
+
export * from "./context/Affiliate";
|
|
36
|
+
export * from "./context/GlobalModal";
|
|
37
|
+
export * from "./i18n";
|
|
38
|
+
export * from "./services/account";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Network, Provider } from "rujira.js";
|
|
2
|
+
const STORAGE = window.localStorage;
|
|
3
|
+
const KEY_ACCOUNT = "rujira-account";
|
|
4
|
+
const KEY_ACCOUNTS = "rujira-accounts";
|
|
5
|
+
/**
|
|
6
|
+
* Fetches the persisted Account
|
|
7
|
+
*/
|
|
8
|
+
export const loadAccount = () => {
|
|
9
|
+
const stored = STORAGE.getItem(KEY_ACCOUNT);
|
|
10
|
+
if (!stored)
|
|
11
|
+
return undefined;
|
|
12
|
+
const parsed = JSON.parse(stored);
|
|
13
|
+
if (typeof parsed == "object" &&
|
|
14
|
+
"network" in parsed &&
|
|
15
|
+
Object.values(Network).includes(parsed.network) &&
|
|
16
|
+
"provider" in parsed &&
|
|
17
|
+
Object.values(Provider).includes(parsed.provider)) {
|
|
18
|
+
return parsed;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw new Error(`Invalid store ${stored}`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Persists a selected account
|
|
26
|
+
*/
|
|
27
|
+
export const saveAccount = (provider, network) => {
|
|
28
|
+
STORAGE.setItem(KEY_ACCOUNT, JSON.stringify({ provider, network }));
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Clears the persisted Account
|
|
32
|
+
*/
|
|
33
|
+
export const clearAccount = () => {
|
|
34
|
+
STORAGE.removeItem(KEY_ACCOUNT);
|
|
35
|
+
};
|
|
36
|
+
export const loadAccounts = () => JSON.parse(STORAGE.getItem(KEY_ACCOUNTS) || "[]");
|
|
37
|
+
export const saveAccounts = (as) => {
|
|
38
|
+
STORAGE.setItem(KEY_ACCOUNTS, JSON.stringify(as));
|
|
39
|
+
};
|
|
40
|
+
export const clearAccounts = () => {
|
|
41
|
+
STORAGE.removeItem(KEY_ACCOUNTS);
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../../src/d.ts","../../src/index.ts","../../src/components/buttons/button.tsx","../../src/components/buttons/popout.tsx","../../src/components/buttons/txbutton.tsx","../../src/components/buttons/__popout.tsx","../../src/components/cards/card.tsx","../../src/components/cards/gradientcard.tsx","../../src/components/footer/footer.tsx","../../src/components/header/accounts.tsx","../../src/components/header/header.tsx","../../src/components/header/quicklauncher.tsx","../../src/components/header/resolvelink.tsx","../../src/components/icons/icondenom.tsx","../../src/components/icons/icons.tsx","../../src/components/icons/networks.tsx","../../src/components/icons/wallets.tsx","../../src/components/inputs/checkbox.tsx","../../src/components/inputs/decimalinput.tsx","../../src/components/inputs/denominput.tsx","../../src/components/inputs/denomselect.tsx","../../src/components/inputs/input.tsx","../../src/components/inputs/numeric.tsx","../../src/components/inputs/radio.tsx","../../src/components/inputs/select.tsx","../../src/components/inputs/textarea.tsx","../../src/components/inputs/toggle.tsx","../../src/components/loader/loader.tsx","../../src/components/logos/rujiralogo.tsx","../../src/components/notices/warning.tsx","../../src/components/numbers/decimal.tsx","../../src/components/numbers/fiat.tsx","../../src/components/progress/progress.tsx","../../src/components/slider/slider.tsx","../../src/context/affiliate.tsx","../../src/context/globalmodal.tsx","../../src/helpers/index.ts","../../src/helpers/number.ts","../../src/hooks/useclickoutside.ts","../../src/hooks/uselocalstorage.ts","../../src/hooks/usequeryparam.ts","../../src/hooks/usewindowsize.ts","../../src/i18n/i18n.tsx","../../src/i18n/index.ts","../../src/services/account.ts"],"version":"5.6.2"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rujira.ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "vitest run",
|
|
8
|
+
"build": "tsc -b"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./lib/esm/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./types": "./lib/esm/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@keplr-wallet/types": "^0.12.151",
|
|
18
|
+
"clsx": "^2.1.1",
|
|
19
|
+
"ethers": "^6.13.4",
|
|
20
|
+
"jsdom": "^24.0.0",
|
|
21
|
+
"motion": "^11.12.0",
|
|
22
|
+
"react": "^18.3.1",
|
|
23
|
+
"react-dom": "^18.3.1",
|
|
24
|
+
"react-hot-toast": "^2.4.1",
|
|
25
|
+
"react-number-format": "^5.4.2",
|
|
26
|
+
"react-router-dom": "^6.26.2",
|
|
27
|
+
"react-slider": "^2.0.6",
|
|
28
|
+
"rujira.js": "workspace:*"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
32
|
+
"@testing-library/react": "^16.0.1",
|
|
33
|
+
"@types/react": "^18.3.4",
|
|
34
|
+
"@types/react-dom": "^18.3.0",
|
|
35
|
+
"@types/react-slider": "^1.3.6",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^8.2.0",
|
|
37
|
+
"@typescript-eslint/parser": "^8.2.0",
|
|
38
|
+
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
39
|
+
"eslint": "^8.57.0",
|
|
40
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
41
|
+
"eslint-plugin-react-refresh": "^0.4.6",
|
|
42
|
+
"sass": "^1.77.8",
|
|
43
|
+
"typescript": "^5.5.4",
|
|
44
|
+
"vite": "^5.2.0",
|
|
45
|
+
"vitest": "^1.5.0"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|