|
| 1 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 2 | +import { mobileViewport } from "../../../../../../stories/utils"; |
| 3 | +import { BluePrintPlayground } from "./BluePrintPlayground"; |
| 4 | +import type { BluePrintMetadata } from "./utils"; |
| 5 | + |
| 6 | +const meta = { |
| 7 | + title: "Insight/BluePrintPlayground", |
| 8 | + component: Story, |
| 9 | + parameters: { |
| 10 | + nextjs: { |
| 11 | + appDirectory: true, |
| 12 | + }, |
| 13 | + }, |
| 14 | +} satisfies Meta<typeof Story>; |
| 15 | + |
| 16 | +export default meta; |
| 17 | +type Story = StoryObj<typeof meta>; |
| 18 | + |
| 19 | +export const Desktop: Story = { |
| 20 | + args: { |
| 21 | + metadata: getBlueprintMetadata().transactionsMetadata, |
| 22 | + }, |
| 23 | +}; |
| 24 | + |
| 25 | +export const Mobile: Story = { |
| 26 | + args: { |
| 27 | + metadata: getBlueprintMetadata().transactionsMetadata, |
| 28 | + }, |
| 29 | + parameters: { |
| 30 | + viewport: mobileViewport("iphone14"), |
| 31 | + }, |
| 32 | +}; |
| 33 | + |
| 34 | +function Story() { |
| 35 | + return ( |
| 36 | + <div className="flex flex-col gap-10"> |
| 37 | + <Variant metadata={getBlueprintMetadata().transactionsMetadata} /> |
| 38 | + <Variant metadata={getBlueprintMetadata().eventsMetadata} /> |
| 39 | + <Variant metadata={getBlueprintMetadata().tokensMetadata} /> |
| 40 | + </div> |
| 41 | + ); |
| 42 | +} |
| 43 | + |
| 44 | +function Variant(props: { |
| 45 | + metadata: BluePrintMetadata; |
| 46 | +}) { |
| 47 | + return ( |
| 48 | + <div className="flex min-h-[800px] flex-col"> |
| 49 | + <BluePrintPlayground metadata={props.metadata} backLink="/" /> |
| 50 | + </div> |
| 51 | + ); |
| 52 | +} |
| 53 | + |
| 54 | +function getBlueprintMetadata() { |
| 55 | + const transactionsMetadata: BluePrintMetadata = { |
| 56 | + domain: "https://{chainId}.insight.thirdweb.com", |
| 57 | + path: "/transactions", |
| 58 | + parameters: [ |
| 59 | + { |
| 60 | + description: "Chain ID", |
| 61 | + name: "chainId", |
| 62 | + in: "path", |
| 63 | + required: true, |
| 64 | + }, |
| 65 | + { |
| 66 | + description: "Filter parameters", |
| 67 | + name: "filter", |
| 68 | + in: "query", |
| 69 | + }, |
| 70 | + { |
| 71 | + description: "Field to group results by", |
| 72 | + name: "group_by", |
| 73 | + in: "query", |
| 74 | + }, |
| 75 | + { |
| 76 | + description: "Field to sort results by", |
| 77 | + name: "sort_by", |
| 78 | + in: "query", |
| 79 | + }, |
| 80 | + { |
| 81 | + description: "Sort order (asc or desc)", |
| 82 | + name: "sort_order", |
| 83 | + in: "query", |
| 84 | + }, |
| 85 | + { |
| 86 | + description: "Page number for pagination", |
| 87 | + name: "page", |
| 88 | + in: "query", |
| 89 | + }, |
| 90 | + { |
| 91 | + description: "Number of items per page", |
| 92 | + name: "limit", |
| 93 | + in: "query", |
| 94 | + }, |
| 95 | + { |
| 96 | + description: "List of aggregate functions to apply", |
| 97 | + name: "aggregate", |
| 98 | + in: "query", |
| 99 | + }, |
| 100 | + ], |
| 101 | + title: "Transactions", |
| 102 | + description: "Retrieve all transactions across all contracts", |
| 103 | + }; |
| 104 | + |
| 105 | + const eventsMetadata: BluePrintMetadata = { |
| 106 | + domain: "https://{chainId}.insight.thirdweb.com", |
| 107 | + path: "/events", |
| 108 | + parameters: [ |
| 109 | + { |
| 110 | + description: "Chain ID", |
| 111 | + name: "chainId", |
| 112 | + in: "path", |
| 113 | + required: true, |
| 114 | + }, |
| 115 | + { |
| 116 | + description: "Filter parameters", |
| 117 | + name: "filter", |
| 118 | + in: "query", |
| 119 | + }, |
| 120 | + { |
| 121 | + description: "Field to group results by", |
| 122 | + name: "group_by", |
| 123 | + in: "query", |
| 124 | + }, |
| 125 | + { |
| 126 | + description: "Field to sort results by", |
| 127 | + name: "sort_by", |
| 128 | + in: "query", |
| 129 | + }, |
| 130 | + { |
| 131 | + description: "Sort order (asc or desc)", |
| 132 | + name: "sort_order", |
| 133 | + in: "query", |
| 134 | + }, |
| 135 | + { |
| 136 | + description: "Page number for pagination", |
| 137 | + name: "page", |
| 138 | + in: "query", |
| 139 | + }, |
| 140 | + { |
| 141 | + description: "Number of items per page", |
| 142 | + name: "limit", |
| 143 | + in: "query", |
| 144 | + }, |
| 145 | + { |
| 146 | + description: "List of aggregate functions to apply", |
| 147 | + name: "aggregate", |
| 148 | + in: "query", |
| 149 | + }, |
| 150 | + ], |
| 151 | + title: "Events", |
| 152 | + description: "Retrieve all logs across all contracts", |
| 153 | + }; |
| 154 | + |
| 155 | + const tokensMetadata: BluePrintMetadata = { |
| 156 | + domain: "https://{chainId}.insight.thirdweb.com", |
| 157 | + path: "/tokens/erc20/:ownerAddress", |
| 158 | + parameters: [ |
| 159 | + { |
| 160 | + name: "chainId", |
| 161 | + in: "path", |
| 162 | + required: true, |
| 163 | + description: "Chain ID", |
| 164 | + }, |
| 165 | + { |
| 166 | + required: true, |
| 167 | + name: "ownerAddress", |
| 168 | + in: "path", |
| 169 | + }, |
| 170 | + { |
| 171 | + required: false, |
| 172 | + name: "clientId", |
| 173 | + in: "path", |
| 174 | + }, |
| 175 | + ], |
| 176 | + title: "Tokens", |
| 177 | + description: "Retrieve tokens balances for a given owner address", |
| 178 | + }; |
| 179 | + |
| 180 | + return { |
| 181 | + transactionsMetadata, |
| 182 | + eventsMetadata, |
| 183 | + tokensMetadata, |
| 184 | + }; |
| 185 | +} |
0 commit comments