|
| 1 | +import type { Meta, StoryObj } from '@storybook/react'; |
| 2 | +import React from 'react'; |
| 3 | + |
| 4 | +import { Jazzicon } from './Jazzicon'; |
| 5 | +import type { JazziconProps } from './Jazzicon.types'; |
| 6 | +import README from './README.mdx'; |
| 7 | + |
| 8 | +const meta: Meta<JazziconProps> = { |
| 9 | + title: 'React Components/Jazzicon', |
| 10 | + component: Jazzicon, |
| 11 | + parameters: { |
| 12 | + docs: { |
| 13 | + page: README, |
| 14 | + }, |
| 15 | + }, |
| 16 | + args: { |
| 17 | + address: '0x9Cbf7c41B7787F6c621115010D3B044029FE2Ce8', |
| 18 | + size: 32, |
| 19 | + }, |
| 20 | + argTypes: { |
| 21 | + address: { |
| 22 | + control: 'text', |
| 23 | + description: |
| 24 | + 'Required address used as a unique identifier to generate the Jazzicon.', |
| 25 | + }, |
| 26 | + size: { |
| 27 | + control: 'number', |
| 28 | + description: 'Optional prop to control the size of the Jazzicon.', |
| 29 | + }, |
| 30 | + className: { |
| 31 | + control: 'text', |
| 32 | + description: |
| 33 | + 'Optional prop for additional CSS classes to be applied to the Jazzicon component.', |
| 34 | + }, |
| 35 | + }, |
| 36 | +}; |
| 37 | + |
| 38 | +export default meta; |
| 39 | +type Story = StoryObj<JazziconProps>; |
| 40 | + |
| 41 | +const sampleAccountAddresses = [ |
| 42 | + '0x9Cbf7c41B7787F6c621115010D3B044029FE2Ce8', // Standard Ethereum address |
| 43 | + '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', // Bitcoin address |
| 44 | + '4Nd1m3NnENa8h8Xte1Xr7s9jcvKqqm21z3FvY9hKg4s7', // Solana address |
| 45 | + 'eip155:1:0xabc', // CAIP-10 formatted address |
| 46 | + 'bip122:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', // CAIP-10 Bitcoin address |
| 47 | + 'solana:mainnet:4Nd1m3NnENa8h8Xte1Xr7s9jcvKqqm21z3FvY9hKg4s7', // CAIP-10 Solana address |
| 48 | +]; |
| 49 | + |
| 50 | +export const Default: Story = {}; |
| 51 | + |
| 52 | +export const Address: Story = { |
| 53 | + render: () => ( |
| 54 | + <div className="flex flex-wrap gap-2"> |
| 55 | + {sampleAccountAddresses.map((address) => ( |
| 56 | + <Jazzicon key={address} address={address} size={32} /> |
| 57 | + ))} |
| 58 | + </div> |
| 59 | + ), |
| 60 | +}; |
| 61 | + |
| 62 | +export const Size: Story = { |
| 63 | + render: () => ( |
| 64 | + <div className="flex items-center gap-4"> |
| 65 | + <Jazzicon address={sampleAccountAddresses[0]} size={16} /> |
| 66 | + <Jazzicon address={sampleAccountAddresses[1]} size={24} /> |
| 67 | + <Jazzicon address={sampleAccountAddresses[2]} size={32} /> |
| 68 | + <Jazzicon address={sampleAccountAddresses[3]} size={48} /> |
| 69 | + <Jazzicon address={sampleAccountAddresses[4]} size={64} /> |
| 70 | + </div> |
| 71 | + ), |
| 72 | +}; |
0 commit comments