Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/extension-ui/src/Popup/Accounts/Account.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,26 @@

import Adapter from 'enzyme-adapter-react-16';
import { configure, mount, ReactWrapper } from 'enzyme';
import { Link } from '@polkadot/extension-ui/components';
import { Link, defaultTheme, Theme } from '@polkadot/extension-ui/components';
import { MemoryRouter } from 'react-router';
import React from 'react';

import Account from './Account';
import { ThemeProvider } from 'styled-components';

configure({ adapter: new Adapter() });

describe('Account component', () => {
let wrapper: ReactWrapper;
const VALID_ADDRESS = 'HjoBp62cvsWDA3vtNMWxz6c9q13ReEHi9UGHK7JbZweH5g5';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mountAccountComponent = (additionalAccountProperties: any): ReactWrapper => mount(
const mountAccountComponent = (additionalAccountProperties: any, theme: Theme = defaultTheme): ReactWrapper => mount(
<MemoryRouter>
<Account
{...{ address: VALID_ADDRESS, ...additionalAccountProperties }}>
</Account>
<ThemeProvider theme={theme}>
<Account
{...{ address: VALID_ADDRESS, ...additionalAccountProperties }}>
</Account>
</ThemeProvider>
</MemoryRouter>);

it('shows Export option if account is not external', () => {
Expand Down
6 changes: 2 additions & 4 deletions packages/extension-ui/src/components/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { Chain } from '@polkadot/extension-chains/types';
import React, { useContext, useEffect, useState } from 'react';
import styled from 'styled-components';
import findChain from '@polkadot/extension-chains';
import Identicon from '@polkadot/react-identicon';
import settings from '@polkadot/ui-settings';
import { decodeAddress, encodeAddress } from '@polkadot/util-crypto';

import IconBox from './IconBox';
import { AccountContext } from './contexts';
import { Identicon } from '@polkadot/extension-ui/components';

interface Props {
address?: string | null;
Expand Down Expand Up @@ -75,9 +75,7 @@ function Address ({ address, children, className, genesisHash, name }: Props): R
className={className}
icon={
<Identicon
className='icon'
size={64}
theme={theme}
iconTheme={theme}
value={address}
/>
}
Expand Down
37 changes: 37 additions & 0 deletions packages/extension-ui/src/components/Identicon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2019 @polkadot/extension-ui authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import React from 'react';
import styled from 'styled-components';
import Icon from '@polkadot/react-identicon';

interface Props {
iconTheme?: 'beachball' | 'empty' | 'jdenticon' | 'polkadot' | 'substrate';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will our coloring work for other types?

className?: string;
value?: string | null;
}

function Identicon ({ iconTheme, className, value }: Props): React.ReactElement<Props> {
return <div className={className}>
<Icon
className='icon'
size={64}
theme={iconTheme}
value={value}
/>
</div>;
}

export default styled(Identicon)`
.container:before {
box-shadow: none;
background: ${({ theme }): string => theme.identiconBackground};
}

svg {
circle:first-of-type {
display: none;
}
}
`;
1 change: 1 addition & 0 deletions packages/extension-ui/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export { default as Fonts } from './Fonts';
export { default as Header } from './Header';
export { default as Icon } from './Icon';
export { default as IconBox } from './IconBox';
export { default as Identicon } from './Identicon';
export { default as InputWithLabel } from './InputWithLabel';
export { default as Link } from './Link';
export { default as Loading } from './Loading';
Expand Down
1 change: 1 addition & 0 deletions packages/extension-ui/src/components/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const defaultTheme = {
readonlyInputBackground: '#000000',
iconWarningColor: '#FF7D01',
iconDangerColor: '#FF5858',
identiconBackground: '#373737',
inputBorder: '#303030',
inputPadding: '0.5rem 0.75rem',
inputPaddingLabel: '1.25rem 0.75rem 0.5rem',
Expand Down