|
| 1 | +import { h } from '@stencil/core'; |
| 2 | +import type { Meta, StoryObj } from '@stencil/storybook-plugin'; |
| 3 | +import type { IAddressTableData } from 'types/address-table.types'; |
| 4 | + |
| 5 | +// prettier-ignore |
| 6 | +const styles = { |
| 7 | + addressTableStoriesWrapper: 'address-table-stories-wrapper mvx:flex mvx:justify-center mvx:items-stretch mvx:h-[600px] mvx:bg-neutral-900', |
| 8 | + addressTableStoriesContainer: 'address-table-stories-container mvx:w-full mvx:max-w-3xl mvx:p-6', |
| 9 | +} satisfies Record<string, string>; |
| 10 | + |
| 11 | +const exampleAccountScreenData: IAddressTableData = { |
| 12 | + startIndex: 0, |
| 13 | + addressesPerPage: 10, |
| 14 | + isLoading: false, |
| 15 | + accounts: [ |
| 16 | + { |
| 17 | + address: 'erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th', |
| 18 | + balance: '1.2345 EGLD', |
| 19 | + usdValue: '$250.12', |
| 20 | + index: 0, |
| 21 | + shard: 0, |
| 22 | + }, |
| 23 | + { |
| 24 | + address: 'erd1qqqqqqqqqqqqqpgqzqvm5ywqqf524efwrhr039tjs29w0qltkklsa05pk7', |
| 25 | + balance: '0.5000 EGLD', |
| 26 | + usdValue: '$101.25', |
| 27 | + index: 1, |
| 28 | + shard: 1, |
| 29 | + }, |
| 30 | + { |
| 31 | + address: 'erd1qj8g8j9h0x0k9p7s0q3w4e5r6t7y8u9i0o1p2a3s4d5f6g7h8j9k0l1m2n3', |
| 32 | + balance: '10.0000 EGLD', |
| 33 | + usdValue: '$2,025.00', |
| 34 | + index: 2, |
| 35 | + shard: 2, |
| 36 | + }, |
| 37 | + { |
| 38 | + address: 'erd1k9p7s0q3w4e5r6t7y8u9i0o1p2a3s4d5f6g7h8j9k0l1m2n3q4r5s6t7u8v', |
| 39 | + balance: '0.0100 EGLD', |
| 40 | + usdValue: '$2.05', |
| 41 | + index: 3, |
| 42 | + shard: 0, |
| 43 | + }, |
| 44 | + { |
| 45 | + address: 'erd1x2c3v4b5n6m7a8s9d0f1g2h3j4k5l6z7x8c9v0b1n2m3a4s5d6f7g8h9j0', |
| 46 | + balance: '5.6789 EGLD', |
| 47 | + usdValue: '$1,150.45', |
| 48 | + index: 4, |
| 49 | + shard: 1, |
| 50 | + }, |
| 51 | + ], |
| 52 | +}; |
| 53 | + |
| 54 | +type AddressTableStoryArgs = { |
| 55 | + accountScreenData: IAddressTableData; |
| 56 | + selectedIndex: number; |
| 57 | +}; |
| 58 | + |
| 59 | +const storySettings: Meta<AddressTableStoryArgs> = { |
| 60 | + tags: ['autodocs'], |
| 61 | + title: 'Components/AddressTable', |
| 62 | + args: { |
| 63 | + accountScreenData: exampleAccountScreenData, |
| 64 | + selectedIndex: exampleAccountScreenData.accounts[0].index, |
| 65 | + }, |
| 66 | + argTypes: { |
| 67 | + accountScreenData: { control: 'object' }, |
| 68 | + selectedIndex: { control: { type: 'number', min: 0 } }, |
| 69 | + }, |
| 70 | +}; |
| 71 | + |
| 72 | +export const Default: StoryObj<AddressTableStoryArgs> = { |
| 73 | + render: properties => ( |
| 74 | + <div class={styles.addressTableStoriesWrapper}> |
| 75 | + <div class={styles.addressTableStoriesContainer}> |
| 76 | + <mvx-address-table |
| 77 | + data-account-screen-data={JSON.stringify(properties.accountScreenData ?? exampleAccountScreenData)} |
| 78 | + selectedIndex={properties.selectedIndex} |
| 79 | + /> |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + ), |
| 83 | +}; |
| 84 | + |
| 85 | +export const PageChanging: StoryObj<AddressTableStoryArgs> = { |
| 86 | + render: properties => ( |
| 87 | + <div class={styles.addressTableStoriesWrapper}> |
| 88 | + <div class={styles.addressTableStoriesContainer}> |
| 89 | + <mvx-address-table |
| 90 | + data-account-screen-data={JSON.stringify({ |
| 91 | + ...exampleAccountScreenData, |
| 92 | + isLoading: true, |
| 93 | + })} |
| 94 | + selectedIndex={properties.selectedIndex} |
| 95 | + /> |
| 96 | + </div> |
| 97 | + </div> |
| 98 | + ), |
| 99 | +}; |
| 100 | + |
| 101 | +export const InitialLoadingIntro: StoryObj<AddressTableStoryArgs> = { |
| 102 | + render: properties => ( |
| 103 | + <div class={styles.addressTableStoriesWrapper}> |
| 104 | + <div class={styles.addressTableStoriesContainer}> |
| 105 | + <mvx-address-table |
| 106 | + data-account-screen-data={JSON.stringify({ |
| 107 | + ...exampleAccountScreenData, |
| 108 | + accounts: [], |
| 109 | + isLoading: true, |
| 110 | + })} |
| 111 | + selectedIndex={properties.selectedIndex} |
| 112 | + /> |
| 113 | + </div> |
| 114 | + </div> |
| 115 | + ), |
| 116 | +}; |
| 117 | + |
| 118 | +export default storySettings; |
0 commit comments