replace icons with Checkbox component (#8830)

in both permission flows the checkboxes were using the fa-check icon, and in the case
of the connected accounts popover the color of the icon was wrong. It occurred to me
while simply fixing that color would have been easier, we will be adding permissions
at some point in the future that a user will be able to 'uncheck'. This PR replaces
the usages of those icons with the Checkbox component that is equipped to handle the
interactivity of checking/unchecking.
feature/default_network_editable
Brad Decker 4 years ago committed by GitHub
parent 3673d69816
commit 41c8e486af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      ui/app/components/app/connected-accounts-permissions/connected-accounts-permissions.component.js
  2. 8
      ui/app/components/app/connected-accounts-permissions/index.scss
  3. 10
      ui/app/components/app/permission-page-container/index.scss
  4. 16
      ui/app/components/app/permission-page-container/permission-page-container-content/permission-page-container-content.component.js
  5. 4
      ui/app/components/ui/check-box/check-box.component.js
  6. 1
      ui/app/components/ui/check-box/index.scss

@ -1,6 +1,7 @@
import classnames from 'classnames' import classnames from 'classnames'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import CheckBox from '../../ui/check-box'
export default class ConnectedAccountsPermissions extends PureComponent { export default class ConnectedAccountsPermissions extends PureComponent {
static contextTypes = { static contextTypes = {
@ -57,7 +58,8 @@ export default class ConnectedAccountsPermissions extends PureComponent {
<ul className="connected-accounts-permissions__list"> <ul className="connected-accounts-permissions__list">
{permissions.map(({ key: permissionName }) => ( {permissions.map(({ key: permissionName }) => (
<li key={permissionName} className="connected-accounts-permissions__list-item"> <li key={permissionName} className="connected-accounts-permissions__list-item">
<i className="fas fa-check-square" />{t(permissionName)} <CheckBox checked disabled id={permissionName} className="connected-accounts-permissions__checkbox" />
<label htmlFor={permissionName}>{t(permissionName)}</label>
</li> </li>
))} ))}
</ul> </ul>

@ -41,13 +41,11 @@
&__list-item { &__list-item {
display: flex; display: flex;
}
i { & &__checkbox {
display: block; margin: 0 8px 0 0;
padding-right: 8px;
font-size: 18px; font-size: 18px;
color: $Grey-800;
}
} }
&__list-container { &__list-container {

@ -62,11 +62,6 @@
display: flex; display: flex;
align-items: center; align-items: center;
i {
font-size: 1.4rem;
color: $Grey-200;
}
label { label {
font-size: 14px; font-size: 14px;
margin-left: 16px; margin-left: 16px;
@ -75,6 +70,11 @@
} }
} }
& &__checkbox {
font-size: 1.4rem;
margin: 0;
}
&__content-container { &__content-container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

@ -2,6 +2,7 @@ import PropTypes from 'prop-types'
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import PermissionsConnectHeader from '../../permissions-connect-header' import PermissionsConnectHeader from '../../permissions-connect-header'
import Tooltip from '../../../ui/tooltip-v2' import Tooltip from '../../../ui/tooltip-v2'
import CheckBox from '../../../ui/check-box'
export default class PermissionPageContainerContent extends PureComponent { export default class PermissionPageContainerContent extends PureComponent {
@ -33,6 +34,8 @@ export default class PermissionPageContainerContent extends PureComponent {
const description = t(permissionName) const description = t(permissionName)
// don't allow deselecting eth_accounts // don't allow deselecting eth_accounts
const isDisabled = permissionName === 'eth_accounts' const isDisabled = permissionName === 'eth_accounts'
const isChecked = Boolean(selectedPermissions[permissionName])
const title = isChecked ? t('permissionCheckedIconDescription') : t('permissionUncheckedIconDescription')
return ( return (
<div <div
@ -44,11 +47,14 @@ export default class PermissionPageContainerContent extends PureComponent {
} }
}} }}
> >
{ selectedPermissions[permissionName] <CheckBox
? <i title={t('permissionCheckedIconDescription')} className="fa fa-check-square" /> disabled={isDisabled}
: <i title={t('permissionUncheckedIconDescription')} className="fa fa-square" /> id={permissionName}
} className="permission-approval-container__checkbox"
<label>{description}</label> checked={isChecked}
title={title}
/>
<label htmlFor={permissionName}>{description}</label>
</div> </div>
) )
}) })

@ -10,7 +10,7 @@ const CHECKBOX_STATE = {
export const { CHECKED, INDETERMINATE, UNCHECKED } = CHECKBOX_STATE export const { CHECKED, INDETERMINATE, UNCHECKED } = CHECKBOX_STATE
const CheckBox = ({ className, disabled, id, onClick, checked }) => { const CheckBox = ({ className, disabled, id, onClick, checked, title }) => {
if (typeof checked === 'boolean') { if (typeof checked === 'boolean') {
checked = checked checked = checked
? CHECKBOX_STATE.CHECKED ? CHECKBOX_STATE.CHECKED
@ -41,6 +41,7 @@ const CheckBox = ({ className, disabled, id, onClick, checked }) => {
} }
readOnly readOnly
ref={ref} ref={ref}
title={title}
type="checkbox" type="checkbox"
/> />
) )
@ -52,6 +53,7 @@ CheckBox.propTypes = {
id: PropTypes.string, id: PropTypes.string,
onClick: PropTypes.func, onClick: PropTypes.func,
checked: PropTypes.oneOf([...Object.keys(CHECKBOX_STATE), true, false]).isRequired, checked: PropTypes.oneOf([...Object.keys(CHECKBOX_STATE), true, false]).isRequired,
title: PropTypes.string,
} }
CheckBox.defaultProps = { CheckBox.defaultProps = {

@ -18,6 +18,5 @@
&:disabled { &:disabled {
color: $Grey-100; color: $Grey-100;
cursor: not-allowed; cursor: not-allowed;
opacity: 0.5;
} }
} }

Loading…
Cancel
Save