* WIP - merge edition of account name and tags * [WIP] - tests * Apply test improvements * Improve tests * Improve tests and use useCallback * WIP - add cancel button * Outside click * Add more tests * Apply styling * Add opacity on not editable elements * Remove unnecessary code and fix type of sidebar ref * Disable eslint rule * Place edit button within account menu buttons * Adjust test setup * Ato-lint fixes * Update styles * Apply review suggestions * Remove unused styles and change type of sidebar ref * Remove onCancel from useAccountInfo hook * Fix issue with edit button * Apply review suggestions, remove tests * Adjust tests * Simplify tests * Apply lint fixes * Change layout of buttons Co-authored-by: MiZiet <michalzietalak@o2.pl> Co-authored-by: Jaco Greeff <jacogr@gmail.com>
90 lines
1.8 KiB
TypeScript
90 lines
1.8 KiB
TypeScript
// Copyright 2017-2021 @polkadot/react-components authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { IconName } from '@fortawesome/fontawesome-svg-core';
|
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core';
|
|
import { fas } from '@fortawesome/free-solid-svg-icons';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
import React from 'react';
|
|
import styled from 'styled-components';
|
|
|
|
interface Props {
|
|
className?: string;
|
|
color?: 'gray' | 'green' | 'normal' | 'orange' | 'red' | 'transparent' | 'white' | 'darkGray';
|
|
icon: IconName;
|
|
isPadded?: boolean;
|
|
isSpinning?: boolean;
|
|
onClick?: () => void;
|
|
size?: '1x' | '2x';
|
|
tooltip?: string;
|
|
}
|
|
|
|
// one-time init of FA libraries
|
|
library.add(fas);
|
|
|
|
function Icon ({ className = '', color = 'normal', icon, isPadded, isSpinning, onClick, size = '1x', tooltip }: Props): React.ReactElement<Props> {
|
|
const extraProps: Record<string, unknown> = {
|
|
'data-testid': icon,
|
|
...(tooltip
|
|
? {
|
|
'data-for': tooltip,
|
|
'data-tip': true
|
|
}
|
|
: {}
|
|
)
|
|
};
|
|
|
|
return (
|
|
<FontAwesomeIcon
|
|
{...extraProps}
|
|
className={`ui--Icon ${color}Color${onClick ? ' isClickable' : ''}${isPadded ? ' isPadded' : ''} ${className}`}
|
|
icon={icon}
|
|
onClick={onClick}
|
|
size={size}
|
|
spin={isSpinning}
|
|
tabIndex={-1}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default React.memo(styled(Icon)`
|
|
outline: none;
|
|
|
|
&.isClickable {
|
|
cursor: pointer;
|
|
}
|
|
|
|
&.isPadded {
|
|
margin: 0 0.25rem;
|
|
}
|
|
|
|
&.grayColor {
|
|
opacity: 0.25;
|
|
}
|
|
|
|
&.greenColor {
|
|
color: green;
|
|
}
|
|
|
|
&.orangeColor {
|
|
color: darkorange;
|
|
}
|
|
|
|
&.redColor {
|
|
color: darkred;
|
|
}
|
|
|
|
&.transparentColor {
|
|
color: transparent;
|
|
}
|
|
|
|
&.whiteColor {
|
|
color: white;
|
|
}
|
|
|
|
&.darkGrayColor {
|
|
color: #8B8B8B;
|
|
}
|
|
`);
|