diff --git a/packages/extension-ui/src/Popup/Metadata/Request.tsx b/packages/extension-ui/src/Popup/Metadata/Request.tsx
index 6530d78f..f24e34ec 100644
--- a/packages/extension-ui/src/Popup/Metadata/Request.tsx
+++ b/packages/extension-ui/src/Popup/Metadata/Request.tsx
@@ -71,7 +71,9 @@ function Request ({ className, metaId, request, url }: Props): React.ReactElemen
-
{t('This approval will add the metadata to your extension instance, allowing future requests to be decoded using this metadata.')}
+
+ {t('This approval will add the metadata to your extension instance, allowing future requests to be decoded using this metadata.')}
+
- {error &&
{error}
}
+ {error && (
+
+ {error}
+
+ )}
);
}
-export default React.memo(styled(Unlock)(({ theme }: ThemeProps) => `
- .error {
- font-size: ${theme.labelFontSize};
- line-height: ${theme.labelLineHeight};
- color: ${theme.errorColor};
- }
-`));
+export default React.memo(Unlock);
diff --git a/packages/extension-ui/src/components/InputWithLabel.tsx b/packages/extension-ui/src/components/InputWithLabel.tsx
index c69efdc3..ae8801dd 100644
--- a/packages/extension-ui/src/components/InputWithLabel.tsx
+++ b/packages/extension-ui/src/components/InputWithLabel.tsx
@@ -1,11 +1,12 @@
// Copyright 2019-2020 @polkadot/extension-ui authors & contributors
// SPDX-License-Identifier: Apache-2.0
-import React, { useCallback } from 'react';
+import React, { useCallback, useState } from 'react';
import styled from 'styled-components';
import Label from './Label';
import { Input } from './TextInputs';
+import Warning from './Warning';
interface Props {
className?: string;
@@ -25,11 +26,21 @@ interface Props {
}
function InputWithLabel ({ className, defaultValue, disabled, isError, isFocused, isReadOnly, label = '', onBlur, onChange, onEnter, placeholder, type = 'text', value, withoutMargin }: Props): React.ReactElement
{
- const _checkEnter = useCallback(
+ const [isCapsLock, setIsCapsLock] = useState(false);
+
+ const _checkKey = useCallback(
(event: React.KeyboardEvent): void => {
onEnter && event.key === 'Enter' && onEnter();
+
+ if (type === 'password') {
+ if (event.getModifierState('CapsLock')) {
+ setIsCapsLock(true);
+ } else {
+ setIsCapsLock(false);
+ }
+ }
},
- [onEnter]
+ [onEnter, type]
);
const _onChange = useCallback(
@@ -52,7 +63,7 @@ function InputWithLabel ({ className, defaultValue, disabled, isError, isFocused
disabled={disabled}
onBlur={onBlur}
onChange={_onChange}
- onKeyPress={_checkEnter}
+ onKeyPress={_checkKey}
placeholder={placeholder}
readOnly={isReadOnly}
spellCheck={false}
@@ -60,6 +71,9 @@ function InputWithLabel ({ className, defaultValue, disabled, isError, isFocused
value={value}
withError={isError}
/>
+ { isCapsLock && (
+ Warning: Caps lock is on
+ )}
);
}
@@ -69,5 +83,9 @@ export default styled(InputWithLabel)`
&.withoutMargin {
margin-bottom: 0px;
+
+ + .error {
+ margin-top: 6px;
+ }
}
`;
diff --git a/packages/extension-ui/src/components/TextInputs.ts b/packages/extension-ui/src/components/TextInputs.ts
index 70016004..169f89ca 100644
--- a/packages/extension-ui/src/components/TextInputs.ts
+++ b/packages/extension-ui/src/components/TextInputs.ts
@@ -11,9 +11,9 @@ interface Props extends ThemeProps {
const TextInput = css(({ theme, withError }: Props) => `
background: ${theme.inputBackground};
- border-color: ${withError ? theme.errorBorderColor : theme.inputBorderColor};
border-radius: ${theme.borderRadius};
border: 1px solid ${theme.inputBorderColor};
+ border-color: ${withError ? theme.errorBorderColor : theme.inputBorderColor};
box-sizing: border-box;
color: ${withError ? theme.errorColor : theme.textColor};
display: block;
diff --git a/packages/extension-ui/src/components/ValidatedInput.tsx b/packages/extension-ui/src/components/ValidatedInput.tsx
index 660e98ad..cd0facb0 100644
--- a/packages/extension-ui/src/components/ValidatedInput.tsx
+++ b/packages/extension-ui/src/components/ValidatedInput.tsx
@@ -1,13 +1,11 @@
// Copyright 2019-2020 @polkadot/extension-ui authors & contributors
// SPDX-License-Identifier: Apache-2.0
-import { ThemeProps } from '../types';
-
import React, { useState, useEffect } from 'react';
-import styled from 'styled-components';
import useIsMounted from '../hooks/useIsMounted';
import { Result, Validator } from '../util/validators';
+import Warning from './Warning';
interface BasicProps {
isError?: boolean;
@@ -52,17 +50,16 @@ function ValidatedInput> ({ className, compone
onChange={setValue}
value={value}
/>
- {Result.isError(validationResult) && {validationResult.error.errorDescription} }
+ {Result.isError(validationResult) && (
+
+ {validationResult.error.errorDescription}
+
+ )}
);
}
-export default styled(ValidatedInput)(({ theme }: ThemeProps) => `
- .error {
- display: block;
- margin-top: -10px;
- font-size: ${theme.labelFontSize};
- line-height: ${theme.labelLineHeight};
- color: ${theme.errorColor};
- }
-`);
+export default ValidatedInput;
diff --git a/packages/extension-ui/src/components/Warning.tsx b/packages/extension-ui/src/components/Warning.tsx
index 0bf48869..d3824a72 100644
--- a/packages/extension-ui/src/components/Warning.tsx
+++ b/packages/extension-ui/src/components/Warning.tsx
@@ -12,30 +12,48 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
interface Props extends ThemeProps {
children: React.ReactNode;
className?: string;
+ isBelowInput?: boolean;
isDanger?: boolean;
}
-function Warning ({ children, className }: Props): React.ReactElement