|
| 1 | +import type { Meta } from "@storybook/react-vite"; |
| 2 | +import { base } from "../chains/chain-definitions/base.js"; |
| 3 | +import { polygon } from "../chains/chain-definitions/polygon.js"; |
| 4 | +import { lightTheme } from "../react/core/design-system/index.js"; |
| 5 | +import { PayEmbed } from "../react/web/ui/PayEmbed.js"; |
| 6 | +import { prepareTransaction } from "../transaction/prepare-transaction.js"; |
| 7 | +import { toWei } from "../utils/units.js"; |
| 8 | +import { storyClient } from "./utils.js"; |
| 9 | + |
| 10 | +const meta = { |
| 11 | + parameters: { |
| 12 | + layout: "centered", |
| 13 | + }, |
| 14 | + tags: ["autodocs"], |
| 15 | + title: "Connect/PayEmbed", |
| 16 | +} satisfies Meta<typeof PayEmbed>; |
| 17 | + |
| 18 | +export function BasicUsage() { |
| 19 | + return <PayEmbed client={storyClient} />; |
| 20 | +} |
| 21 | + |
| 22 | +export function BasicUsageWithMetadata() { |
| 23 | + return ( |
| 24 | + <PayEmbed |
| 25 | + client={storyClient} |
| 26 | + payOptions={{ |
| 27 | + metadata: { |
| 28 | + name: "this is a title", |
| 29 | + // This is not shown in UI - TODO fix this |
| 30 | + description: "this is a description", |
| 31 | + }, |
| 32 | + }} |
| 33 | + /> |
| 34 | + ); |
| 35 | +} |
| 36 | + |
| 37 | +export function FundWallet() { |
| 38 | + return ( |
| 39 | + <PayEmbed |
| 40 | + client={storyClient} |
| 41 | + payOptions={{ |
| 42 | + mode: "fund_wallet", |
| 43 | + }} |
| 44 | + /> |
| 45 | + ); |
| 46 | +} |
| 47 | + |
| 48 | +export function FundWalletWithMetadata() { |
| 49 | + return ( |
| 50 | + <PayEmbed |
| 51 | + client={storyClient} |
| 52 | + payOptions={{ |
| 53 | + mode: "fund_wallet", |
| 54 | + metadata: { |
| 55 | + name: "this is a title", |
| 56 | + // This is not shown in UI - TODO fix this |
| 57 | + description: "this is a description", |
| 58 | + }, |
| 59 | + }} |
| 60 | + /> |
| 61 | + ); |
| 62 | +} |
| 63 | + |
| 64 | +export function FundWalletWithOptions() { |
| 65 | + return ( |
| 66 | + <PayEmbed |
| 67 | + client={storyClient} |
| 68 | + payOptions={{ |
| 69 | + mode: "fund_wallet", |
| 70 | + prefillBuy: { |
| 71 | + amount: "0.123", |
| 72 | + chain: polygon, |
| 73 | + }, |
| 74 | + }} |
| 75 | + /> |
| 76 | + ); |
| 77 | +} |
| 78 | + |
| 79 | +export function FundWalletERC20() { |
| 80 | + return ( |
| 81 | + <PayEmbed |
| 82 | + client={storyClient} |
| 83 | + payOptions={{ |
| 84 | + mode: "fund_wallet", |
| 85 | + prefillBuy: { |
| 86 | + amount: "0.123", |
| 87 | + chain: base, |
| 88 | + token: { |
| 89 | + address: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", |
| 90 | + name: "USDC", |
| 91 | + // This icon is not being used - TODO fix this, either remove this prop or use it |
| 92 | + icon: "https://picsum.photos/200/200", |
| 93 | + }, |
| 94 | + }, |
| 95 | + }} |
| 96 | + /> |
| 97 | + ); |
| 98 | +} |
| 99 | + |
| 100 | +export function DirectPayment() { |
| 101 | + return ( |
| 102 | + <PayEmbed |
| 103 | + client={storyClient} |
| 104 | + payOptions={{ |
| 105 | + mode: "direct_payment", |
| 106 | + paymentInfo: { |
| 107 | + amount: "0.123", |
| 108 | + chain: polygon, |
| 109 | + sellerAddress: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425", |
| 110 | + }, |
| 111 | + }} |
| 112 | + /> |
| 113 | + ); |
| 114 | +} |
| 115 | + |
| 116 | +export function DirectPaymentERC20() { |
| 117 | + return ( |
| 118 | + <PayEmbed |
| 119 | + client={storyClient} |
| 120 | + payOptions={{ |
| 121 | + mode: "direct_payment", |
| 122 | + paymentInfo: { |
| 123 | + amount: "0.123", |
| 124 | + chain: base, |
| 125 | + sellerAddress: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425", |
| 126 | + token: { |
| 127 | + address: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", |
| 128 | + name: "USDC", |
| 129 | + // This icon is not being used - TODO fix this, either remove this prop or use it |
| 130 | + icon: "https://coin-images.coingecko.com/coins/images/6319/large/usdc.png", |
| 131 | + }, |
| 132 | + }, |
| 133 | + }} |
| 134 | + /> |
| 135 | + ); |
| 136 | +} |
| 137 | + |
| 138 | +export function DirectPaymentWithMetadata() { |
| 139 | + return ( |
| 140 | + <PayEmbed |
| 141 | + client={storyClient} |
| 142 | + payOptions={{ |
| 143 | + mode: "direct_payment", |
| 144 | + paymentInfo: { |
| 145 | + amount: "0.123", |
| 146 | + chain: polygon, |
| 147 | + sellerAddress: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425", |
| 148 | + }, |
| 149 | + metadata: { |
| 150 | + name: "this is a title", |
| 151 | + description: "this is a description", |
| 152 | + }, |
| 153 | + }} |
| 154 | + /> |
| 155 | + ); |
| 156 | +} |
| 157 | + |
| 158 | +export function Transaction() { |
| 159 | + return ( |
| 160 | + <PayEmbed |
| 161 | + client={storyClient} |
| 162 | + payOptions={{ |
| 163 | + mode: "transaction", |
| 164 | + transaction: prepareTransaction({ |
| 165 | + to: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425", |
| 166 | + chain: polygon, |
| 167 | + client: storyClient, |
| 168 | + value: toWei("0.123"), |
| 169 | + }), |
| 170 | + }} |
| 171 | + /> |
| 172 | + ); |
| 173 | +} |
| 174 | + |
| 175 | +export function TransactionWithMetadata() { |
| 176 | + return ( |
| 177 | + <PayEmbed |
| 178 | + client={storyClient} |
| 179 | + payOptions={{ |
| 180 | + metadata: { |
| 181 | + name: "this is a title", |
| 182 | + description: "this is a description", |
| 183 | + }, |
| 184 | + mode: "transaction", |
| 185 | + transaction: prepareTransaction({ |
| 186 | + to: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425", |
| 187 | + chain: polygon, |
| 188 | + client: storyClient, |
| 189 | + value: toWei("0.123"), |
| 190 | + }), |
| 191 | + }} |
| 192 | + /> |
| 193 | + ); |
| 194 | +} |
| 195 | + |
| 196 | +export function LightMode() { |
| 197 | + return <PayEmbed client={storyClient} theme="light" />; |
| 198 | +} |
| 199 | + |
| 200 | +export function CustomLightTheme() { |
| 201 | + return ( |
| 202 | + <PayEmbed |
| 203 | + client={storyClient} |
| 204 | + theme={lightTheme({ |
| 205 | + colors: { |
| 206 | + modalBg: "#FFFFF0", |
| 207 | + tertiaryBg: "#DBE4C9", |
| 208 | + borderColor: "#8AA624", |
| 209 | + secondaryText: "#3E3F29", |
| 210 | + accentText: "#E43636", |
| 211 | + }, |
| 212 | + })} |
| 213 | + /> |
| 214 | + ); |
| 215 | +} |
| 216 | + |
| 217 | +export default meta; |
0 commit comments