@0xsquid/ui 0.9.3 → 0.9.5
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/cjs/index.js +78 -79
- package/dist/cjs/types/components/lists/HistoryItem.d.ts +3 -1
- package/dist/cjs/types/components/lists/SettingsItem.d.ts +1 -0
- package/dist/cjs/types/providers/SquidConfigProvider.d.ts +1 -1
- package/dist/cjs/types/services/internal/colorService.d.ts +16 -1
- package/dist/cjs/types/types/config.d.ts +23 -16
- package/dist/esm/index.js +78 -79
- package/dist/esm/types/components/lists/HistoryItem.d.ts +3 -1
- package/dist/esm/types/components/lists/SettingsItem.d.ts +1 -0
- package/dist/esm/types/providers/SquidConfigProvider.d.ts +1 -1
- package/dist/esm/types/services/internal/colorService.d.ts +16 -1
- package/dist/esm/types/types/config.d.ts +23 -16
- package/dist/index.css +8 -0
- package/dist/index.d.ts +22 -34
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2680,12 +2680,6 @@ const SQUID_THEME_CSS_VARIABLE_PREFIX = '--squid-theme-';
|
|
|
2680
2680
|
* Mapping between readable variables name and css variables used TailwindCSS config
|
|
2681
2681
|
*/
|
|
2682
2682
|
const themeTypesKeys = {
|
|
2683
|
-
'accent-gold': {
|
|
2684
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}accent-gold`,
|
|
2685
|
-
},
|
|
2686
|
-
'accent-salmon': {
|
|
2687
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}accent-salmon`,
|
|
2688
|
-
},
|
|
2689
2683
|
'grey-100': {
|
|
2690
2684
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}grey-100`,
|
|
2691
2685
|
},
|
|
@@ -2731,54 +2725,18 @@ const themeTypesKeys = {
|
|
|
2731
2725
|
'material-light-thin': {
|
|
2732
2726
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}material-light-thin`,
|
|
2733
2727
|
},
|
|
2734
|
-
'royal-100': {
|
|
2735
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-100`,
|
|
2736
|
-
},
|
|
2737
|
-
'royal-200': {
|
|
2738
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-200`,
|
|
2739
|
-
},
|
|
2740
|
-
'royal-300': {
|
|
2741
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-300`,
|
|
2742
|
-
},
|
|
2743
2728
|
'royal-400': {
|
|
2744
2729
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-400`,
|
|
2745
2730
|
},
|
|
2746
2731
|
'royal-500': {
|
|
2747
2732
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-500`,
|
|
2748
2733
|
},
|
|
2749
|
-
'royal-600': {
|
|
2750
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-600`,
|
|
2751
|
-
},
|
|
2752
|
-
'royal-700': {
|
|
2753
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-700`,
|
|
2754
|
-
},
|
|
2755
|
-
'royal-800': {
|
|
2756
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-800`,
|
|
2757
|
-
},
|
|
2758
2734
|
'status-negative': {
|
|
2759
2735
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}status-negative`,
|
|
2760
2736
|
},
|
|
2761
2737
|
'status-positive': {
|
|
2762
2738
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}status-positive`,
|
|
2763
2739
|
},
|
|
2764
|
-
'volt-300': {
|
|
2765
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-300`,
|
|
2766
|
-
},
|
|
2767
|
-
'volt-400': {
|
|
2768
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-400`,
|
|
2769
|
-
},
|
|
2770
|
-
'volt-600': {
|
|
2771
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-600`,
|
|
2772
|
-
},
|
|
2773
|
-
'volt-700': {
|
|
2774
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-700`,
|
|
2775
|
-
},
|
|
2776
|
-
'volt-800': {
|
|
2777
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-800`,
|
|
2778
|
-
},
|
|
2779
|
-
'volt-900': {
|
|
2780
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-900`,
|
|
2781
|
-
},
|
|
2782
2740
|
};
|
|
2783
2741
|
|
|
2784
2742
|
function PlusIcon() {
|
|
@@ -3191,13 +3149,14 @@ const dropdownPositionClassMap = {
|
|
|
3191
3149
|
bottom: 'tw-right-[calc(100%-10px)] tw-top-7',
|
|
3192
3150
|
center: 'tw-right-[40px] -tw-top-[55px]',
|
|
3193
3151
|
};
|
|
3194
|
-
function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel = 'Pending', dropdownMenuItems, }) {
|
|
3152
|
+
function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel = 'Pending', dropdownMenuItems, itemsContainerRef, }) {
|
|
3195
3153
|
const { isDropdownOpen, dropdownRef, openDropdownButtonRef, openDropdown } = useDropdownMenu();
|
|
3196
3154
|
const [dropdownPosition, setDropdownPosition] = react.useState(null);
|
|
3197
3155
|
const itemRef = react.useRef(null);
|
|
3198
3156
|
const menuRef = react.useRef(null);
|
|
3199
3157
|
// Effect to find the best position for the dropdown menu, so it's always visible for the user
|
|
3200
3158
|
react.useEffect(() => {
|
|
3159
|
+
var _a;
|
|
3201
3160
|
if (!isDropdownOpen) {
|
|
3202
3161
|
// when the dropdown is closed, we want to reset its position
|
|
3203
3162
|
// because user may scroll, and the old position may be out of view, so we'll need to recalculate it
|
|
@@ -3205,7 +3164,7 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
|
|
|
3205
3164
|
return;
|
|
3206
3165
|
}
|
|
3207
3166
|
const item = itemRef.current;
|
|
3208
|
-
const itemsContainer = item === null || item === void 0 ? void 0 : item.parentElement;
|
|
3167
|
+
const itemsContainer = (_a = itemsContainerRef === null || itemsContainerRef === void 0 ? void 0 : itemsContainerRef.current) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.parentElement;
|
|
3209
3168
|
const dropdownMenu = menuRef.current;
|
|
3210
3169
|
if (!item || !dropdownRef.current || !itemsContainer || !dropdownMenu) {
|
|
3211
3170
|
return;
|
|
@@ -3240,7 +3199,7 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
|
|
|
3240
3199
|
}
|
|
3241
3200
|
}, [isDropdownOpen, menuRef, dropdownPosition, itemRef]);
|
|
3242
3201
|
return (jsxRuntime.jsx("li", { ref: itemRef, className: "tw-h-list-item-large tw-min-w-list-item-small tw-self-stretch tw-bg-grey-900 tw-px-squid-xs tw-text-grey-300", children: jsxRuntime.jsxs("div", { className: "tw-group/history-item tw-relative tw-flex tw-flex-shrink-0 tw-cursor-pointer tw-items-center tw-gap-squid-xs tw-self-stretch tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs hover:tw-bg-material-light-thin", children: [jsxRuntime.jsxs("div", { className: "tw-relative tw-h-10 tw-w-[60px]", children: [isPending ? (jsxRuntime.jsx("span", { className: "tw-absolute -tw-left-[5px] tw-bottom-0 tw-z-30 tw-flex tw-h-squid-m tw-w-squid-m tw-items-center tw-justify-center tw-rounded-full tw-border tw-border-grey-900 tw-bg-royal-400 tw-p-0.5", children: jsxRuntime.jsx(DotGrid1x3HorizontalIcon, {}) })) : null, jsxRuntime.jsx("img", { src: firstImageUrl, className: "tw-absolute tw-h-10 tw-w-10 tw-rounded-full tw-border tw-border-grey-900" }), jsxRuntime.jsx("img", { src: secondImageUrl, className: "tw-absolute tw-left-5 tw-h-10 tw-w-10 tw-rounded-full tw-border tw-border-grey-900" })] }), jsxRuntime.jsxs("div", { className: "tw-flex tw-h-10 tw-flex-1 tw-flex-col tw-self-stretch", children: [jsxRuntime.jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-justify-between tw-text-grey-500", children: [jsxRuntime.jsxs("div", { className: "tw-flex tw-items-center", children: [jsxRuntime.jsx(CaptionText, { children: fromLabel }), jsxRuntime.jsx("span", { className: "tw-text-grey-600", children: jsxRuntime.jsx(ChevronRightSmallIcon, {}) }), jsxRuntime.jsx(CaptionText, { children: toLabel })] }), !!dropdownMenuItems && (jsxRuntime.jsx("button", { className: "tw-peer tw-absolute tw-right-squid-xxs tw-top-squid-xxs tw-flex tw-h-squid-xl tw-w-squid-xl tw-items-center tw-justify-center tw-rounded-squid-xs tw-bg-material-light-thin tw-p-2 tw-text-grey-300 tw-opacity-0 tw-transition-opacity focus:tw-opacity-100 group-hover/history-item:tw-opacity-100", onClick: openDropdown, ref: openDropdownButtonRef, children: jsxRuntime.jsx(DotGrid1x3HorizontalIcon, { size: "24" }) })), jsxRuntime.jsx("div", { className: cn(!!dropdownMenuItems &&
|
|
3243
|
-
'tw-transition-opacity group-hover/history-item:tw-opacity-0 peer-focus:tw-opacity-0'), children: isPending ? (jsxRuntime.jsx(CaptionText, { className: "tw-text-royal-400", children: pendingLabel })) : (jsxRuntime.jsx(CaptionText, { children: dateCompleted })) })] }), jsxRuntime.jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-gap-squid-xxs tw-text-grey-300", children: [jsxRuntime.jsx(BodyText, { size: "small", children: fromAmount }), jsxRuntime.jsx("span", { className: "tw-text-grey-600", children: jsxRuntime.jsx(ChevronLargeRightIcon, {}) }), jsxRuntime.jsx(BodyText, { size: "small", children: toAmount })] })] }), isDropdownOpen && !!dropdownMenuItems ? (jsxRuntime.jsx(DropdownMenu, { menuRef: menuRef,
|
|
3202
|
+
'tw-transition-opacity group-hover/history-item:tw-hidden group-hover/history-item:tw-opacity-0 peer-focus:tw-hidden peer-focus:tw-opacity-0'), children: isPending ? (jsxRuntime.jsx(CaptionText, { className: "tw-text-royal-400", children: pendingLabel })) : (jsxRuntime.jsx(CaptionText, { children: dateCompleted })) })] }), jsxRuntime.jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-gap-squid-xxs tw-text-grey-300", children: [jsxRuntime.jsx(BodyText, { size: "small", children: fromAmount }), jsxRuntime.jsx("span", { className: "tw-text-grey-600", children: jsxRuntime.jsx(ChevronLargeRightIcon, {}) }), jsxRuntime.jsx(BodyText, { size: "small", children: toAmount })] })] }), isDropdownOpen && !!dropdownMenuItems ? (jsxRuntime.jsx(DropdownMenu, { menuRef: menuRef,
|
|
3244
3203
|
// only show dropdown menu if there is a position defined for it
|
|
3245
3204
|
isHidden: !dropdownPosition, className: cn(!!dropdownPosition && dropdownPositionClassMap[dropdownPosition]), dropdownRef: dropdownRef, items: dropdownMenuItems })) : null] }) }));
|
|
3246
3205
|
}
|
|
@@ -3290,7 +3249,7 @@ function SettingsItem({ icon, label, controls = [], link, transparent = false, h
|
|
|
3290
3249
|
return (jsxRuntime.jsx("li", { className: cn('tw-h-[50px] tw-self-stretch tw-px-squid-xs', transparent ? 'tw-bg-transparent' : 'tw-bg-grey-800'), children: jsxRuntime.jsxs(ContentTag, Object.assign({ className: cn('tw-flex tw-items-center tw-justify-center tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xs tw-text-grey-300', link && 'hover:tw-bg-material-light-thin') }, contentTagProps, { children: [icon, jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-1 tw-items-center tw-gap-squid-xxs tw-self-stretch", children: [jsxRuntime.jsx(BodyText, { size: "small", children: label }), helpTooltip ? (jsxRuntime.jsx(Tooltip, Object.assign({}, helpTooltip, { children: helpIcon }))) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: helpIcon }))] }), jsxRuntime.jsx("div", { className: cn('tw-flex tw-h-squid-l tw-items-center tw-justify-center tw-rounded-squid-xs', showDetailsBorder &&
|
|
3291
3250
|
'tw-rounded-squid-xs tw-border tw-border-solid tw-border-material-light-thin tw-bg-material-dark-thin'), children: !!link ? (jsxRuntime.jsx(SquareArrowTopRight2Icon, { className: "tw-text-material-light-average" })) : (controls.map((control, index) => {
|
|
3292
3251
|
if (control.type === 'switch') {
|
|
3293
|
-
const switchControl = (jsxRuntime.jsx(Switch, { size: "large", checked: control.checked, onChange: control.onChange }, index));
|
|
3252
|
+
const switchControl = (jsxRuntime.jsx(Switch, { size: "large", checked: control.checked, onChange: control.onChange, disabled: control.disabled }, index));
|
|
3294
3253
|
if (control.tooltip) {
|
|
3295
3254
|
return jsxRuntime.jsx(Tooltip, Object.assign({}, control.tooltip, { children: switchControl }));
|
|
3296
3255
|
}
|
|
@@ -3500,42 +3459,82 @@ function TokenPair({ firstToken, secondToken }) {
|
|
|
3500
3459
|
}, children: [jsxRuntime.jsx("img", { className: "tw-ml-[1px] tw-aspect-square tw-w-10", src: firstToken.imageUrl }), jsxRuntime.jsx("img", { className: "tw-mr-[1px] tw-aspect-square tw-w-10", src: secondToken.imageUrl })] })] }));
|
|
3501
3460
|
}
|
|
3502
3461
|
|
|
3462
|
+
const themeKeysToReplace = [
|
|
3463
|
+
{
|
|
3464
|
+
userKey: 'content',
|
|
3465
|
+
internalKey: 'grey',
|
|
3466
|
+
},
|
|
3467
|
+
{
|
|
3468
|
+
userKey: 'accent',
|
|
3469
|
+
internalKey: 'royal',
|
|
3470
|
+
},
|
|
3471
|
+
{
|
|
3472
|
+
userKey: 'transparent',
|
|
3473
|
+
internalKey: 'material',
|
|
3474
|
+
},
|
|
3475
|
+
];
|
|
3503
3476
|
/**
|
|
3504
3477
|
* Parsing the user readable config to css variables
|
|
3478
|
+
* Also maps the public theme variables to the internal theme variables
|
|
3479
|
+
* example user theme:
|
|
3480
|
+
* {
|
|
3481
|
+
* 'content-100': '#000',
|
|
3482
|
+
* 'content-200': '#000',
|
|
3483
|
+
* 'accent-400': '#000',
|
|
3484
|
+
* 'transparent-light-thin': '#000'
|
|
3485
|
+
* }
|
|
3486
|
+
* Resulting in:
|
|
3487
|
+
* {
|
|
3488
|
+
* 'grey-100': '#000',
|
|
3489
|
+
* 'grey-200': '#000',
|
|
3490
|
+
* 'royal-400': '#000',
|
|
3491
|
+
* 'material-light-thin': '#000'
|
|
3492
|
+
* }
|
|
3505
3493
|
* @param style
|
|
3506
3494
|
*/
|
|
3507
|
-
const
|
|
3508
|
-
if (
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
}
|
|
3495
|
+
const parseSquidTheme = (userTheme) => {
|
|
3496
|
+
if (!userTheme)
|
|
3497
|
+
return undefined;
|
|
3498
|
+
const squidTheme = Object.entries(userTheme).reduce((internalKeys, [userKey, userValue]) => {
|
|
3499
|
+
// content-* -> grey-*
|
|
3500
|
+
// accent-* -> royal-*
|
|
3501
|
+
// transparent-* -> material-*
|
|
3502
|
+
const keyToReplace = themeKeysToReplace.find((k) => userKey.includes(k.userKey));
|
|
3503
|
+
if (keyToReplace) {
|
|
3504
|
+
const newKey = userKey.replace(keyToReplace.userKey, keyToReplace.internalKey);
|
|
3505
|
+
internalKeys[newKey] = userValue;
|
|
3506
|
+
}
|
|
3507
|
+
return internalKeys;
|
|
3508
|
+
}, {});
|
|
3509
|
+
const styleKeys = Object.keys(themeTypesKeys);
|
|
3510
|
+
const parsed = styleKeys.map((sk) => {
|
|
3511
|
+
const themeItem = themeTypesKeys[sk];
|
|
3512
|
+
let userValue = squidTheme[sk];
|
|
3513
|
+
return {
|
|
3514
|
+
[themeItem.cssVariable]: userValue,
|
|
3515
|
+
};
|
|
3516
|
+
});
|
|
3517
|
+
// adds a variant with 0.05 opacity for each color
|
|
3518
|
+
// will result in variables like this:
|
|
3519
|
+
// var(--squid-theme-grey-100-005) --> grey-100 with 0.05 opacity
|
|
3520
|
+
// styleKeys.forEach((sk) => {
|
|
3521
|
+
// const themeItem = themeTypesKeys[sk]
|
|
3522
|
+
// const valueWith005Opacity = getHexColorFromOpacityPercentage(
|
|
3523
|
+
// style[sk], // i.e "#ffffff"
|
|
3524
|
+
// 0.05,
|
|
3525
|
+
// )
|
|
3526
|
+
// // { "--squid-theme-grey-100-005": "#ffffff80" }
|
|
3527
|
+
// parsed.push({
|
|
3528
|
+
// [`${themeItem.cssVariable}-005`]: valueWith005Opacity,
|
|
3529
|
+
// })
|
|
3530
|
+
// })
|
|
3531
|
+
parsed.push({
|
|
3532
|
+
[`${themeTypesKeys['grey-100'].cssVariable}-005`]: getHexColorFromOpacityPercentage(squidTheme['grey-100'], 0.05),
|
|
3533
|
+
});
|
|
3534
|
+
return parsed.reduce((a, v) => {
|
|
3535
|
+
const key = Object.keys(v)[0];
|
|
3536
|
+
return Object.assign(Object.assign({}, a), { [key]: v[key] });
|
|
3537
|
+
});
|
|
3539
3538
|
};
|
|
3540
3539
|
/**
|
|
3541
3540
|
* Returns a hexadecimal color with opacity based on the given color and opacity percentage.
|
|
@@ -3554,7 +3553,7 @@ function getHexColorFromOpacityPercentage(color, opacity) {
|
|
|
3554
3553
|
}
|
|
3555
3554
|
|
|
3556
3555
|
function SquidConfigProvider({ theme, children, themeType = 'light', }) {
|
|
3557
|
-
const parsedStyle =
|
|
3556
|
+
const parsedStyle = parseSquidTheme(theme);
|
|
3558
3557
|
return (jsxRuntime.jsx("div", { style: parsedStyle, "data-squid-theme-type": themeType, className: "tw-group tw-relative tw-font-geist", children: children }));
|
|
3559
3558
|
}
|
|
3560
3559
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { DropdownMenuItemProps } from './DropdownMenuItem';
|
|
2
3
|
interface HistoryItemProps {
|
|
3
4
|
firstImageUrl: string;
|
|
@@ -10,6 +11,7 @@ interface HistoryItemProps {
|
|
|
10
11
|
fromAmount: string;
|
|
11
12
|
toAmount: string;
|
|
12
13
|
dropdownMenuItems?: DropdownMenuItemProps[];
|
|
14
|
+
itemsContainerRef?: React.RefObject<HTMLElement>;
|
|
13
15
|
}
|
|
14
|
-
export declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, }: HistoryItemProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, itemsContainerRef, }: HistoryItemProps): import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { SquidTheme } from '../types/config';
|
|
3
2
|
import { ThemeType } from '../types/components';
|
|
3
|
+
import { SquidTheme } from '../types/config';
|
|
4
4
|
export declare function SquidConfigProvider({ theme, children, themeType, }: {
|
|
5
5
|
theme: SquidTheme;
|
|
6
6
|
children?: React.ReactNode;
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { SquidTheme } from '../../types/config';
|
|
2
2
|
/**
|
|
3
3
|
* Parsing the user readable config to css variables
|
|
4
|
+
* Also maps the public theme variables to the internal theme variables
|
|
5
|
+
* example user theme:
|
|
6
|
+
* {
|
|
7
|
+
* 'content-100': '#000',
|
|
8
|
+
* 'content-200': '#000',
|
|
9
|
+
* 'accent-400': '#000',
|
|
10
|
+
* 'transparent-light-thin': '#000'
|
|
11
|
+
* }
|
|
12
|
+
* Resulting in:
|
|
13
|
+
* {
|
|
14
|
+
* 'grey-100': '#000',
|
|
15
|
+
* 'grey-200': '#000',
|
|
16
|
+
* 'royal-400': '#000',
|
|
17
|
+
* 'material-light-thin': '#000'
|
|
18
|
+
* }
|
|
4
19
|
* @param style
|
|
5
20
|
*/
|
|
6
|
-
export declare const
|
|
21
|
+
export declare const parseSquidTheme: (userTheme?: SquidTheme) => {
|
|
7
22
|
[key: string]: string | undefined;
|
|
8
23
|
} | undefined;
|
|
9
24
|
export declare function getContrastColor({ r, g, b, }: {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The color format must be of type #FFFFFF
|
|
3
3
|
*/
|
|
4
4
|
export type ColorType = `#${string}${string}${string}${string}${string}${string}`;
|
|
5
|
-
export interface
|
|
5
|
+
export interface InternalSquidTheme {
|
|
6
6
|
'grey-100': string;
|
|
7
7
|
'grey-200': string;
|
|
8
8
|
'grey-300': string;
|
|
@@ -12,14 +12,8 @@ export interface SquidTheme {
|
|
|
12
12
|
'grey-700': string;
|
|
13
13
|
'grey-800': string;
|
|
14
14
|
'grey-900': string;
|
|
15
|
-
'royal-100': string;
|
|
16
|
-
'royal-200': string;
|
|
17
|
-
'royal-300': string;
|
|
18
15
|
'royal-400': string;
|
|
19
16
|
'royal-500': string;
|
|
20
|
-
'royal-600': string;
|
|
21
|
-
'royal-700': string;
|
|
22
|
-
'royal-800': string;
|
|
23
17
|
'status-positive': string;
|
|
24
18
|
'status-negative': string;
|
|
25
19
|
'material-light-thin': string;
|
|
@@ -28,19 +22,32 @@ export interface SquidTheme {
|
|
|
28
22
|
'material-dark-thin': string;
|
|
29
23
|
'material-dark-average': string;
|
|
30
24
|
'material-dark-thick': string;
|
|
31
|
-
'volt-300': string;
|
|
32
|
-
'volt-400': string;
|
|
33
|
-
'volt-600': string;
|
|
34
|
-
'volt-700': string;
|
|
35
|
-
'volt-800': string;
|
|
36
|
-
'volt-900': string;
|
|
37
|
-
'accent-salmon': string;
|
|
38
|
-
'accent-gold': string;
|
|
39
25
|
}
|
|
26
|
+
export type SquidTheme = {
|
|
27
|
+
'content-100': string;
|
|
28
|
+
'content-200': string;
|
|
29
|
+
'content-300': string;
|
|
30
|
+
'content-400': string;
|
|
31
|
+
'content-500': string;
|
|
32
|
+
'content-600': string;
|
|
33
|
+
'content-700': string;
|
|
34
|
+
'content-800': string;
|
|
35
|
+
'content-900': string;
|
|
36
|
+
'accent-400': string;
|
|
37
|
+
'accent-500': string;
|
|
38
|
+
'status-positive': string;
|
|
39
|
+
'status-negative': string;
|
|
40
|
+
'transparent-light-thin': string;
|
|
41
|
+
'transparent-light-average': string;
|
|
42
|
+
'transparent-light-thick': string;
|
|
43
|
+
'transparent-dark-thin': string;
|
|
44
|
+
'transparent-dark-average': string;
|
|
45
|
+
'transparent-dark-thick': string;
|
|
46
|
+
};
|
|
40
47
|
export declare const SQUID_THEME_CSS_VARIABLE_PREFIX = "--squid-theme-";
|
|
41
48
|
/**
|
|
42
49
|
* Mapping between readable variables name and css variables used TailwindCSS config
|
|
43
50
|
*/
|
|
44
|
-
export declare const themeTypesKeys: Record<keyof
|
|
51
|
+
export declare const themeTypesKeys: Record<keyof InternalSquidTheme, {
|
|
45
52
|
cssVariable: string;
|
|
46
53
|
}>;
|
package/dist/esm/index.js
CHANGED
|
@@ -2678,12 +2678,6 @@ const SQUID_THEME_CSS_VARIABLE_PREFIX = '--squid-theme-';
|
|
|
2678
2678
|
* Mapping between readable variables name and css variables used TailwindCSS config
|
|
2679
2679
|
*/
|
|
2680
2680
|
const themeTypesKeys = {
|
|
2681
|
-
'accent-gold': {
|
|
2682
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}accent-gold`,
|
|
2683
|
-
},
|
|
2684
|
-
'accent-salmon': {
|
|
2685
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}accent-salmon`,
|
|
2686
|
-
},
|
|
2687
2681
|
'grey-100': {
|
|
2688
2682
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}grey-100`,
|
|
2689
2683
|
},
|
|
@@ -2729,54 +2723,18 @@ const themeTypesKeys = {
|
|
|
2729
2723
|
'material-light-thin': {
|
|
2730
2724
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}material-light-thin`,
|
|
2731
2725
|
},
|
|
2732
|
-
'royal-100': {
|
|
2733
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-100`,
|
|
2734
|
-
},
|
|
2735
|
-
'royal-200': {
|
|
2736
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-200`,
|
|
2737
|
-
},
|
|
2738
|
-
'royal-300': {
|
|
2739
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-300`,
|
|
2740
|
-
},
|
|
2741
2726
|
'royal-400': {
|
|
2742
2727
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-400`,
|
|
2743
2728
|
},
|
|
2744
2729
|
'royal-500': {
|
|
2745
2730
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-500`,
|
|
2746
2731
|
},
|
|
2747
|
-
'royal-600': {
|
|
2748
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-600`,
|
|
2749
|
-
},
|
|
2750
|
-
'royal-700': {
|
|
2751
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-700`,
|
|
2752
|
-
},
|
|
2753
|
-
'royal-800': {
|
|
2754
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}royal-800`,
|
|
2755
|
-
},
|
|
2756
2732
|
'status-negative': {
|
|
2757
2733
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}status-negative`,
|
|
2758
2734
|
},
|
|
2759
2735
|
'status-positive': {
|
|
2760
2736
|
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}status-positive`,
|
|
2761
2737
|
},
|
|
2762
|
-
'volt-300': {
|
|
2763
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-300`,
|
|
2764
|
-
},
|
|
2765
|
-
'volt-400': {
|
|
2766
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-400`,
|
|
2767
|
-
},
|
|
2768
|
-
'volt-600': {
|
|
2769
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-600`,
|
|
2770
|
-
},
|
|
2771
|
-
'volt-700': {
|
|
2772
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-700`,
|
|
2773
|
-
},
|
|
2774
|
-
'volt-800': {
|
|
2775
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-800`,
|
|
2776
|
-
},
|
|
2777
|
-
'volt-900': {
|
|
2778
|
-
cssVariable: `${SQUID_THEME_CSS_VARIABLE_PREFIX}volt-900`,
|
|
2779
|
-
},
|
|
2780
2738
|
};
|
|
2781
2739
|
|
|
2782
2740
|
function PlusIcon() {
|
|
@@ -3189,13 +3147,14 @@ const dropdownPositionClassMap = {
|
|
|
3189
3147
|
bottom: 'tw-right-[calc(100%-10px)] tw-top-7',
|
|
3190
3148
|
center: 'tw-right-[40px] -tw-top-[55px]',
|
|
3191
3149
|
};
|
|
3192
|
-
function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel = 'Pending', dropdownMenuItems, }) {
|
|
3150
|
+
function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel = 'Pending', dropdownMenuItems, itemsContainerRef, }) {
|
|
3193
3151
|
const { isDropdownOpen, dropdownRef, openDropdownButtonRef, openDropdown } = useDropdownMenu();
|
|
3194
3152
|
const [dropdownPosition, setDropdownPosition] = useState(null);
|
|
3195
3153
|
const itemRef = useRef(null);
|
|
3196
3154
|
const menuRef = useRef(null);
|
|
3197
3155
|
// Effect to find the best position for the dropdown menu, so it's always visible for the user
|
|
3198
3156
|
useEffect(() => {
|
|
3157
|
+
var _a;
|
|
3199
3158
|
if (!isDropdownOpen) {
|
|
3200
3159
|
// when the dropdown is closed, we want to reset its position
|
|
3201
3160
|
// because user may scroll, and the old position may be out of view, so we'll need to recalculate it
|
|
@@ -3203,7 +3162,7 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
|
|
|
3203
3162
|
return;
|
|
3204
3163
|
}
|
|
3205
3164
|
const item = itemRef.current;
|
|
3206
|
-
const itemsContainer = item === null || item === void 0 ? void 0 : item.parentElement;
|
|
3165
|
+
const itemsContainer = (_a = itemsContainerRef === null || itemsContainerRef === void 0 ? void 0 : itemsContainerRef.current) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.parentElement;
|
|
3207
3166
|
const dropdownMenu = menuRef.current;
|
|
3208
3167
|
if (!item || !dropdownRef.current || !itemsContainer || !dropdownMenu) {
|
|
3209
3168
|
return;
|
|
@@ -3238,7 +3197,7 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
|
|
|
3238
3197
|
}
|
|
3239
3198
|
}, [isDropdownOpen, menuRef, dropdownPosition, itemRef]);
|
|
3240
3199
|
return (jsx("li", { ref: itemRef, className: "tw-h-list-item-large tw-min-w-list-item-small tw-self-stretch tw-bg-grey-900 tw-px-squid-xs tw-text-grey-300", children: jsxs("div", { className: "tw-group/history-item tw-relative tw-flex tw-flex-shrink-0 tw-cursor-pointer tw-items-center tw-gap-squid-xs tw-self-stretch tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs hover:tw-bg-material-light-thin", children: [jsxs("div", { className: "tw-relative tw-h-10 tw-w-[60px]", children: [isPending ? (jsx("span", { className: "tw-absolute -tw-left-[5px] tw-bottom-0 tw-z-30 tw-flex tw-h-squid-m tw-w-squid-m tw-items-center tw-justify-center tw-rounded-full tw-border tw-border-grey-900 tw-bg-royal-400 tw-p-0.5", children: jsx(DotGrid1x3HorizontalIcon, {}) })) : null, jsx("img", { src: firstImageUrl, className: "tw-absolute tw-h-10 tw-w-10 tw-rounded-full tw-border tw-border-grey-900" }), jsx("img", { src: secondImageUrl, className: "tw-absolute tw-left-5 tw-h-10 tw-w-10 tw-rounded-full tw-border tw-border-grey-900" })] }), jsxs("div", { className: "tw-flex tw-h-10 tw-flex-1 tw-flex-col tw-self-stretch", children: [jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-justify-between tw-text-grey-500", children: [jsxs("div", { className: "tw-flex tw-items-center", children: [jsx(CaptionText, { children: fromLabel }), jsx("span", { className: "tw-text-grey-600", children: jsx(ChevronRightSmallIcon, {}) }), jsx(CaptionText, { children: toLabel })] }), !!dropdownMenuItems && (jsx("button", { className: "tw-peer tw-absolute tw-right-squid-xxs tw-top-squid-xxs tw-flex tw-h-squid-xl tw-w-squid-xl tw-items-center tw-justify-center tw-rounded-squid-xs tw-bg-material-light-thin tw-p-2 tw-text-grey-300 tw-opacity-0 tw-transition-opacity focus:tw-opacity-100 group-hover/history-item:tw-opacity-100", onClick: openDropdown, ref: openDropdownButtonRef, children: jsx(DotGrid1x3HorizontalIcon, { size: "24" }) })), jsx("div", { className: cn(!!dropdownMenuItems &&
|
|
3241
|
-
'tw-transition-opacity group-hover/history-item:tw-opacity-0 peer-focus:tw-opacity-0'), children: isPending ? (jsx(CaptionText, { className: "tw-text-royal-400", children: pendingLabel })) : (jsx(CaptionText, { children: dateCompleted })) })] }), jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-gap-squid-xxs tw-text-grey-300", children: [jsx(BodyText, { size: "small", children: fromAmount }), jsx("span", { className: "tw-text-grey-600", children: jsx(ChevronLargeRightIcon, {}) }), jsx(BodyText, { size: "small", children: toAmount })] })] }), isDropdownOpen && !!dropdownMenuItems ? (jsx(DropdownMenu, { menuRef: menuRef,
|
|
3200
|
+
'tw-transition-opacity group-hover/history-item:tw-hidden group-hover/history-item:tw-opacity-0 peer-focus:tw-hidden peer-focus:tw-opacity-0'), children: isPending ? (jsx(CaptionText, { className: "tw-text-royal-400", children: pendingLabel })) : (jsx(CaptionText, { children: dateCompleted })) })] }), jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-gap-squid-xxs tw-text-grey-300", children: [jsx(BodyText, { size: "small", children: fromAmount }), jsx("span", { className: "tw-text-grey-600", children: jsx(ChevronLargeRightIcon, {}) }), jsx(BodyText, { size: "small", children: toAmount })] })] }), isDropdownOpen && !!dropdownMenuItems ? (jsx(DropdownMenu, { menuRef: menuRef,
|
|
3242
3201
|
// only show dropdown menu if there is a position defined for it
|
|
3243
3202
|
isHidden: !dropdownPosition, className: cn(!!dropdownPosition && dropdownPositionClassMap[dropdownPosition]), dropdownRef: dropdownRef, items: dropdownMenuItems })) : null] }) }));
|
|
3244
3203
|
}
|
|
@@ -3288,7 +3247,7 @@ function SettingsItem({ icon, label, controls = [], link, transparent = false, h
|
|
|
3288
3247
|
return (jsx("li", { className: cn('tw-h-[50px] tw-self-stretch tw-px-squid-xs', transparent ? 'tw-bg-transparent' : 'tw-bg-grey-800'), children: jsxs(ContentTag, Object.assign({ className: cn('tw-flex tw-items-center tw-justify-center tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xs tw-text-grey-300', link && 'hover:tw-bg-material-light-thin') }, contentTagProps, { children: [icon, jsxs("div", { className: "tw-flex tw-flex-1 tw-items-center tw-gap-squid-xxs tw-self-stretch", children: [jsx(BodyText, { size: "small", children: label }), helpTooltip ? (jsx(Tooltip, Object.assign({}, helpTooltip, { children: helpIcon }))) : (jsx(Fragment, { children: helpIcon }))] }), jsx("div", { className: cn('tw-flex tw-h-squid-l tw-items-center tw-justify-center tw-rounded-squid-xs', showDetailsBorder &&
|
|
3289
3248
|
'tw-rounded-squid-xs tw-border tw-border-solid tw-border-material-light-thin tw-bg-material-dark-thin'), children: !!link ? (jsx(SquareArrowTopRight2Icon, { className: "tw-text-material-light-average" })) : (controls.map((control, index) => {
|
|
3290
3249
|
if (control.type === 'switch') {
|
|
3291
|
-
const switchControl = (jsx(Switch, { size: "large", checked: control.checked, onChange: control.onChange }, index));
|
|
3250
|
+
const switchControl = (jsx(Switch, { size: "large", checked: control.checked, onChange: control.onChange, disabled: control.disabled }, index));
|
|
3292
3251
|
if (control.tooltip) {
|
|
3293
3252
|
return jsx(Tooltip, Object.assign({}, control.tooltip, { children: switchControl }));
|
|
3294
3253
|
}
|
|
@@ -3498,42 +3457,82 @@ function TokenPair({ firstToken, secondToken }) {
|
|
|
3498
3457
|
}, children: [jsx("img", { className: "tw-ml-[1px] tw-aspect-square tw-w-10", src: firstToken.imageUrl }), jsx("img", { className: "tw-mr-[1px] tw-aspect-square tw-w-10", src: secondToken.imageUrl })] })] }));
|
|
3499
3458
|
}
|
|
3500
3459
|
|
|
3460
|
+
const themeKeysToReplace = [
|
|
3461
|
+
{
|
|
3462
|
+
userKey: 'content',
|
|
3463
|
+
internalKey: 'grey',
|
|
3464
|
+
},
|
|
3465
|
+
{
|
|
3466
|
+
userKey: 'accent',
|
|
3467
|
+
internalKey: 'royal',
|
|
3468
|
+
},
|
|
3469
|
+
{
|
|
3470
|
+
userKey: 'transparent',
|
|
3471
|
+
internalKey: 'material',
|
|
3472
|
+
},
|
|
3473
|
+
];
|
|
3501
3474
|
/**
|
|
3502
3475
|
* Parsing the user readable config to css variables
|
|
3476
|
+
* Also maps the public theme variables to the internal theme variables
|
|
3477
|
+
* example user theme:
|
|
3478
|
+
* {
|
|
3479
|
+
* 'content-100': '#000',
|
|
3480
|
+
* 'content-200': '#000',
|
|
3481
|
+
* 'accent-400': '#000',
|
|
3482
|
+
* 'transparent-light-thin': '#000'
|
|
3483
|
+
* }
|
|
3484
|
+
* Resulting in:
|
|
3485
|
+
* {
|
|
3486
|
+
* 'grey-100': '#000',
|
|
3487
|
+
* 'grey-200': '#000',
|
|
3488
|
+
* 'royal-400': '#000',
|
|
3489
|
+
* 'material-light-thin': '#000'
|
|
3490
|
+
* }
|
|
3503
3491
|
* @param style
|
|
3504
3492
|
*/
|
|
3505
|
-
const
|
|
3506
|
-
if (
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
}
|
|
3493
|
+
const parseSquidTheme = (userTheme) => {
|
|
3494
|
+
if (!userTheme)
|
|
3495
|
+
return undefined;
|
|
3496
|
+
const squidTheme = Object.entries(userTheme).reduce((internalKeys, [userKey, userValue]) => {
|
|
3497
|
+
// content-* -> grey-*
|
|
3498
|
+
// accent-* -> royal-*
|
|
3499
|
+
// transparent-* -> material-*
|
|
3500
|
+
const keyToReplace = themeKeysToReplace.find((k) => userKey.includes(k.userKey));
|
|
3501
|
+
if (keyToReplace) {
|
|
3502
|
+
const newKey = userKey.replace(keyToReplace.userKey, keyToReplace.internalKey);
|
|
3503
|
+
internalKeys[newKey] = userValue;
|
|
3504
|
+
}
|
|
3505
|
+
return internalKeys;
|
|
3506
|
+
}, {});
|
|
3507
|
+
const styleKeys = Object.keys(themeTypesKeys);
|
|
3508
|
+
const parsed = styleKeys.map((sk) => {
|
|
3509
|
+
const themeItem = themeTypesKeys[sk];
|
|
3510
|
+
let userValue = squidTheme[sk];
|
|
3511
|
+
return {
|
|
3512
|
+
[themeItem.cssVariable]: userValue,
|
|
3513
|
+
};
|
|
3514
|
+
});
|
|
3515
|
+
// adds a variant with 0.05 opacity for each color
|
|
3516
|
+
// will result in variables like this:
|
|
3517
|
+
// var(--squid-theme-grey-100-005) --> grey-100 with 0.05 opacity
|
|
3518
|
+
// styleKeys.forEach((sk) => {
|
|
3519
|
+
// const themeItem = themeTypesKeys[sk]
|
|
3520
|
+
// const valueWith005Opacity = getHexColorFromOpacityPercentage(
|
|
3521
|
+
// style[sk], // i.e "#ffffff"
|
|
3522
|
+
// 0.05,
|
|
3523
|
+
// )
|
|
3524
|
+
// // { "--squid-theme-grey-100-005": "#ffffff80" }
|
|
3525
|
+
// parsed.push({
|
|
3526
|
+
// [`${themeItem.cssVariable}-005`]: valueWith005Opacity,
|
|
3527
|
+
// })
|
|
3528
|
+
// })
|
|
3529
|
+
parsed.push({
|
|
3530
|
+
[`${themeTypesKeys['grey-100'].cssVariable}-005`]: getHexColorFromOpacityPercentage(squidTheme['grey-100'], 0.05),
|
|
3531
|
+
});
|
|
3532
|
+
return parsed.reduce((a, v) => {
|
|
3533
|
+
const key = Object.keys(v)[0];
|
|
3534
|
+
return Object.assign(Object.assign({}, a), { [key]: v[key] });
|
|
3535
|
+
});
|
|
3537
3536
|
};
|
|
3538
3537
|
/**
|
|
3539
3538
|
* Returns a hexadecimal color with opacity based on the given color and opacity percentage.
|
|
@@ -3552,7 +3551,7 @@ function getHexColorFromOpacityPercentage(color, opacity) {
|
|
|
3552
3551
|
}
|
|
3553
3552
|
|
|
3554
3553
|
function SquidConfigProvider({ theme, children, themeType = 'light', }) {
|
|
3555
|
-
const parsedStyle =
|
|
3554
|
+
const parsedStyle = parseSquidTheme(theme);
|
|
3556
3555
|
return (jsx("div", { style: parsedStyle, "data-squid-theme-type": themeType, className: "tw-group tw-relative tw-font-geist", children: children }));
|
|
3557
3556
|
}
|
|
3558
3557
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { DropdownMenuItemProps } from './DropdownMenuItem';
|
|
2
3
|
interface HistoryItemProps {
|
|
3
4
|
firstImageUrl: string;
|
|
@@ -10,6 +11,7 @@ interface HistoryItemProps {
|
|
|
10
11
|
fromAmount: string;
|
|
11
12
|
toAmount: string;
|
|
12
13
|
dropdownMenuItems?: DropdownMenuItemProps[];
|
|
14
|
+
itemsContainerRef?: React.RefObject<HTMLElement>;
|
|
13
15
|
}
|
|
14
|
-
export declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, }: HistoryItemProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, itemsContainerRef, }: HistoryItemProps): import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { SquidTheme } from '../types/config';
|
|
3
2
|
import { ThemeType } from '../types/components';
|
|
3
|
+
import { SquidTheme } from '../types/config';
|
|
4
4
|
export declare function SquidConfigProvider({ theme, children, themeType, }: {
|
|
5
5
|
theme: SquidTheme;
|
|
6
6
|
children?: React.ReactNode;
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { SquidTheme } from '../../types/config';
|
|
2
2
|
/**
|
|
3
3
|
* Parsing the user readable config to css variables
|
|
4
|
+
* Also maps the public theme variables to the internal theme variables
|
|
5
|
+
* example user theme:
|
|
6
|
+
* {
|
|
7
|
+
* 'content-100': '#000',
|
|
8
|
+
* 'content-200': '#000',
|
|
9
|
+
* 'accent-400': '#000',
|
|
10
|
+
* 'transparent-light-thin': '#000'
|
|
11
|
+
* }
|
|
12
|
+
* Resulting in:
|
|
13
|
+
* {
|
|
14
|
+
* 'grey-100': '#000',
|
|
15
|
+
* 'grey-200': '#000',
|
|
16
|
+
* 'royal-400': '#000',
|
|
17
|
+
* 'material-light-thin': '#000'
|
|
18
|
+
* }
|
|
4
19
|
* @param style
|
|
5
20
|
*/
|
|
6
|
-
export declare const
|
|
21
|
+
export declare const parseSquidTheme: (userTheme?: SquidTheme) => {
|
|
7
22
|
[key: string]: string | undefined;
|
|
8
23
|
} | undefined;
|
|
9
24
|
export declare function getContrastColor({ r, g, b, }: {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The color format must be of type #FFFFFF
|
|
3
3
|
*/
|
|
4
4
|
export type ColorType = `#${string}${string}${string}${string}${string}${string}`;
|
|
5
|
-
export interface
|
|
5
|
+
export interface InternalSquidTheme {
|
|
6
6
|
'grey-100': string;
|
|
7
7
|
'grey-200': string;
|
|
8
8
|
'grey-300': string;
|
|
@@ -12,14 +12,8 @@ export interface SquidTheme {
|
|
|
12
12
|
'grey-700': string;
|
|
13
13
|
'grey-800': string;
|
|
14
14
|
'grey-900': string;
|
|
15
|
-
'royal-100': string;
|
|
16
|
-
'royal-200': string;
|
|
17
|
-
'royal-300': string;
|
|
18
15
|
'royal-400': string;
|
|
19
16
|
'royal-500': string;
|
|
20
|
-
'royal-600': string;
|
|
21
|
-
'royal-700': string;
|
|
22
|
-
'royal-800': string;
|
|
23
17
|
'status-positive': string;
|
|
24
18
|
'status-negative': string;
|
|
25
19
|
'material-light-thin': string;
|
|
@@ -28,19 +22,32 @@ export interface SquidTheme {
|
|
|
28
22
|
'material-dark-thin': string;
|
|
29
23
|
'material-dark-average': string;
|
|
30
24
|
'material-dark-thick': string;
|
|
31
|
-
'volt-300': string;
|
|
32
|
-
'volt-400': string;
|
|
33
|
-
'volt-600': string;
|
|
34
|
-
'volt-700': string;
|
|
35
|
-
'volt-800': string;
|
|
36
|
-
'volt-900': string;
|
|
37
|
-
'accent-salmon': string;
|
|
38
|
-
'accent-gold': string;
|
|
39
25
|
}
|
|
26
|
+
export type SquidTheme = {
|
|
27
|
+
'content-100': string;
|
|
28
|
+
'content-200': string;
|
|
29
|
+
'content-300': string;
|
|
30
|
+
'content-400': string;
|
|
31
|
+
'content-500': string;
|
|
32
|
+
'content-600': string;
|
|
33
|
+
'content-700': string;
|
|
34
|
+
'content-800': string;
|
|
35
|
+
'content-900': string;
|
|
36
|
+
'accent-400': string;
|
|
37
|
+
'accent-500': string;
|
|
38
|
+
'status-positive': string;
|
|
39
|
+
'status-negative': string;
|
|
40
|
+
'transparent-light-thin': string;
|
|
41
|
+
'transparent-light-average': string;
|
|
42
|
+
'transparent-light-thick': string;
|
|
43
|
+
'transparent-dark-thin': string;
|
|
44
|
+
'transparent-dark-average': string;
|
|
45
|
+
'transparent-dark-thick': string;
|
|
46
|
+
};
|
|
40
47
|
export declare const SQUID_THEME_CSS_VARIABLE_PREFIX = "--squid-theme-";
|
|
41
48
|
/**
|
|
42
49
|
* Mapping between readable variables name and css variables used TailwindCSS config
|
|
43
50
|
*/
|
|
44
|
-
export declare const themeTypesKeys: Record<keyof
|
|
51
|
+
export declare const themeTypesKeys: Record<keyof InternalSquidTheme, {
|
|
45
52
|
cssVariable: string;
|
|
46
53
|
}>;
|
package/dist/index.css
CHANGED
|
@@ -2697,6 +2697,10 @@ input[type='number'] {
|
|
|
2697
2697
|
display: flex;
|
|
2698
2698
|
}
|
|
2699
2699
|
|
|
2700
|
+
.tw-group\/history-item:hover .group-hover\/history-item\:tw-hidden {
|
|
2701
|
+
display: none;
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2700
2704
|
.tw-group\/history-item:hover .group-hover\/history-item\:tw-opacity-0 {
|
|
2701
2705
|
opacity: 0;
|
|
2702
2706
|
}
|
|
@@ -2714,6 +2718,10 @@ input[type='number'] {
|
|
|
2714
2718
|
display: block;
|
|
2715
2719
|
}
|
|
2716
2720
|
|
|
2721
|
+
.tw-peer:focus ~ .peer-focus\:tw-hidden {
|
|
2722
|
+
display: none;
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2717
2725
|
.tw-peer:focus ~ .peer-focus\:tw-opacity-0 {
|
|
2718
2726
|
opacity: 0;
|
|
2719
2727
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -202,8 +202,9 @@ interface HistoryItemProps {
|
|
|
202
202
|
fromAmount: string;
|
|
203
203
|
toAmount: string;
|
|
204
204
|
dropdownMenuItems?: DropdownMenuItemProps[];
|
|
205
|
+
itemsContainerRef?: React.RefObject<HTMLElement>;
|
|
205
206
|
}
|
|
206
|
-
declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, }: HistoryItemProps): react_jsx_runtime.JSX.Element;
|
|
207
|
+
declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, itemsContainerRef, }: HistoryItemProps): react_jsx_runtime.JSX.Element;
|
|
207
208
|
|
|
208
209
|
interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
209
210
|
itemTitle: string | React.ReactNode;
|
|
@@ -269,6 +270,7 @@ type SettingsControl = {
|
|
|
269
270
|
checked: boolean;
|
|
270
271
|
onChange: (checked: boolean) => void;
|
|
271
272
|
tooltip?: Omit<TooltipProps, 'children'>;
|
|
273
|
+
disabled?: boolean;
|
|
272
274
|
};
|
|
273
275
|
interface SettingsItemProps {
|
|
274
276
|
icon: React.ReactNode;
|
|
@@ -441,41 +443,27 @@ interface HeadingTextProps {
|
|
|
441
443
|
}
|
|
442
444
|
declare function HeadingText({ children, bold, size }: HeadingTextProps): react_jsx_runtime.JSX.Element;
|
|
443
445
|
|
|
444
|
-
|
|
445
|
-
'
|
|
446
|
-
'
|
|
447
|
-
'
|
|
448
|
-
'
|
|
449
|
-
'
|
|
450
|
-
'
|
|
451
|
-
'
|
|
452
|
-
'
|
|
453
|
-
'
|
|
454
|
-
'
|
|
455
|
-
'
|
|
456
|
-
'royal-300': string;
|
|
457
|
-
'royal-400': string;
|
|
458
|
-
'royal-500': string;
|
|
459
|
-
'royal-600': string;
|
|
460
|
-
'royal-700': string;
|
|
461
|
-
'royal-800': string;
|
|
446
|
+
type SquidTheme = {
|
|
447
|
+
'content-100': string;
|
|
448
|
+
'content-200': string;
|
|
449
|
+
'content-300': string;
|
|
450
|
+
'content-400': string;
|
|
451
|
+
'content-500': string;
|
|
452
|
+
'content-600': string;
|
|
453
|
+
'content-700': string;
|
|
454
|
+
'content-800': string;
|
|
455
|
+
'content-900': string;
|
|
456
|
+
'accent-400': string;
|
|
457
|
+
'accent-500': string;
|
|
462
458
|
'status-positive': string;
|
|
463
459
|
'status-negative': string;
|
|
464
|
-
'
|
|
465
|
-
'
|
|
466
|
-
'
|
|
467
|
-
'
|
|
468
|
-
'
|
|
469
|
-
'
|
|
470
|
-
|
|
471
|
-
'volt-400': string;
|
|
472
|
-
'volt-600': string;
|
|
473
|
-
'volt-700': string;
|
|
474
|
-
'volt-800': string;
|
|
475
|
-
'volt-900': string;
|
|
476
|
-
'accent-salmon': string;
|
|
477
|
-
'accent-gold': string;
|
|
478
|
-
}
|
|
460
|
+
'transparent-light-thin': string;
|
|
461
|
+
'transparent-light-average': string;
|
|
462
|
+
'transparent-light-thick': string;
|
|
463
|
+
'transparent-dark-thin': string;
|
|
464
|
+
'transparent-dark-average': string;
|
|
465
|
+
'transparent-dark-thick': string;
|
|
466
|
+
};
|
|
479
467
|
|
|
480
468
|
declare function SquidConfigProvider({ theme, children, themeType, }: {
|
|
481
469
|
theme: SquidTheme;
|