decentraland-ui2 0.40.0 → 0.40.1-19236027142.commit-389b58d

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.
Files changed (32) hide show
  1. package/dist/components/CreditsToggle/CreditsToggle.d.ts +4 -0
  2. package/dist/components/CreditsToggle/CreditsToggle.js +42 -0
  3. package/dist/components/CreditsToggle/CreditsToggle.js.map +1 -0
  4. package/dist/components/CreditsToggle/CreditsToggle.stories.d.ts +12 -0
  5. package/dist/components/CreditsToggle/CreditsToggle.stories.js +109 -0
  6. package/dist/components/CreditsToggle/CreditsToggle.stories.js.map +1 -0
  7. package/dist/components/CreditsToggle/CreditsToggle.styled.d.ts +52 -0
  8. package/dist/components/CreditsToggle/CreditsToggle.styled.js +117 -0
  9. package/dist/components/CreditsToggle/CreditsToggle.styled.js.map +1 -0
  10. package/dist/components/CreditsToggle/CreditsToggle.types.d.ts +42 -0
  11. package/dist/components/CreditsToggle/CreditsToggle.types.js +2 -0
  12. package/dist/components/CreditsToggle/CreditsToggle.types.js.map +1 -0
  13. package/dist/components/CreditsToggle/index.d.ts +2 -0
  14. package/dist/components/CreditsToggle/index.js +2 -0
  15. package/dist/components/CreditsToggle/index.js.map +1 -0
  16. package/dist/components/CreditsToggle/toggleAnimation.json +3356 -0
  17. package/dist/components/WearablePreview/AnimationControls/AnimationControls.d.ts +2 -2
  18. package/dist/components/WearablePreview/AnimationControls/AnimationControls.js +13 -6
  19. package/dist/components/WearablePreview/AnimationControls/AnimationControls.js.map +1 -1
  20. package/dist/components/WearablePreview/AnimationControls/AnimationControls.types.d.ts +5 -3
  21. package/dist/components/WearablePreview/ZoomControls/ZoomControls.js +1 -1
  22. package/dist/components/WearablePreview/ZoomControls/ZoomControls.js.map +1 -1
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/utils/format.d.ts +6 -0
  27. package/dist/utils/format.js +11 -0
  28. package/dist/utils/format.js.map +1 -0
  29. package/dist/utils/index.d.ts +2 -0
  30. package/dist/utils/index.js +3 -0
  31. package/dist/utils/index.js.map +1 -0
  32. package/package.json +3 -2
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { CreditsToggleProps } from "./CreditsToggle.types";
3
+ declare const CreditsToggle: React.FC<CreditsToggleProps>;
4
+ export { CreditsToggle };
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useMemo } from "react";
3
+ import Lottie from "lottie-react";
4
+ import toggleAnimation from "./toggleAnimation.json";
5
+ import { formatEther } from "../../utils/format";
6
+ import { CreditsIcon } from "../Icon/CreditsIcon";
7
+ import { AnimationContainer, Container, LearnMoreButton, LeftSection, PopupContainer, StyledAmount, StyledNumber, StyledSwitch, StyledText, } from "./CreditsToggle.styled";
8
+ const CreditsToggle = ({ totalCredits, assetPrice, useCredits, onToggle, className = "", showLearnMore = false, learnMoreUrl, label, showTooltip = true, tooltipContent, }) => {
9
+ const creditsToUseInEth = useMemo(() => {
10
+ if (!totalCredits) {
11
+ return "0";
12
+ }
13
+ const inEth = formatEther(totalCredits.toString());
14
+ const assetPriceInEth = assetPrice
15
+ ? formatEther(assetPrice.toString())
16
+ : "0";
17
+ return assetPrice
18
+ ? Math.min(Number(assetPriceInEth), Number(inEth)).toFixed(2)
19
+ : Number(inEth).toFixed(2);
20
+ }, [totalCredits, assetPrice]);
21
+ const handleToggleCredits = useCallback(() => {
22
+ onToggle(!useCredits);
23
+ }, [useCredits, onToggle]);
24
+ const handleLearnMore = useCallback(() => {
25
+ if (learnMoreUrl) {
26
+ window.open(learnMoreUrl, "_blank", "noopener noreferrer");
27
+ }
28
+ }, [learnMoreUrl]);
29
+ const hasCredits = totalCredits && BigInt(totalCredits) > BigInt(0);
30
+ // If user has no credits and showLearnMore is false, don't render anything
31
+ if (!hasCredits && !showLearnMore) {
32
+ return null;
33
+ }
34
+ // Show the GET CREDITS button
35
+ if (!hasCredits && showLearnMore) {
36
+ return (_jsxs(Container, { showLearnMore: true, className: className, children: [_jsxs(LeftSection, { children: [_jsx(CreditsIcon, { sx: { fontSize: 18 } }), _jsx(StyledText, { children: label || "Get with Credits" })] }), _jsx(StyledAmount, { children: _jsx(LearnMoreButton, { variant: "outlined", onClick: handleLearnMore, children: "Learn More" }) })] }));
37
+ }
38
+ return (_jsxs(Container, { active: useCredits, className: className, children: [_jsxs(LeftSection, { active: useCredits, children: [_jsx(AnimationContainer, { show: useCredits, children: useCredits && (_jsx(Lottie, { animationData: toggleAnimation, loop: false })) }), _jsx(StyledSwitch, { checked: useCredits, onChange: handleToggleCredits }), _jsx(StyledText, { active: useCredits, children: label || "Use Credits" })] }), _jsx(StyledAmount, { active: useCredits, children: showTooltip ? (_jsxs(PopupContainer, { title: tooltipContent || "Credits value", children: [_jsx(CreditsIcon, { sx: { fontSize: 18, marginLeft: 1.5 } }), _jsx(StyledNumber, { children: creditsToUseInEth })] })) : (_jsxs(PopupContainer, { children: [_jsx(CreditsIcon, { sx: { fontSize: 18, marginLeft: 1.5 } }), _jsx(StyledNumber, { children: creditsToUseInEth })] })) })] }));
39
+ };
40
+ CreditsToggle.displayName = "CreditsToggle";
41
+ export { CreditsToggle };
42
+ //# sourceMappingURL=CreditsToggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreditsToggle.js","sourceRoot":"","sources":["../../../src/components/CreditsToggle/CreditsToggle.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,eAAe,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,WAAW,EACX,cAAc,EACd,YA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E,GAAG,EAAE,GAAI,EACtD,KAAC,YAAY,cAAE,iBAAiB,GAAgB,IACjC,CAClB,CAAC,CAAC,CAAC,CACF,MAAC,cAAc,eACb,KAAC,WAAW,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,GAAI,EACtD,KAAC,YAAY,cAAE,iBAAiB,GAAgB,IACjC,CAClB,GACY,IACL,CACb,CAAA;AACH,CAAC,CAAA;AAED,aAAa,CAAC,WAAW,GAAG,eAAe,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { CreditsToggle } from "./CreditsToggle";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ declare const meta: Meta<typeof CreditsToggle>;
4
+ type Story = StoryObj<typeof CreditsToggle>;
5
+ declare const WithCredits: Story;
6
+ declare const Active: Story;
7
+ declare const InsufficientCredits: Story;
8
+ declare const NoCreditsWithLearnMore: Story;
9
+ declare const NoCreditsHidden: Story;
10
+ declare const CustomLabel: Story;
11
+ export { WithCredits, Active, InsufficientCredits, NoCreditsWithLearnMore, NoCreditsHidden, CustomLabel, };
12
+ export default meta;
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { CreditsToggle } from "./CreditsToggle";
4
+ // Helper to convert ETH to Wei (avoiding ethers dependency)
5
+ const parseEther = (value) => {
6
+ return (BigInt(value) * BigInt("1000000000000000000")).toString();
7
+ };
8
+ const meta = {
9
+ title: "Decentraland UI/CreditsToggle",
10
+ component: CreditsToggle,
11
+ tags: ["autodocs"],
12
+ argTypes: {
13
+ totalCredits: {
14
+ control: "text",
15
+ description: "Total credits available in wei",
16
+ },
17
+ assetPrice: {
18
+ control: "text",
19
+ description: "Price of the asset/item in wei",
20
+ },
21
+ useCredits: {
22
+ control: "boolean",
23
+ description: "Whether credits are currently being used",
24
+ },
25
+ showLearnMore: {
26
+ control: "boolean",
27
+ description: 'Show "Learn More" button instead of credits amount when user has no credits',
28
+ },
29
+ label: {
30
+ control: "text",
31
+ description: "Custom text for the toggle label",
32
+ },
33
+ showTooltip: {
34
+ control: "boolean",
35
+ description: "Show tooltip with credit value explanation",
36
+ },
37
+ },
38
+ };
39
+ // Interactive wrapper to handle state
40
+ const InteractiveCreditsToggle = (args) => {
41
+ const [useCredits, setUseCredits] = useState(args.useCredits);
42
+ return (_jsx("div", { style: { maxWidth: "600px", padding: "20px" }, children: _jsx(CreditsToggle, { ...args, useCredits: useCredits, onToggle: setUseCredits }) }));
43
+ };
44
+ const WithCredits = {
45
+ render: (args) => _jsx(InteractiveCreditsToggle, { ...args }),
46
+ args: {
47
+ totalCredits: parseEther("100"),
48
+ assetPrice: parseEther("50"),
49
+ useCredits: false,
50
+ label: "Use Credits",
51
+ showTooltip: true,
52
+ tooltipContent: "Credits value",
53
+ },
54
+ };
55
+ const Active = {
56
+ render: (args) => _jsx(InteractiveCreditsToggle, { ...args }),
57
+ args: {
58
+ totalCredits: parseEther("100"),
59
+ assetPrice: parseEther("50"),
60
+ useCredits: true,
61
+ label: "Use Credits",
62
+ showTooltip: true,
63
+ },
64
+ };
65
+ const InsufficientCredits = {
66
+ render: (args) => _jsx(InteractiveCreditsToggle, { ...args }),
67
+ args: {
68
+ totalCredits: parseEther("10"),
69
+ assetPrice: parseEther("50"),
70
+ useCredits: false,
71
+ label: "Use Credits",
72
+ showTooltip: true,
73
+ },
74
+ };
75
+ const NoCreditsWithLearnMore = {
76
+ render: (args) => _jsx(InteractiveCreditsToggle, { ...args }),
77
+ args: {
78
+ totalCredits: "0",
79
+ assetPrice: parseEther("50"),
80
+ useCredits: false,
81
+ showLearnMore: true,
82
+ label: "Get with Credits",
83
+ learnMoreUrl: "https://decentraland.org/blog/announcements/marketplace-credits",
84
+ },
85
+ };
86
+ const NoCreditsHidden = {
87
+ render: (args) => _jsx(InteractiveCreditsToggle, { ...args }),
88
+ args: {
89
+ totalCredits: "0",
90
+ assetPrice: parseEther("50"),
91
+ useCredits: false,
92
+ showLearnMore: false,
93
+ },
94
+ };
95
+ const CustomLabel = {
96
+ render: (args) => _jsx(InteractiveCreditsToggle, { ...args }),
97
+ args: {
98
+ totalCredits: parseEther("75"),
99
+ assetPrice: parseEther("50"),
100
+ useCredits: false,
101
+ label: "Pagar con Créditos",
102
+ showTooltip: true,
103
+ tooltipContent: "Valor de los créditos",
104
+ },
105
+ };
106
+ export { WithCredits, Active, InsufficientCredits, NoCreditsWithLearnMore, NoCreditsHidden, CustomLabel, };
107
+ // eslint-disable-next-line import/no-default-export
108
+ export default meta;
109
+ //# sourceMappingURL=CreditsToggle.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreditsToggle.stories.js","sourceRoot":"","sources":["../../../src/components/CreditsToggle/CreditsToggle.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,4DAA4D;AAC5D,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE;IAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;AACnE,CAAC,CAAA;AAED,MAAM,IAAI,GAA+B;IACvC,KAAK,EAAE,+BAA+B;IACtC,SAAS,EAAE,aAAa;IACxB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,YAAY,EAAE;YACZ,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,gCAAgC;SAC9C;QACD,UAAU,EAAE;YACV,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,gCAAgC;SAC9C;QACD,UAAU,EAAE;YACV,OAAO,EAAE,SAAS;YAClB,WAAW,EAAE,0CAA0C;SACxD;QACD,aAAa,EAAE;YACb,OAAO,EAAE,SAAS;YAClB,WAAW,EACT,6EA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IAAI,CAAA"}
@@ -0,0 +1,52 @@
1
+ declare const Container: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
2
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
3
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
4
+ theme?: import("@emotion/react").Theme;
5
+ } & {
6
+ active?: boolean;
7
+ showLearnMore?: boolean;
8
+ }, {}, {}>;
9
+ declare const LeftSection: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
10
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
11
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
12
+ theme?: import("@emotion/react").Theme;
13
+ } & {
14
+ active?: boolean;
15
+ }, {}, {}>;
16
+ declare const StyledText: import("@emotion/styled").StyledComponent<{
17
+ theme?: import("@emotion/react").Theme;
18
+ as?: import("react").ElementType;
19
+ } & {
20
+ active?: boolean;
21
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
22
+ declare const StyledAmount: import("@emotion/styled").StyledComponent<{
23
+ theme?: import("@emotion/react").Theme;
24
+ as?: import("react").ElementType;
25
+ } & {
26
+ active?: boolean;
27
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
28
+ declare const StyledNumber: import("@emotion/styled").StyledComponent<{
29
+ theme?: import("@emotion/react").Theme;
30
+ as?: import("react").ElementType;
31
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
32
+ declare const PopupContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
33
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
34
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
35
+ theme?: import("@emotion/react").Theme;
36
+ }, {}, {}>;
37
+ declare const AnimationContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
38
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
39
+ }, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & {
40
+ theme?: import("@emotion/react").Theme;
41
+ } & {
42
+ show: boolean;
43
+ }, {}, {}>;
44
+ declare const LearnMoreButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
45
+ ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
46
+ }, "disabled" | "color" | "className" | "style" | "classes" | "children" | "sx" | "variant" | "tabIndex" | "disableElevation" | "fullWidth" | "startIcon" | "endIcon" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "href" | "size"> & {
47
+ theme?: import("@emotion/react").Theme;
48
+ }, {}, {}>;
49
+ declare const StyledSwitch: import("@emotion/styled").StyledComponent<import("@mui/material").SwitchProps & {
50
+ theme?: import("@emotion/react").Theme;
51
+ }, {}, {}>;
52
+ export { AnimationContainer, Container, LeftSection, LearnMoreButton, PopupContainer, StyledAmount, StyledNumber, StyledSwitch, StyledText, };
@@ -0,0 +1,117 @@
1
+ import { keyframes } from "@emotion/react";
2
+ import styled from "@emotion/styled";
3
+ import { Box, Button as MuiButton, Switch as MuiSwitch } from "@mui/material";
4
+ // TODO: Add credits color (#a0abff) to theme palette
5
+ const CREDITS_COLOR = "#a0abff";
6
+ const CREDITS_COLOR_TRANSPARENT = "rgba(160, 171, 255, 0.15)";
7
+ const moveGradient = keyframes({
8
+ "0%": {
9
+ backgroundPosition: "300% 0%",
10
+ },
11
+ "100%": {
12
+ backgroundPosition: "0% 0%",
13
+ },
14
+ });
15
+ const Container = styled(Box)(({ theme, active, showLearnMore }) => ({
16
+ display: "flex",
17
+ justifyContent: "space-between",
18
+ alignItems: "center",
19
+ width: "100%",
20
+ padding: `${theme.spacing(0.5)} ${theme.spacing(2.25)}`,
21
+ paddingLeft: theme.spacing(0.5),
22
+ borderRadius: theme.spacing(1),
23
+ border: "1px solid",
24
+ borderColor: active ? CREDITS_COLOR : CREDITS_COLOR_TRANSPARENT,
25
+ transition: "all 0.2s ease",
26
+ marginBottom: theme.spacing(2),
27
+ position: "relative",
28
+ gap: showLearnMore ? theme.spacing(1.5) : 0,
29
+ ...(active
30
+ ? {}
31
+ : {
32
+ "&::before": {
33
+ content: '""',
34
+ position: "absolute",
35
+ inset: "-2px",
36
+ borderRadius: theme.spacing(1.25),
37
+ background: `linear-gradient(90deg, transparent, transparent, ${CREDITS_COLOR}, ${CREDITS_COLOR}, transparent, transparent)`,
38
+ backgroundSize: "300% 100%",
39
+ animation: `${moveGradient} 6s linear infinite`,
40
+ WebkitMask: `
41
+ linear-gradient(#fff 0 0) content-box,
42
+ linear-gradient(#fff 0 0)
43
+ `,
44
+ WebkitMaskComposite: "xor",
45
+ mask: `
46
+ linear-gradient(#fff 0 0) content-box,
47
+ linear-gradient(#fff 0 0)
48
+ `,
49
+ maskComposite: "exclude",
50
+ padding: "2px",
51
+ pointerEvents: "none",
52
+ zIndex: 1,
53
+ },
54
+ }),
55
+ }));
56
+ const LeftSection = styled(Box)(({ theme, active }) => ({
57
+ position: "relative",
58
+ display: "flex",
59
+ alignItems: "center",
60
+ gap: theme.spacing(1.5),
61
+ paddingLeft: theme.spacing(1.5),
62
+ "& .MuiSwitch-root.MuiSwitch-sizeMedium": {
63
+ marginLeft: theme.spacing(-1.5),
64
+ },
65
+ ...(active && {
66
+ "& .MuiSwitch-thumb": {
67
+ backgroundColor: `${CREDITS_COLOR} !important`,
68
+ },
69
+ "& .Mui-checked + .MuiSwitch-track": {
70
+ backgroundColor: `${CREDITS_COLOR} !important`,
71
+ },
72
+ }),
73
+ }));
74
+ const StyledText = styled("span")(({ theme, active }) => ({
75
+ fontSize: "15px",
76
+ fontWeight: 500,
77
+ color: active ? CREDITS_COLOR : theme.palette.text.primary,
78
+ transition: "color 0.2s ease",
79
+ }));
80
+ const StyledAmount = styled("span")(({ theme, active }) => ({
81
+ fontSize: "15px",
82
+ color: active ? CREDITS_COLOR : theme.palette.text.primary,
83
+ transition: "color 0.2s ease",
84
+ }));
85
+ const StyledNumber = styled("span")({
86
+ fontWeight: 600,
87
+ color: CREDITS_COLOR,
88
+ cursor: "pointer",
89
+ transition: "color 0.2s ease",
90
+ });
91
+ const PopupContainer = styled(Box)(({ theme }) => ({
92
+ display: "flex",
93
+ alignItems: "center",
94
+ gap: theme.spacing(0.5),
95
+ }));
96
+ const AnimationContainer = styled(Box)(({ show }) => ({
97
+ position: "absolute",
98
+ left: "-175px",
99
+ bottom: "-200px",
100
+ width: "500px",
101
+ height: "500px",
102
+ opacity: show ? 1 : 0,
103
+ pointerEvents: "none",
104
+ }));
105
+ const LearnMoreButton = styled(MuiButton)(({ theme }) => ({
106
+ color: theme.palette.primary.main,
107
+ textTransform: "uppercase",
108
+ }));
109
+ const StyledSwitch = styled(MuiSwitch)({
110
+ "& .MuiSwitch-switchBase": {
111
+ "&:hover": {
112
+ backgroundColor: "transparent",
113
+ },
114
+ },
115
+ });
116
+ export { AnimationContainer, Container, LeftSection, LearnMoreButton, PopupContainer, StyledAmount, StyledNumber, StyledSwitch, StyledText, };
117
+ //# sourceMappingURL=CreditsToggle.styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreditsToggle.styled.js","sourceRoot":"","sources":["../../../src/components/CreditsToggle/CreditsToggle.styled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,eAAe,CAAA;AAE7E,qDAAqD;AACrD,MAAM,aAAa,GAAG,SAAS,CAAA;AAC/B,MAAM,yBAAyB,GAAG,2BAA2B,CAAA;AAE7D,MAAM,YAAY,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE;QACJ,kBAAkB,EAAE,SAAS;KAC9B;IACD,MAAM,EAAE;QACN,kBAAkB,EAAE,OAAO;KAC5B;CACF,CAAC,CAAA;AAEF,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAC3B,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;IACrC,OAAO,EAAE,MAAM;IACf,cAAc,EAAE,eAAe;IAC/B,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;IACvD,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;IAC/B,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9B,MAAM,EA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AG,MAAM,CAAC,GAAG,CAAC,CAAoB,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IACvE,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrB,aAAa,EAAE,MAAM;CACtB,CAAC,CAAC,CAAA;AAEH,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACxD,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;IACjC,aAAa,EAAE,WAAW;CAC3B,CAAC,CAAC,CAAA;AAEH,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IACrC,yBAAyB,EAAE;QACzB,SAAS,EAAE;YACT,eAAe,EAAE,aAAa;SAC/B;KACF;CACF,CAAC,CAAA;AAEF,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,eAAe,EACf,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,UAAU,GACX,CAAA"}
@@ -0,0 +1,42 @@
1
+ export type CreditsToggleProps = {
2
+ /**
3
+ * Total credits available in wei
4
+ */
5
+ totalCredits: string | number;
6
+ /**
7
+ * Price of the asset/item in wei
8
+ */
9
+ assetPrice: string;
10
+ /**
11
+ * Whether credits are currently being used
12
+ */
13
+ useCredits: boolean;
14
+ /**
15
+ * Callback when toggle changes
16
+ */
17
+ onToggle: (useCredits: boolean) => void;
18
+ /**
19
+ * Optional className for the container
20
+ */
21
+ className?: string;
22
+ /**
23
+ * Optional: Show "Learn More" button instead of credits amount when user has no credits
24
+ */
25
+ showLearnMore?: boolean;
26
+ /**
27
+ * Optional: URL for the "Learn More" button
28
+ */
29
+ learnMoreUrl?: string;
30
+ /**
31
+ * Optional: Custom text for the toggle label
32
+ */
33
+ label?: string;
34
+ /**
35
+ * Optional: Show tooltip with credit value explanation
36
+ */
37
+ showTooltip?: boolean;
38
+ /**
39
+ * Optional: Tooltip content
40
+ */
41
+ tooltipContent?: string;
42
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=CreditsToggle.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreditsToggle.types.js","sourceRoot":"","sources":["../../../src/components/CreditsToggle/CreditsToggle.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { CreditsToggle } from "./CreditsToggle";
2
+ export type { CreditsToggleProps } from "./CreditsToggle.types";
@@ -0,0 +1,2 @@
1
+ export { CreditsToggle } from "./CreditsToggle";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CreditsToggle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}