@0xsquid/ui 3.0.1 → 3.0.2

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 CHANGED
@@ -21410,7 +21410,7 @@ const mainImageSizeMap = {
21410
21410
  large: "xxlarge",
21411
21411
  small: "xlarge",
21412
21412
  };
21413
- function TokenGroup({ isSelected = false, tokenItems, priceChange, balance, balanceUsd, extraSpacing = true, chainImageUrl, imageUrl, symbol, name, onClick, variant = "large", className, onChildClick, isAdjacentToPreviousExpanded = false, isAdjacentToNextExpanded = false, }) {
21413
+ function TokenGroup({ isSelected = false, tokenItems, priceChange, balance, balanceUsd, extraSpacing = true, chainImageUrl, imageUrl, fallbackImageUrl, symbol, name, onClick, variant = "large", className, onChildClick, isAdjacentToPreviousExpanded = false, isAdjacentToNextExpanded = false, }) {
21414
21414
  var _a;
21415
21415
  const [isCollapsed, setIsCollapsed] = React$1.useState(true);
21416
21416
  const isCollapsible = tokenItems && tokenItems.length > 0;
@@ -21445,7 +21445,7 @@ function TokenGroup({ isSelected = false, tokenItems, priceChange, balance, bala
21445
21445
  : "tw-h-squid-xl tw-gap-squid-xxs"
21446
21446
  : isSmallVariant
21447
21447
  ? "tw-h-[50px] tw-gap-squid-s tw-py-squid-xxs"
21448
- : "tw-h-squid-xl tw-gap-squid-xxs"), children: [jsxRuntime.jsxs("div", { className: "tw-relative tw-min-w-fit", children: [jsxRuntime.jsx(Image$1, { src: imageUrl, size: isLargeVariant && !isCollapsed
21448
+ : "tw-h-squid-xl tw-gap-squid-xxs"), children: [jsxRuntime.jsxs("div", { className: "tw-relative tw-min-w-fit", children: [jsxRuntime.jsx(Image$1, { src: imageUrl, placeholderImageUrl: fallbackImageUrl, size: isLargeVariant && !isCollapsed
21449
21449
  ? "medium"
21450
21450
  : (_a = mainImageSizeMap[variant]) !== null && _a !== void 0 ? _a : "medium", rounded: isCompactVariant ? "xxs" : "full", style: {
21451
21451
  transition: `${ANIMATION_DURATIONS.GENERIC}ms ${ANIMATION_TIMINGS.GENERIC}`,
@@ -21762,6 +21762,7 @@ const DEFAULT_TIMEFRAME = "1D";
21762
21762
  const DefaultChart = ({ timeframe, }) => (jsxRuntime.jsx("div", { className: "tw-flex tw-h-full tw-w-full tw-items-center tw-justify-center", children: jsxRuntime.jsxs(BodyText, { size: "small", children: ["Chart (", timeframe, ")"] }) }));
21763
21763
  const TokenModalHeader = ({ token, chain, onLikeToken, onClose, isFavorite, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-w-full tw-items-start tw-justify-between", children: [jsxRuntime.jsx("div", { className: "tw-flex tw-items-center tw-gap-squid-xs tw-pb-squid-xs", children: jsxRuntime.jsx(BadgeImage, { image: {
21764
21764
  src: token.image,
21765
+ placeholderImageUrl: token.fallbackImage,
21765
21766
  size: "xxlarge",
21766
21767
  rounded: "full",
21767
21768
  shadow: true,
@@ -21772,7 +21773,7 @@ const TokenModalHeader = ({ token, chain, onLikeToken, onClose, isFavorite, }) =
21772
21773
  border: "outline-lg",
21773
21774
  } }) }), jsxRuntime.jsxs("span", { className: "tw-absolute tw-right-squid-xs tw-top-squid-xs tw-flex tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsx(IconButton, { className: "tw-group/token-detail-fav-icon tw-text-grey-300", onClick: onLikeToken, icon: isFavorite ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FilledHeartIcon, { className: "tw-block group-hover/token-detail-fav-icon:tw-hidden" }), jsxRuntime.jsx(BrokenHeartIcon, { className: "tw-hidden group-hover/token-detail-fav-icon:tw-block" })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(EmptyHeartIcon, { className: "tw-block group-hover/token-detail-fav-icon:tw-hidden" }), jsxRuntime.jsx(FilledHeartIcon, { className: "tw-hidden group-hover/token-detail-fav-icon:tw-block" })] })) }), jsxRuntime.jsx(IconButton, { className: "tw-text-grey-300", onClick: onClose, icon: jsxRuntime.jsx(CircleXFilledIcon, {}) })] })] }));
21774
21775
  const TokenInfo = ({ token, tokenPrice, priceChange, loading, }) => (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(BodyText, { size: "large", loading: { isLoading: loading, width: "100px" }, children: tokenPrice.toLocaleString() }), jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-row tw-items-center tw-justify-between", children: [jsxRuntime.jsx(BodyText, { size: "small", children: token.name }), jsxRuntime.jsx(PriceChange, { value: priceChange, variant: "large" })] })] }));
21775
- const BalanceInfo = ({ balance, balanceUSD, token, loading, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-col", children: [jsxRuntime.jsx(CaptionText, { className: "tw-text-grey-500", children: "Balance" }), jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-row tw-justify-between", children: [jsxRuntime.jsxs("span", { className: "tw-flex tw-flex-row tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsx("img", { src: token.image, alt: token.name, className: "tw-h-squid-m tw-w-squid-m tw-rounded-full" }), jsxRuntime.jsxs(BodyText, { size: "small", loading: { isLoading: loading, width: "80px" }, children: [balance, " ", token.symbol] })] }), jsxRuntime.jsxs(CaptionText, { className: "tw-text-grey-500", loading: { isLoading: loading, width: "60px" }, children: [jsxRuntime.jsx("span", { className: "tw-opacity-66", children: "$" }), balanceUSD] })] })] }));
21776
+ const BalanceInfo = ({ balance, balanceUSD, token, loading, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-col", children: [jsxRuntime.jsx(CaptionText, { className: "tw-text-grey-500", children: "Balance" }), jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-row tw-justify-between", children: [jsxRuntime.jsxs("span", { className: "tw-flex tw-flex-row tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsx(Image$1, { src: token.image, placeholderImageUrl: token.fallbackImage, alt: token.name, size: "medium", rounded: "full" }), jsxRuntime.jsxs(BodyText, { size: "small", loading: { isLoading: loading, width: "80px" }, children: [balance, " ", token.symbol] })] }), jsxRuntime.jsxs(CaptionText, { className: "tw-text-grey-500", loading: { isLoading: loading, width: "60px" }, children: [jsxRuntime.jsx("span", { className: "tw-opacity-66", children: "$" }), balanceUSD] })] })] }));
21776
21777
  const MarketDataItem = ({ label, value, showDollar, loading, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-col", children: [jsxRuntime.jsx(CaptionText, { className: "tw-text-grey-500", children: label }), jsxRuntime.jsxs(CaptionText, { loading: { isLoading: loading, width: "60px" }, children: [showDollar && jsxRuntime.jsx("span", { className: "tw-text-grey-500", children: "$" }), value] })] }));
21777
21778
  const TokenMarketData = ({ volume24h, marketCap, totalSupply, loading, }) => (jsxRuntime.jsxs("div", { className: "tw-mb-squid-xs tw-flex tw-h-full tw-w-full tw-flex-row tw-items-center tw-justify-between", children: [jsxRuntime.jsx(MarketDataItem, { label: "24h volume", value: volume24h, showDollar: true, loading: loading }), jsxRuntime.jsx(MarketDataItem, { label: "Market cap", value: marketCap, showDollar: true, loading: loading }), jsxRuntime.jsx(MarketDataItem, { label: "Total supply", value: totalSupply, loading: loading })] }));
21778
21779
  const FooterButton = (_a) => {
@@ -4,6 +4,7 @@ interface Token {
4
4
  name: string;
5
5
  symbol: string;
6
6
  image: string;
7
+ fallbackImage?: string;
7
8
  chainId: string;
8
9
  }
9
10
  interface Chain {
@@ -3,6 +3,7 @@ export type TokenGroupVariant = "compact" | "large" | "small";
3
3
  export interface TokenGroupProps<T> {
4
4
  isSelected?: boolean;
5
5
  imageUrl: string;
6
+ fallbackImageUrl?: string;
6
7
  symbol: string;
7
8
  name: string;
8
9
  chainImageUrl: string;
@@ -12,11 +13,10 @@ export interface TokenGroupProps<T> {
12
13
  tokenItems?: T[];
13
14
  extraSpacing?: boolean;
14
15
  onClick?: (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
15
- maxPreviewItems?: number;
16
16
  variant?: TokenGroupVariant;
17
17
  className?: string;
18
18
  onChildClick?: (tokenProps: T) => void;
19
19
  isAdjacentToPreviousExpanded?: boolean;
20
20
  isAdjacentToNextExpanded?: boolean;
21
21
  }
22
- export declare function TokenGroup<T extends TokenGroupProps<T>>({ isSelected, tokenItems, priceChange, balance, balanceUsd, extraSpacing, chainImageUrl, imageUrl, symbol, name, onClick, variant, className, onChildClick, isAdjacentToPreviousExpanded, isAdjacentToNextExpanded, }: TokenGroupProps<T>): import("react/jsx-runtime").JSX.Element;
22
+ export declare function TokenGroup<T extends TokenGroupProps<T>>({ isSelected, tokenItems, priceChange, balance, balanceUsd, extraSpacing, chainImageUrl, imageUrl, fallbackImageUrl, symbol, name, onClick, variant, className, onChildClick, isAdjacentToPreviousExpanded, isAdjacentToNextExpanded, }: TokenGroupProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -12,3 +12,4 @@ export declare const Closed: Story;
12
12
  export declare const Loading: Story;
13
13
  export declare const MarkedFavorite: Story;
14
14
  export declare const WithFakeChart: Story;
15
+ export declare const FallbackImage: Story;
@@ -16,3 +16,5 @@ export declare const LargeVariantLongTokenName: Story;
16
16
  export declare const CompactVariantWithItems: Story;
17
17
  export declare const CompactVariantLongTokenName: Story;
18
18
  export declare const MultipleCollapsibleGroups: Story;
19
+ export declare const FallbackImage: Story;
20
+ export declare const ItemsWithFallbackImage: Story;
package/dist/esm/index.js CHANGED
@@ -21390,7 +21390,7 @@ const mainImageSizeMap = {
21390
21390
  large: "xxlarge",
21391
21391
  small: "xlarge",
21392
21392
  };
21393
- function TokenGroup({ isSelected = false, tokenItems, priceChange, balance, balanceUsd, extraSpacing = true, chainImageUrl, imageUrl, symbol, name, onClick, variant = "large", className, onChildClick, isAdjacentToPreviousExpanded = false, isAdjacentToNextExpanded = false, }) {
21393
+ function TokenGroup({ isSelected = false, tokenItems, priceChange, balance, balanceUsd, extraSpacing = true, chainImageUrl, imageUrl, fallbackImageUrl, symbol, name, onClick, variant = "large", className, onChildClick, isAdjacentToPreviousExpanded = false, isAdjacentToNextExpanded = false, }) {
21394
21394
  var _a;
21395
21395
  const [isCollapsed, setIsCollapsed] = useState(true);
21396
21396
  const isCollapsible = tokenItems && tokenItems.length > 0;
@@ -21425,7 +21425,7 @@ function TokenGroup({ isSelected = false, tokenItems, priceChange, balance, bala
21425
21425
  : "tw-h-squid-xl tw-gap-squid-xxs"
21426
21426
  : isSmallVariant
21427
21427
  ? "tw-h-[50px] tw-gap-squid-s tw-py-squid-xxs"
21428
- : "tw-h-squid-xl tw-gap-squid-xxs"), children: [jsxs("div", { className: "tw-relative tw-min-w-fit", children: [jsx(Image$1, { src: imageUrl, size: isLargeVariant && !isCollapsed
21428
+ : "tw-h-squid-xl tw-gap-squid-xxs"), children: [jsxs("div", { className: "tw-relative tw-min-w-fit", children: [jsx(Image$1, { src: imageUrl, placeholderImageUrl: fallbackImageUrl, size: isLargeVariant && !isCollapsed
21429
21429
  ? "medium"
21430
21430
  : (_a = mainImageSizeMap[variant]) !== null && _a !== void 0 ? _a : "medium", rounded: isCompactVariant ? "xxs" : "full", style: {
21431
21431
  transition: `${ANIMATION_DURATIONS.GENERIC}ms ${ANIMATION_TIMINGS.GENERIC}`,
@@ -21742,6 +21742,7 @@ const DEFAULT_TIMEFRAME = "1D";
21742
21742
  const DefaultChart = ({ timeframe, }) => (jsx("div", { className: "tw-flex tw-h-full tw-w-full tw-items-center tw-justify-center", children: jsxs(BodyText, { size: "small", children: ["Chart (", timeframe, ")"] }) }));
21743
21743
  const TokenModalHeader = ({ token, chain, onLikeToken, onClose, isFavorite, }) => (jsxs("div", { className: "tw-flex tw-w-full tw-items-start tw-justify-between", children: [jsx("div", { className: "tw-flex tw-items-center tw-gap-squid-xs tw-pb-squid-xs", children: jsx(BadgeImage, { image: {
21744
21744
  src: token.image,
21745
+ placeholderImageUrl: token.fallbackImage,
21745
21746
  size: "xxlarge",
21746
21747
  rounded: "full",
21747
21748
  shadow: true,
@@ -21752,7 +21753,7 @@ const TokenModalHeader = ({ token, chain, onLikeToken, onClose, isFavorite, }) =
21752
21753
  border: "outline-lg",
21753
21754
  } }) }), jsxs("span", { className: "tw-absolute tw-right-squid-xs tw-top-squid-xs tw-flex tw-items-center tw-gap-squid-xxs", children: [jsx(IconButton, { className: "tw-group/token-detail-fav-icon tw-text-grey-300", onClick: onLikeToken, icon: isFavorite ? (jsxs(Fragment, { children: [jsx(FilledHeartIcon, { className: "tw-block group-hover/token-detail-fav-icon:tw-hidden" }), jsx(BrokenHeartIcon, { className: "tw-hidden group-hover/token-detail-fav-icon:tw-block" })] })) : (jsxs(Fragment, { children: [jsx(EmptyHeartIcon, { className: "tw-block group-hover/token-detail-fav-icon:tw-hidden" }), jsx(FilledHeartIcon, { className: "tw-hidden group-hover/token-detail-fav-icon:tw-block" })] })) }), jsx(IconButton, { className: "tw-text-grey-300", onClick: onClose, icon: jsx(CircleXFilledIcon, {}) })] })] }));
21754
21755
  const TokenInfo = ({ token, tokenPrice, priceChange, loading, }) => (jsxs("div", { children: [jsx(BodyText, { size: "large", loading: { isLoading: loading, width: "100px" }, children: tokenPrice.toLocaleString() }), jsxs("div", { className: "tw-flex tw-flex-row tw-items-center tw-justify-between", children: [jsx(BodyText, { size: "small", children: token.name }), jsx(PriceChange, { value: priceChange, variant: "large" })] })] }));
21755
- const BalanceInfo = ({ balance, balanceUSD, token, loading, }) => (jsxs("div", { className: "tw-flex tw-flex-col", children: [jsx(CaptionText, { className: "tw-text-grey-500", children: "Balance" }), jsxs("div", { className: "tw-flex tw-flex-row tw-justify-between", children: [jsxs("span", { className: "tw-flex tw-flex-row tw-items-center tw-gap-squid-xxs", children: [jsx("img", { src: token.image, alt: token.name, className: "tw-h-squid-m tw-w-squid-m tw-rounded-full" }), jsxs(BodyText, { size: "small", loading: { isLoading: loading, width: "80px" }, children: [balance, " ", token.symbol] })] }), jsxs(CaptionText, { className: "tw-text-grey-500", loading: { isLoading: loading, width: "60px" }, children: [jsx("span", { className: "tw-opacity-66", children: "$" }), balanceUSD] })] })] }));
21756
+ const BalanceInfo = ({ balance, balanceUSD, token, loading, }) => (jsxs("div", { className: "tw-flex tw-flex-col", children: [jsx(CaptionText, { className: "tw-text-grey-500", children: "Balance" }), jsxs("div", { className: "tw-flex tw-flex-row tw-justify-between", children: [jsxs("span", { className: "tw-flex tw-flex-row tw-items-center tw-gap-squid-xxs", children: [jsx(Image$1, { src: token.image, placeholderImageUrl: token.fallbackImage, alt: token.name, size: "medium", rounded: "full" }), jsxs(BodyText, { size: "small", loading: { isLoading: loading, width: "80px" }, children: [balance, " ", token.symbol] })] }), jsxs(CaptionText, { className: "tw-text-grey-500", loading: { isLoading: loading, width: "60px" }, children: [jsx("span", { className: "tw-opacity-66", children: "$" }), balanceUSD] })] })] }));
21756
21757
  const MarketDataItem = ({ label, value, showDollar, loading, }) => (jsxs("div", { className: "tw-flex tw-flex-col", children: [jsx(CaptionText, { className: "tw-text-grey-500", children: label }), jsxs(CaptionText, { loading: { isLoading: loading, width: "60px" }, children: [showDollar && jsx("span", { className: "tw-text-grey-500", children: "$" }), value] })] }));
21757
21758
  const TokenMarketData = ({ volume24h, marketCap, totalSupply, loading, }) => (jsxs("div", { className: "tw-mb-squid-xs tw-flex tw-h-full tw-w-full tw-flex-row tw-items-center tw-justify-between", children: [jsx(MarketDataItem, { label: "24h volume", value: volume24h, showDollar: true, loading: loading }), jsx(MarketDataItem, { label: "Market cap", value: marketCap, showDollar: true, loading: loading }), jsx(MarketDataItem, { label: "Total supply", value: totalSupply, loading: loading })] }));
21758
21759
  const FooterButton = (_a) => {
@@ -4,6 +4,7 @@ interface Token {
4
4
  name: string;
5
5
  symbol: string;
6
6
  image: string;
7
+ fallbackImage?: string;
7
8
  chainId: string;
8
9
  }
9
10
  interface Chain {
@@ -3,6 +3,7 @@ export type TokenGroupVariant = "compact" | "large" | "small";
3
3
  export interface TokenGroupProps<T> {
4
4
  isSelected?: boolean;
5
5
  imageUrl: string;
6
+ fallbackImageUrl?: string;
6
7
  symbol: string;
7
8
  name: string;
8
9
  chainImageUrl: string;
@@ -12,11 +13,10 @@ export interface TokenGroupProps<T> {
12
13
  tokenItems?: T[];
13
14
  extraSpacing?: boolean;
14
15
  onClick?: (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
15
- maxPreviewItems?: number;
16
16
  variant?: TokenGroupVariant;
17
17
  className?: string;
18
18
  onChildClick?: (tokenProps: T) => void;
19
19
  isAdjacentToPreviousExpanded?: boolean;
20
20
  isAdjacentToNextExpanded?: boolean;
21
21
  }
22
- export declare function TokenGroup<T extends TokenGroupProps<T>>({ isSelected, tokenItems, priceChange, balance, balanceUsd, extraSpacing, chainImageUrl, imageUrl, symbol, name, onClick, variant, className, onChildClick, isAdjacentToPreviousExpanded, isAdjacentToNextExpanded, }: TokenGroupProps<T>): import("react/jsx-runtime").JSX.Element;
22
+ export declare function TokenGroup<T extends TokenGroupProps<T>>({ isSelected, tokenItems, priceChange, balance, balanceUsd, extraSpacing, chainImageUrl, imageUrl, fallbackImageUrl, symbol, name, onClick, variant, className, onChildClick, isAdjacentToPreviousExpanded, isAdjacentToNextExpanded, }: TokenGroupProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -12,3 +12,4 @@ export declare const Closed: Story;
12
12
  export declare const Loading: Story;
13
13
  export declare const MarkedFavorite: Story;
14
14
  export declare const WithFakeChart: Story;
15
+ export declare const FallbackImage: Story;
@@ -16,3 +16,5 @@ export declare const LargeVariantLongTokenName: Story;
16
16
  export declare const CompactVariantWithItems: Story;
17
17
  export declare const CompactVariantLongTokenName: Story;
18
18
  export declare const MultipleCollapsibleGroups: Story;
19
+ export declare const FallbackImage: Story;
20
+ export declare const ItemsWithFallbackImage: Story;
package/dist/index.d.ts CHANGED
@@ -1329,6 +1329,7 @@ interface Token$2 {
1329
1329
  name: string;
1330
1330
  symbol: string;
1331
1331
  image: string;
1332
+ fallbackImage?: string;
1332
1333
  chainId: string;
1333
1334
  }
1334
1335
  interface Chain {
@@ -1893,6 +1894,7 @@ type TokenGroupVariant = "compact" | "large" | "small";
1893
1894
  interface TokenGroupProps<T> {
1894
1895
  isSelected?: boolean;
1895
1896
  imageUrl: string;
1897
+ fallbackImageUrl?: string;
1896
1898
  symbol: string;
1897
1899
  name: string;
1898
1900
  chainImageUrl: string;
@@ -1902,14 +1904,13 @@ interface TokenGroupProps<T> {
1902
1904
  tokenItems?: T[];
1903
1905
  extraSpacing?: boolean;
1904
1906
  onClick?: (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
1905
- maxPreviewItems?: number;
1906
1907
  variant?: TokenGroupVariant;
1907
1908
  className?: string;
1908
1909
  onChildClick?: (tokenProps: T) => void;
1909
1910
  isAdjacentToPreviousExpanded?: boolean;
1910
1911
  isAdjacentToNextExpanded?: boolean;
1911
1912
  }
1912
- declare function TokenGroup<T extends TokenGroupProps<T>>({ isSelected, tokenItems, priceChange, balance, balanceUsd, extraSpacing, chainImageUrl, imageUrl, symbol, name, onClick, variant, className, onChildClick, isAdjacentToPreviousExpanded, isAdjacentToNextExpanded, }: TokenGroupProps<T>): react_jsx_runtime.JSX.Element;
1913
+ declare function TokenGroup<T extends TokenGroupProps<T>>({ isSelected, tokenItems, priceChange, balance, balanceUsd, extraSpacing, chainImageUrl, imageUrl, fallbackImageUrl, symbol, name, onClick, variant, className, onChildClick, isAdjacentToPreviousExpanded, isAdjacentToNextExpanded, }: TokenGroupProps<T>): react_jsx_runtime.JSX.Element;
1913
1914
 
1914
1915
  interface TokenGroupsProps<T extends TokenGroupProps<T>> {
1915
1916
  groups: T[];
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git+https://github.com/0xsquid/squid-ui.git"
6
6
  },
7
7
  "description": "Squid's UI components",
8
- "version": "3.0.1",
8
+ "version": "3.0.2",
9
9
  "author": "",
10
10
  "license": "MIT",
11
11
  "resolutions": {