ghost-portal/packages/react-components/src/Checkbox.tsx
Krzysztof Jelski 7b387762bd
Updated flow for creating accounts (#3880)
* Add 3 step account creation

* Add textarea with dropdown

* Add OWASP and styles to PasswordStrength

* Align the checkbox with other ui elements

* Notification on mnemonic copy

* Make confirmation label clickable

* Do not shorten address in creation modal

* Make address name not editable in header

* Always show password strength meter

* Always show password strength meter

* Update tests to new account flow

* Remove repeated dependency

* Remove console.log from test

* Update yarn.lock

* Restore imports order.

* Format div component according to style

* Remove cursor styling for old browsers

* Empty line

* Organize imports. Configure StrengthTester once. Use color from theme.

* wip on text area

* TextArea styling

* Checbox styling

* Update repeated password validity on first password change

* Simplify CopyButton notification code.

* Change TextArea styling to more consistent

* Make password strength indicator wider

* Move external warning down and show on both steps

* Inline TextArea subcomponents

* Move mnemonic saved confirmation label closer to buttons

* Add steps counter to header

* Remove space

Co-authored-by: Michał Ziętalak <michal.z@ethworks.io>
Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-10-22 15:59:01 +02:00

71 lines
1.4 KiB
TypeScript

// Copyright 2017-2020 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React, { useCallback } from 'react';
import styled from 'styled-components';
import { ThemeProps } from './types';
import Icon from './Icon';
interface Props {
className?: string;
isDisabled?: boolean;
label: React.ReactNode;
onChange?: (isChecked: boolean) => void;
value?: boolean;
}
function Checkbox ({ className = '', isDisabled, label, onChange, value }: Props): React.ReactElement<Props> {
const _onClick = useCallback(
(): void => {
!isDisabled && onChange && onChange(!value);
},
[isDisabled, onChange, value]
);
return (
<div
className={`ui--Checkbox${isDisabled ? ' isDisabled' : ''} ${className}`}
onClick={_onClick}
>
<Icon
color={value ? 'normal' : 'transparent'}
icon='check'
/>
{label && <label>{label}</label>}
</div>
);
}
export default React.memo(styled(Checkbox)(({ theme }: ThemeProps) => `
display: inline-block;
cursor: pointer;
&.isDisabled {
opacity: 0.5;
}
&:not(.isDisabled) {
cursor: pointer;
}
> label {
color: ${theme.color};
display: inline-block;
margin: 0 0.5rem;
opacity: 1;
cursor: pointer;
user-select: none;
}
> label,
> .ui--Icon {
vertical-align: middle;
}
.ui--Icon {
border: 1px solid ${theme.colorCheckbox};
border-radius: 0.125rem;
}
`));