Allow for Custom IdentityIcon override (#375)

This commit is contained in:
Jaco Greeff
2020-09-30 14:20:50 +02:00
committed by GitHub
parent d4923b80fc
commit fea7424a7d
2 changed files with 4 additions and 3 deletions
+3 -3
View File
@@ -90,7 +90,7 @@ class BaseIcon extends React.PureComponent<Props, State> {
public render (): React.ReactNode { public render (): React.ReactNode {
const { address } = this.state; const { address } = this.state;
const wrapped = this.getWrapped(this.state); const wrapped = this.getWrapped(this.state, this.props);
return !address return !address
? wrapped ? wrapped
@@ -104,11 +104,11 @@ class BaseIcon extends React.PureComponent<Props, State> {
); );
} }
private getWrapped ({ address, publicKey }: State): React.ReactNode { private getWrapped ({ address, publicKey }: State, { Custom }: Props): React.ReactNode {
const { className = '', isAlternative, isHighlight, size = DEFAULT_SIZE, style, theme = settings.icon } = this.props; const { className = '', isAlternative, isHighlight, size = DEFAULT_SIZE, style, theme = settings.icon } = this.props;
const Component = !address const Component = !address
? Empty ? Empty
: Components[theme === 'default' ? ICON_DEFAULT_HOST : theme] || Fallback; : Custom || Components[theme === 'default' ? ICON_DEFAULT_HOST : theme] || Fallback;
return ( return (
<Wrapper <Wrapper
+1
View File
@@ -19,6 +19,7 @@ export interface Props extends BaseProps {
} }
export interface IdentityProps extends BaseProps { export interface IdentityProps extends BaseProps {
Custom?: React.ComponentType<Props>;
isAlternative?: boolean; isAlternative?: boolean;
isHighlight?: boolean; isHighlight?: boolean;
onCopy?: (value: string) => void; onCopy?: (value: string) => void;