Skip to content
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

Component/4779 audit #4809

Merged
merged 21 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions app/component-library/components/AccountAvatar/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions app/component-library/components/AccountAvatar/index.ts

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions app/component-library/components/AvatarIcon/AvatarIcon.tsx

This file was deleted.

35 changes: 0 additions & 35 deletions app/component-library/components/AvatarIcon/AvatarIcon.types.ts

This file was deleted.

23 changes: 0 additions & 23 deletions app/component-library/components/AvatarIcon/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable import/prefer-default-export */

export const DUMMY_WALLET_ADDRESS =
'0x10e08af911f2e489480fb2855b24771745d0198b50f5c55891369844a8c57092';
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Third party dependencies.
import React from 'react';
import { storiesOf } from '@storybook/react-native';
import { text, select } from '@storybook/addon-knobs';

// External dependencies.
import { AvatarBaseSize } from '../AvatarBase';

// Internal dependencies.
import AvatarAccount from './AvatarAccount';
import { AvatarAccountType } from './AvatarAccount.types';
import { DUMMY_WALLET_ADDRESS } from './AvatarAccount.constants';

storiesOf(' Component Library / AvatarAccount', module)
.addDecorator((getStory) => getStory())
.add('Default', () => {
const accountAddress = text('accountAddress', DUMMY_WALLET_ADDRESS);
const sizeSelector = select('size', AvatarBaseSize, AvatarBaseSize.Md);
const typeSelector = select(
'type',
AvatarAccountType,
AvatarAccountType.JazzIcon,
);

return (
<AvatarAccount
size={sizeSelector}
type={typeSelector}
accountAddress={accountAddress}
/>
);
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Third party dependencies.
import { StyleSheet } from 'react-native';

const styleSheet = StyleSheet.create({ imageStyle: { flex: 1 } });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Third party dependencies.
import React from 'react';
import { shallow } from 'enzyme';

// External dependencies.
import { AvatarBaseSize } from '../AvatarBase';

// Internal dependencies.
import AvatarAccount from './AvatarAccount';
import { AvatarAccountType } from './AvatarAccount.types';
import { DUMMY_WALLET_ADDRESS } from './AvatarAccount.constants';

describe('AvatarAccount', () => {
it('should render correctly', () => {
const wrapper = shallow(
<AvatarAccount
size={AvatarBaseSize.Xl}
type={AvatarAccountType.JazzIcon}
accountAddress={DUMMY_WALLET_ADDRESS}
/>,
);
expect(wrapper).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable react/prop-types */

// Third party dependencies.
import React from 'react';
import { Image } from 'react-native';
import JazzIcon from 'react-native-jazzicon';

// External dependencies.
import Avatar, { AvatarBaseSize } from '../AvatarBase';
import { toDataUrl } from '../../../../util/blockies';

// Internal dependencies.
import { AvatarAccountProps, AvatarAccountType } from './AvatarAccount.types';
import stylesheet from './AvatarAccount.styles';

const AvatarAccount = ({
type = AvatarAccountType.JazzIcon,
accountAddress,
size = AvatarBaseSize.Md,
style,
}: AvatarAccountProps) => (
<Avatar size={size} style={style}>
{
{
[AvatarAccountType.JazzIcon]: (
<JazzIcon size={Number(size)} address={accountAddress} />
),
[AvatarAccountType.Blockies]: (
<Image
source={{ uri: toDataUrl(accountAddress) }}
style={stylesheet.imageStyle}
/>
),
}[type]
}
</Avatar>
);

export default AvatarAccount;

export { AvatarAccount };
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// External dependencies.
import { AvatarBaseProps } from '../AvatarBase';

/**
* AvatarAccount variants.
*/
export enum AvatarAccountType {
JazzIcon = 'JazzIcon',
Blockies = 'Blockies',
}

/**
* AvatarAccount component props.
*/
export interface AvatarAccountProps extends AvatarBaseProps {
/**
* Optional enum to select the avatar type between `JazzIcon` and `Blockies`.
* @default JazzIcon
*/
type?: AvatarAccountType;
/**
* An Ethereum wallet address.
*/
accountAddress: string;
}
Loading