Updates for JSON v3 (#393)

* Updates for JSON v3

* Bump ui

* isBusy markers

* isBusy button

* Spinner button

* Update tests

* Update packages/extension-ui/src/Popup/Export.tsx

* Adjust busy indicator

* Spinner colors
This commit is contained in:
Jaco Greeff
2020-07-22 13:59:42 +02:00
committed by GitHub
parent c8d02b2404
commit 837e1ecedd
21 changed files with 267 additions and 150 deletions
@@ -310,7 +310,7 @@ export default styled(Address)(({ theme }: ThemeProps) => `
}
.identityIcon {
margin-left: 25px;
margin-left: 15px;
margin-right: 10px;
& svg {
@@ -7,18 +7,26 @@ import { ThemeProps } from '../types';
import React from 'react';
import styled from 'styled-components';
import Spinner from './Spinner';
interface Props extends ThemeProps {
className?: string;
children?: React.ReactNode;
isBusy?: boolean;
isDanger?: boolean;
isDisabled?: boolean;
onClick?: () => void | Promise<void | boolean>;
to?: string;
}
function Button ({ children, className, isDisabled, onClick, to }: Props): React.ReactElement<Props> {
const STYLE: { position: 'relative'; width: string } = {
position: 'relative',
width: '100%'
};
function Button ({ children, className, isBusy, isDisabled, onClick, to }: Props): React.ReactElement<Props> {
const _onClick = (): void => {
if (isDisabled) {
if (isBusy || isDisabled) {
return;
}
@@ -30,13 +38,16 @@ function Button ({ children, className, isDisabled, onClick, to }: Props): React
};
return (
<button
className={className}
disabled={isDisabled}
onClick={_onClick}
>
{children}
</button>
<div style={STYLE}>
<button
className={className}
disabled={isDisabled || isBusy}
onClick={_onClick}
>
{children}
</button>
{isBusy && <Spinner />}
</div>
);
}
@@ -18,12 +18,20 @@ interface Props {
label: string;
onBlur?: () => void;
onChange?: (value: string) => void;
onEnter?: () => void;
type?: 'text' | 'password';
value?: string;
placeholder?: string;
}
function InputWithLabel ({ className, defaultValue, disabled, isError, isFocused, isReadOnly, label, onBlur, onChange, placeholder, type = 'text', value }: Props): React.ReactElement<Props> {
function InputWithLabel ({ className, defaultValue, disabled, isError, isFocused, isReadOnly, label, onBlur, onChange, onEnter, placeholder, type = 'text', value }: Props): React.ReactElement<Props> {
const _checkEnter = useCallback(
(event: React.KeyboardEvent<HTMLInputElement>): void => {
onEnter && event.key === 'Enter' && onEnter();
},
[onEnter]
);
const _onChange = useCallback(
({ target: { value } }: React.ChangeEvent<HTMLInputElement>): void => {
onChange && onChange(value);
@@ -44,6 +52,7 @@ function InputWithLabel ({ className, defaultValue, disabled, isError, isFocused
disabled={disabled}
onBlur={onBlur}
onChange={_onChange}
onKeyPress={_checkEnter}
placeholder={placeholder}
readOnly={isReadOnly}
spellCheck={false}
@@ -0,0 +1,33 @@
// Copyright 2019-2020 @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 { ThemeProps } from '../types';
import React from 'react';
import styled from 'styled-components';
import spinnerSrc from '../assets/spinner.png';
interface Props extends ThemeProps {
className?: string;
size?: 'normal';
}
function Spinner ({ className = '', size = 'normal' }: Props): React.ReactElement<Props> {
return (
<img
className={`${className} ${size}Size`}
src={spinnerSrc}
/>
);
}
export default React.memo(styled(Spinner)`
bottom: 0rem;
height: 3rem;
position: absolute;
right: 0.75rem;
width: 3rem;
z-index:
`);
@@ -26,6 +26,7 @@ export { default as MenuDivider } from './MenuDivider';
export { default as MenuItem } from './MenuItem';
export { default as MnemonicSeed } from './MnemonicSeed';
export { default as NextStepButton } from './NextStepButton';
export { default as Spinner } from './Spinner';
export { default as Svg } from './Svg';
export { default as Switch } from './Switch';
export { default as Table } from './Table';