-
-
Notifications
You must be signed in to change notification settings - Fork 5
[DSRN] Added AvatarGroup #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9051ac9
21573aa
326fcf7
dde29f4
bdf93d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,12 @@ import type { Meta, StoryObj } from '@storybook/react-native'; | |
import { View } from 'react-native'; | ||
|
||
import AvatarAccount from './AvatarAccount'; | ||
import { DEFAULT_AVATARACCOUNT_PROPS } from './AvatarAccount.constants'; | ||
import { | ||
DEFAULT_AVATARACCOUNT_PROPS, | ||
SAMPLE_AVATARACCOUNT_ADDRESSES, | ||
} from './AvatarAccount.constants'; | ||
import type { AvatarAccountProps } from './AvatarAccount.types'; | ||
import { AvatarSize } from '../../shared/enums'; | ||
import { IconName } from '../Icon'; | ||
import { AvatarAccountVariant } from './AvatarAccount.types'; | ||
|
||
const meta: Meta<AvatarAccountProps> = { | ||
|
@@ -29,28 +31,16 @@ const meta: Meta<AvatarAccountProps> = { | |
export default meta; | ||
|
||
type Story = StoryObj<AvatarAccountProps>; | ||
const sampleAccountAddresses = [ | ||
'0x9Cbf7c41B7787F6c621115010D3B044029FE2Ce8', | ||
'0xb9b81f6bd23B953c5257C3b5E2F0c03B07E944eB', | ||
'0x360507dfEC4Bf0c03495f91154A78C672599F308', | ||
'0x50cA820Ff810F7687E7d0aDb23A830e3ac6032C3', | ||
'0x840C9Eb73729E626673714D6E4dA8afc8Ccc90d3', | ||
'0xCA0361BE89B7d47a6233d1875F0727ddeAB23377', | ||
'0xD78CBcA88eCd65c6128511e46a518CDc6c66fC74', | ||
'0xCFc8b1d1031ef2ecce3a98d5D79ce4D75Edb06bA', | ||
'0xDe53fa2E659b6134991bB56F64B691990e5C44E7', | ||
'0x8AceA3A9748294d1B5C25a08EFE37b756AafDFdd', | ||
'0xEC5CE72f2e18B0017C88F7B12d3308119C5Cf129', | ||
'0xeC56Da21c90Af6b50E4Ba5ec252bD97e735290fc', | ||
]; | ||
export const Default: Story = { | ||
args: { | ||
size: DEFAULT_AVATARACCOUNT_PROPS.size, | ||
variant: DEFAULT_AVATARACCOUNT_PROPS.variant, | ||
twClassName: '', | ||
}, | ||
render: (args) => { | ||
return <AvatarAccount {...args} address={sampleAccountAddresses[0]} />; | ||
return ( | ||
<AvatarAccount {...args} address={SAMPLE_AVATARACCOUNT_ADDRESSES[0]} /> | ||
); | ||
Comment on lines
+41
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the benefits of storing sample data in constants, but we should also be aware of the tradeoffs. No action items—just noting that there are some downsides. Pros:
Cons:
Let's keep these in mind—maybe a mixed approach would help mitigate this: // Keep minimal examples direct in stories
export const Default: Story = {
render: () => (
<AvatarAccount
address="0x9Cbf7c41B7787F6c621115010D3B044029FE2Ce8"
/>
)
};
// Use constants for complex scenarios or when reuse is valuable
export const MultipleAddresses: Story = {
render: () => (
<View style={{ gap: 16 }}>
{SAMPLE_AVATARACCOUNT_ADDRESSES.slice(0, 3).map((address) => (
<AvatarAccount key={address} address={address} />
))}
</View>
)
}; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also do things like this without any type errors where the variant is token but the sample props are for network export const Default: Story = {
render: () => (
<AvatarGroup
variant={AvatarGroupVariant.Token}
avatarPropsArr={SAMPLE_AVATARGROUP_AVATARNETWORKPROPSARR}
/>
),
}; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same thing can be said for our tokens |
||
}, | ||
}; | ||
|
||
|
@@ -62,12 +52,12 @@ export const Sizes: Story = { | |
<AvatarAccount | ||
size={AvatarSize[sizeKey as keyof typeof AvatarSize]} | ||
variant={AvatarAccountVariant.Blockies} | ||
address={sampleAccountAddresses[0]} | ||
address={SAMPLE_AVATARACCOUNT_ADDRESSES[0]} | ||
/> | ||
<AvatarAccount | ||
size={AvatarSize[sizeKey as keyof typeof AvatarSize]} | ||
variant={AvatarAccountVariant.Jazzicon} | ||
address={sampleAccountAddresses[0]} | ||
address={SAMPLE_AVATARACCOUNT_ADDRESSES[0]} | ||
/> | ||
</View> | ||
))} | ||
|
@@ -86,7 +76,7 @@ export const Variants: Story = { | |
variantKey as keyof typeof AvatarAccountVariant | ||
] | ||
} | ||
address={sampleAccountAddresses[0]} | ||
address={SAMPLE_AVATARACCOUNT_ADDRESSES[0]} | ||
/> | ||
))} | ||
</View> | ||
|
@@ -96,7 +86,7 @@ export const Variants: Story = { | |
export const SampleAddresses: Story = { | ||
render: () => ( | ||
<View style={{ gap: 16 }}> | ||
{sampleAccountAddresses.map((address) => ( | ||
{SAMPLE_AVATARACCOUNT_ADDRESSES.map((address) => ( | ||
<View key={address} style={{ flexDirection: 'row', gap: 8 }}> | ||
<AvatarAccount | ||
variant={AvatarAccountVariant.Blockies} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,14 @@ export const DEFAULT_AVATARFAVICON_PROPS: Required< | |
width: '100%', | ||
height: '100%', | ||
}; | ||
|
||
// Sample Favicon URIs | ||
export const SAMPLE_AVATARFAVICON_URIS = [ | ||
'https://metamask.github.io/test-dapp/metamask-fox.svg', | ||
'https://www.coinbase.com/favicon.ico', | ||
'https://www.myetherwallet.com/favicon.ico', | ||
'https://www.blockchain.com/static/favicon.ico', | ||
'https://trezor.io/favicon.ico', | ||
'https://electrum.org/favicon.ico', | ||
'https://cryptologos.cc/logos/ethereum-eth-logo.svg', | ||
]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added these so they can be reused for both |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,7 +2,10 @@ import type { Meta, StoryObj } from '@storybook/react-native'; | |||||
import { ImageSourcePropType, View } from 'react-native'; | ||||||
|
||||||
import AvatarFavicon from './AvatarFavicon'; | ||||||
import { DEFAULT_AVATARFAVICON_PROPS } from './AvatarFavicon.constants'; | ||||||
import { | ||||||
DEFAULT_AVATARFAVICON_PROPS, | ||||||
SAMPLE_AVATARFAVICON_URIS, | ||||||
} from './AvatarFavicon.constants'; | ||||||
import type { AvatarFaviconProps } from './AvatarFavicon.types'; | ||||||
import { AvatarSize } from '../../shared/enums'; | ||||||
|
||||||
|
@@ -24,7 +27,7 @@ export default meta; | |||||
|
||||||
type Story = StoryObj<AvatarFaviconProps>; | ||||||
const storyImageSource: ImageSourcePropType = { | ||||||
uri: 'https://metamask.github.io/test-dapp/metamask-fox.svg', | ||||||
uri: SAMPLE_AVATARFAVICON_URIS[0], | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non-blocking: same comment here about storing sample data in constants. I think using a string here is helpful to instantly show what the value should be.
Suggested change
|
||||||
}; | ||||||
|
||||||
export const Default: Story = { | ||||||
|
@@ -48,3 +51,18 @@ export const Sizes: Story = { | |||||
</View> | ||||||
), | ||||||
}; | ||||||
|
||||||
export const SampleFavicons: Story = { | ||||||
render: () => ( | ||||||
<View style={{ gap: 16 }}> | ||||||
{SAMPLE_AVATARFAVICON_URIS.map((faviconUri) => ( | ||||||
<AvatarFavicon | ||||||
src={{ | ||||||
uri: faviconUri, | ||||||
}} | ||||||
key={faviconUri} | ||||||
/> | ||||||
))} | ||||||
</View> | ||||||
), | ||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added these so they can be reused for both
AvatarAccount
,AvatarGroup
, and any other components built fromAvatarAccount