@babylonlabs-io/core-ui 1.29.1 → 1.30.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.
@@ -0,0 +1,5 @@
1
+ import type { AvatarProps } from "./Avatar";
2
+ export interface ValidatorAvatarProps extends Omit<AvatarProps, "children"> {
3
+ name: string;
4
+ }
5
+ export declare function ValidatorAvatar({ url, name, variant, size, ...props }: ValidatorAvatarProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Avatar } from "./Avatar";
3
+ import { Text } from "../Text";
4
+ export function ValidatorAvatar({ url, name, variant = "rounded", size = "large", ...props }) {
5
+ return (_jsx(Avatar, { ...props, url: url, alt: name, variant: variant, size: size, children: _jsx(Text, { as: "span", className: "inline-flex h-full w-full items-center justify-center bg-secondary-main text-xs text-accent-contrast", children: name?.charAt(0).toUpperCase() || "?" }) }));
6
+ }
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { ValidatorAvatar } from "./ValidatorAvatar";
3
+ declare const meta: Meta<typeof ValidatorAvatar>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Image: Story;
7
+ export declare const Initials: Story;
@@ -0,0 +1,21 @@
1
+ import { ValidatorAvatar } from "./ValidatorAvatar";
2
+ const meta = {
3
+ component: ValidatorAvatar,
4
+ tags: ["autodocs"],
5
+ };
6
+ export default meta;
7
+ export const Image = {
8
+ args: {
9
+ name: "Satoshi",
10
+ url: "/images/wallets/binance.webp",
11
+ size: "large",
12
+ variant: "rounded",
13
+ },
14
+ };
15
+ export const Initials = {
16
+ args: {
17
+ name: "Satoshi",
18
+ size: "large",
19
+ variant: "rounded",
20
+ },
21
+ };
@@ -1,2 +1,3 @@
1
1
  export * from "./Avatar";
2
2
  export * from "./AvatarGroup";
3
+ export * from "./ValidatorAvatar";
@@ -1,2 +1,3 @@
1
1
  export * from "./Avatar";
2
2
  export * from "./AvatarGroup";
3
+ export * from "./ValidatorAvatar";
@@ -9,3 +9,4 @@ export declare const AdaptiveRegular: Story;
9
9
  export declare const LongContentHorizontal: Story;
10
10
  export declare const LongContentVertical: Story;
11
11
  export declare const SingleItem: Story;
12
+ export declare const WithStatItems: Story;
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { MdOutlineInfo, MdAccountBalanceWallet, MdTrendingUp } from "react-icons/md";
3
3
  import { List } from "./List";
4
4
  import { ListItem } from "./components/ListItem";
5
+ import { StatItem } from "./StatItem";
5
6
  const meta = {
6
7
  component: List,
7
8
  tags: ["autodocs"],
@@ -67,3 +68,14 @@ export const SingleItem = {
67
68
  children: [_jsx(ListItem, { title: "Single Entry", value: "Only one item in list", suffix: _jsx(MdOutlineInfo, { size: 20 }) })],
68
69
  },
69
70
  };
71
+ export const WithStatItems = {
72
+ name: "With StatItem examples",
73
+ args: {
74
+ orientation: "adaptive",
75
+ children: [
76
+ _jsx(StatItem, { title: "Total BTC TVL", value: "2,345 BTC", tooltip: "Total value locked in BTC" }),
77
+ _jsx(StatItem, { title: "BTC Staking APR", value: "3.2%", tooltip: "Estimated APR" }),
78
+ _jsx(StatItem, { title: "Finality Providers", value: "24 Active (30 Total)" }),
79
+ ],
80
+ },
81
+ };
@@ -0,0 +1,10 @@
1
+ import { type JSX } from "react";
2
+ import { type ListItemProps } from "@/components/List";
3
+ export interface StatItemProps extends Omit<ListItemProps, "value" | "suffix"> {
4
+ hidden?: boolean;
5
+ loading?: boolean;
6
+ tooltip?: string | JSX.Element;
7
+ loadingStyle?: "spinner" | "spinner-and-value";
8
+ value: string | JSX.Element;
9
+ }
10
+ export declare const StatItem: ({ hidden, loading, title, value, tooltip, loadingStyle, ...props }: StatItemProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useId, useState } from "react";
3
+ import { AiOutlineInfoCircle } from "react-icons/ai";
4
+ import { Button } from "@/components/Button";
5
+ import { ListItem } from "@/components/List";
6
+ import { MobileDialog } from "@/components/Dialog";
7
+ import { useIsMobile } from "@/hooks";
8
+ import { Popover } from "@/components/Popover";
9
+ export const StatItem = ({ hidden = false, loading, title, value, tooltip, loadingStyle = "spinner", ...props }) => {
10
+ const tooltipId = useId();
11
+ const isMobileView = useIsMobile();
12
+ const [dialogOpen, setDialogOpen] = useState(false);
13
+ const [anchorEl, setAnchorEl] = useState(null);
14
+ useEffect(() => {
15
+ if (!isMobileView && dialogOpen) {
16
+ setDialogOpen(false);
17
+ }
18
+ }, [isMobileView, dialogOpen]);
19
+ if (hidden)
20
+ return null;
21
+ const spinnerEl = (_jsxs("div", { className: "inline-flex items-center gap-2", children: [_jsx("span", { className: "loader size-5" }), loadingStyle === "spinner-and-value" && _jsx("span", { className: "opacity-50", children: value })] }));
22
+ const suffixEl = tooltip ? (isMobileView ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "block size-5 cursor-pointer text-xs", onClick: () => setDialogOpen(true), children: _jsx(AiOutlineInfoCircle, { size: 20 }) }), _jsxs(MobileDialog, { open: dialogOpen, onClose: () => setDialogOpen(false), children: [_jsx("div", { className: "px-4 py-2 text-accent-primary", children: tooltip }), _jsx("div", { className: "p-4", children: _jsx(Button, { variant: "contained", fluid: true, onClick: () => setDialogOpen(false), children: "Done" }) })] })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "block size-5 cursor-pointer text-xs", onMouseEnter: (e) => setAnchorEl(e.currentTarget), onMouseLeave: () => setAnchorEl(null), "aria-describedby": tooltipId, children: _jsx(AiOutlineInfoCircle, { size: 20 }) }), _jsx(Popover, { open: !!anchorEl, anchorEl: anchorEl, placement: "top", offset: [0, 8], children: _jsx("div", { className: "tooltip-wrap", children: tooltip }) })] }))) : undefined;
23
+ return (_jsx(ListItem, { ...props, title: title, value: loading ? spinnerEl : value, suffix: suffixEl }));
24
+ };
@@ -1,2 +1,3 @@
1
1
  export * from "./List";
2
2
  export * from "./components/ListItem";
3
+ export * from "./StatItem";
@@ -1,2 +1,3 @@
1
1
  export * from "./List";
2
2
  export * from "./components/ListItem";
3
+ export * from "./StatItem";
@@ -1,3 +1,5 @@
1
1
  export { Copy } from './Copy';
2
2
  export { Toggle } from './Toggle';
3
3
  export { DisplayHash } from './DisplayHash';
4
+ export * from './Avatar';
5
+ export * from './Text';
@@ -1,3 +1,5 @@
1
1
  export { Copy } from './Copy';
2
2
  export { Toggle } from './Toggle';
3
3
  export { DisplayHash } from './DisplayHash';
4
+ export * from './Avatar';
5
+ export * from './Text';