mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fixup prop types and use constants (#10306)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
This commit is contained in:
parent
9269615b26
commit
469ccd20b3
@ -15,7 +15,7 @@ import { isPrefixedFormattedHexString } from '../../../../../shared/modules/util
|
|||||||
import { getEnvironmentType } from '../../../../../app/scripts/lib/util'
|
import { getEnvironmentType } from '../../../../../app/scripts/lib/util'
|
||||||
|
|
||||||
import ColorIndicator from '../../ui/color-indicator'
|
import ColorIndicator from '../../ui/color-indicator'
|
||||||
import { COLORS } from '../../../helpers/constants/design-system'
|
import { COLORS, SIZES } from '../../../helpers/constants/design-system'
|
||||||
import { Dropdown, DropdownMenuItem } from './components/dropdown'
|
import { Dropdown, DropdownMenuItem } from './components/dropdown'
|
||||||
|
|
||||||
// classes from nodes of the toggle element.
|
// classes from nodes of the toggle element.
|
||||||
@ -149,7 +149,7 @@ class NetworkDropdown extends Component {
|
|||||||
)}
|
)}
|
||||||
<ColorIndicator
|
<ColorIndicator
|
||||||
color={COLORS.UI2}
|
color={COLORS.UI2}
|
||||||
size={ColorIndicator.SIZES.LARGE}
|
size={SIZES.LG}
|
||||||
type={ColorIndicator.TYPES.FILLED}
|
type={ColorIndicator.TYPES.FILLED}
|
||||||
borderColor={isCurrentRpcTarget ? COLORS.WHITE : COLORS.UI2}
|
borderColor={isCurrentRpcTarget ? COLORS.WHITE : COLORS.UI2}
|
||||||
/>
|
/>
|
||||||
@ -219,7 +219,7 @@ class NetworkDropdown extends Component {
|
|||||||
)}
|
)}
|
||||||
<ColorIndicator
|
<ColorIndicator
|
||||||
color={network}
|
color={network}
|
||||||
size={ColorIndicator.SIZES.LARGE}
|
size={SIZES.LG}
|
||||||
type={ColorIndicator.TYPES.FILLED}
|
type={ColorIndicator.TYPES.FILLED}
|
||||||
borderColor={providerType === network ? COLORS.WHITE : network}
|
borderColor={providerType === network ? COLORS.WHITE : network}
|
||||||
/>
|
/>
|
||||||
@ -309,7 +309,7 @@ class NetworkDropdown extends Component {
|
|||||||
type={ColorIndicator.TYPES.FILLED}
|
type={ColorIndicator.TYPES.FILLED}
|
||||||
color={COLORS.TRANSPARENT}
|
color={COLORS.TRANSPARENT}
|
||||||
borderColor={COLORS.UI2}
|
borderColor={COLORS.UI2}
|
||||||
size={ColorIndicator.SIZES.LARGE}
|
size={SIZES.LG}
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
className="network-name-item"
|
className="network-name-item"
|
||||||
|
@ -6,7 +6,11 @@ import { NETWORK_TYPE_RPC } from '../../../../../shared/constants/network'
|
|||||||
|
|
||||||
import LoadingIndicator from '../../ui/loading-indicator'
|
import LoadingIndicator from '../../ui/loading-indicator'
|
||||||
import ColorIndicator from '../../ui/color-indicator'
|
import ColorIndicator from '../../ui/color-indicator'
|
||||||
import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system'
|
import {
|
||||||
|
COLORS,
|
||||||
|
SIZES,
|
||||||
|
TYPOGRAPHY,
|
||||||
|
} from '../../../helpers/constants/design-system'
|
||||||
import Chip from '../../ui/chip/chip'
|
import Chip from '../../ui/chip/chip'
|
||||||
import { useI18nContext } from '../../../hooks/useI18nContext'
|
import { useI18nContext } from '../../../hooks/useI18nContext'
|
||||||
|
|
||||||
@ -14,7 +18,9 @@ export default function NetworkDisplay({
|
|||||||
colored,
|
colored,
|
||||||
outline,
|
outline,
|
||||||
iconClassName,
|
iconClassName,
|
||||||
|
indicatorSize,
|
||||||
disabled,
|
disabled,
|
||||||
|
labelProps,
|
||||||
onClick,
|
onClick,
|
||||||
}) {
|
}) {
|
||||||
const { network, networkNickname, networkType } = useSelector((state) => ({
|
const { network, networkNickname, networkType } = useSelector((state) => ({
|
||||||
@ -36,7 +42,7 @@ export default function NetworkDisplay({
|
|||||||
>
|
>
|
||||||
<ColorIndicator
|
<ColorIndicator
|
||||||
color={networkType === NETWORK_TYPE_RPC ? COLORS.UI4 : networkType}
|
color={networkType === NETWORK_TYPE_RPC ? COLORS.UI4 : networkType}
|
||||||
size={ColorIndicator.SIZES.LARGE}
|
size={indicatorSize}
|
||||||
type={ColorIndicator.TYPES.FILLED}
|
type={ColorIndicator.TYPES.FILLED}
|
||||||
iconClassName={
|
iconClassName={
|
||||||
networkType === NETWORK_TYPE_RPC ? 'fa fa-question' : undefined
|
networkType === NETWORK_TYPE_RPC ? 'fa fa-question' : undefined
|
||||||
@ -61,12 +67,17 @@ export default function NetworkDisplay({
|
|||||||
})}
|
})}
|
||||||
labelProps={{
|
labelProps={{
|
||||||
variant: TYPOGRAPHY.H7,
|
variant: TYPOGRAPHY.H7,
|
||||||
|
...labelProps,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
NetworkDisplay.propTypes = {
|
NetworkDisplay.propTypes = {
|
||||||
colored: PropTypes.bool,
|
colored: PropTypes.bool,
|
||||||
|
indicatorSize: PropTypes.oneOf(Object.values(SIZES)),
|
||||||
|
labelProps: PropTypes.shape({
|
||||||
|
...Chip.propTypes.labelProps,
|
||||||
|
}),
|
||||||
outline: PropTypes.bool,
|
outline: PropTypes.bool,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
iconClassName: PropTypes.string,
|
iconClassName: PropTypes.string,
|
||||||
@ -75,4 +86,5 @@ NetworkDisplay.propTypes = {
|
|||||||
|
|
||||||
NetworkDisplay.defaultProps = {
|
NetworkDisplay.defaultProps = {
|
||||||
colored: true,
|
colored: true,
|
||||||
|
indicatorSize: SIZES.LG,
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { COLORS } from '../../../helpers/constants/design-system'
|
import { COLORS, SIZES } from '../../../helpers/constants/design-system'
|
||||||
|
|
||||||
export default function ColorIndicator({
|
export default function ColorIndicator({
|
||||||
size = 'small',
|
size = 'small',
|
||||||
@ -29,12 +29,6 @@ export default function ColorIndicator({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorIndicator.SIZES = {
|
|
||||||
LARGE: 'large',
|
|
||||||
MEDIUM: 'medium',
|
|
||||||
SMALL: 'small,',
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorIndicator.TYPES = {
|
ColorIndicator.TYPES = {
|
||||||
FILLED: 'filled',
|
FILLED: 'filled',
|
||||||
PARTIAL: 'partial-filled',
|
PARTIAL: 'partial-filled',
|
||||||
@ -44,7 +38,7 @@ ColorIndicator.TYPES = {
|
|||||||
ColorIndicator.propTypes = {
|
ColorIndicator.propTypes = {
|
||||||
color: PropTypes.oneOf(Object.values(COLORS)),
|
color: PropTypes.oneOf(Object.values(COLORS)),
|
||||||
borderColor: PropTypes.oneOf(Object.values(COLORS)),
|
borderColor: PropTypes.oneOf(Object.values(COLORS)),
|
||||||
size: PropTypes.oneOf(Object.values(ColorIndicator.SIZES)),
|
size: PropTypes.oneOf(Object.values(SIZES)),
|
||||||
iconClassName: PropTypes.string,
|
iconClassName: PropTypes.string,
|
||||||
type: PropTypes.oneOf(Object.values(ColorIndicator.TYPES)),
|
type: PropTypes.oneOf(Object.values(ColorIndicator.TYPES)),
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
@use "design-system";
|
@use "design-system";
|
||||||
|
|
||||||
$sizes: (
|
$sizes: (
|
||||||
'large': 6,
|
'xl': 8,
|
||||||
'medium': 5,
|
'lg': 6,
|
||||||
'small': 4,
|
'md': 5,
|
||||||
|
'sm': 4,
|
||||||
|
'xs': 2.5,
|
||||||
);
|
);
|
||||||
|
|
||||||
.color-indicator {
|
.color-indicator {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { select } from '@storybook/addon-knobs'
|
import { select } from '@storybook/addon-knobs'
|
||||||
import { COLORS } from '../../../helpers/constants/design-system'
|
import { COLORS, SIZES } from '../../../helpers/constants/design-system'
|
||||||
import ColorIndicator from './color-indicator'
|
import ColorIndicator from './color-indicator'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -9,7 +9,7 @@ export default {
|
|||||||
|
|
||||||
export const colorIndicator = () => (
|
export const colorIndicator = () => (
|
||||||
<ColorIndicator
|
<ColorIndicator
|
||||||
size={select('size', ColorIndicator.SIZES, ColorIndicator.SIZES.LARGE)}
|
size={select('size', SIZES, SIZES.LG)}
|
||||||
type={select('type', ColorIndicator.TYPES, ColorIndicator.TYPES.FILLED)}
|
type={select('type', ColorIndicator.TYPES, ColorIndicator.TYPES.FILLED)}
|
||||||
color={select('color', COLORS, COLORS.PRIMARY1)}
|
color={select('color', COLORS, COLORS.PRIMARY1)}
|
||||||
borderColor={select('borderColor', { NONE: undefined, ...COLORS })}
|
borderColor={select('borderColor', { NONE: undefined, ...COLORS })}
|
||||||
@ -18,7 +18,7 @@ export const colorIndicator = () => (
|
|||||||
|
|
||||||
export const withIcon = () => (
|
export const withIcon = () => (
|
||||||
<ColorIndicator
|
<ColorIndicator
|
||||||
size={select('size', ColorIndicator.SIZES, ColorIndicator.SIZES.LARGE)}
|
size={select('size', SIZES, SIZES.LG)}
|
||||||
type={select('type', ColorIndicator.TYPES, ColorIndicator.TYPES.FILLED)}
|
type={select('type', ColorIndicator.TYPES, ColorIndicator.TYPES.FILLED)}
|
||||||
color={select('color', COLORS, COLORS.PRIMARY1)}
|
color={select('color', COLORS, COLORS.PRIMARY1)}
|
||||||
iconClassName="fa fa-question"
|
iconClassName="fa fa-question"
|
||||||
|
@ -72,7 +72,9 @@ export default function DefinitionList({
|
|||||||
|
|
||||||
DefinitionList.propTypes = {
|
DefinitionList.propTypes = {
|
||||||
gapSize: PropTypes.oneOf(Object.values(SIZES)),
|
gapSize: PropTypes.oneOf(Object.values(SIZES)),
|
||||||
dictionary: PropTypes.objectOf(PropTypes.string),
|
dictionary: PropTypes.objectOf(
|
||||||
|
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
|
),
|
||||||
tooltips: PropTypes.objectOf(PropTypes.string),
|
tooltips: PropTypes.objectOf(PropTypes.string),
|
||||||
termTypography: PropTypes.shape({
|
termTypography: PropTypes.shape({
|
||||||
...omit(Typography.propTypes, ['tag', 'className', 'boxProps']),
|
...omit(Typography.propTypes, ['tag', 'className', 'boxProps']),
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
NETWORKS_FORM_ROUTE,
|
NETWORKS_FORM_ROUTE,
|
||||||
} from '../../../helpers/constants/routes'
|
} from '../../../helpers/constants/routes'
|
||||||
import ColorIndicator from '../../../components/ui/color-indicator'
|
import ColorIndicator from '../../../components/ui/color-indicator'
|
||||||
import { COLORS } from '../../../helpers/constants/design-system'
|
import { COLORS, SIZES } from '../../../helpers/constants/design-system'
|
||||||
import NetworkForm from './network-form'
|
import NetworkForm from './network-form'
|
||||||
|
|
||||||
export default class NetworksTab extends PureComponent {
|
export default class NetworksTab extends PureComponent {
|
||||||
@ -113,7 +113,7 @@ export default class NetworksTab extends PureComponent {
|
|||||||
<ColorIndicator
|
<ColorIndicator
|
||||||
color={labelKey}
|
color={labelKey}
|
||||||
type={ColorIndicator.TYPES.FILLED}
|
type={ColorIndicator.TYPES.FILLED}
|
||||||
size={ColorIndicator.SIZES.LARGE}
|
size={SIZES.LG}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
className={classnames('networks-tab__networks-list-name', {
|
className={classnames('networks-tab__networks-list-name', {
|
||||||
@ -159,7 +159,7 @@ export default class NetworksTab extends PureComponent {
|
|||||||
type={ColorIndicator.TYPES.FILLED}
|
type={ColorIndicator.TYPES.FILLED}
|
||||||
color={COLORS.WHITE}
|
color={COLORS.WHITE}
|
||||||
borderColor={COLORS.UI4}
|
borderColor={COLORS.UI4}
|
||||||
size={ColorIndicator.SIZES.LARGE}
|
size={SIZES.LG}
|
||||||
/>
|
/>
|
||||||
<div className="networks-tab__networks-list-name networks-tab__networks-list-name--selected">
|
<div className="networks-tab__networks-list-name networks-tab__networks-list-name--selected">
|
||||||
{this.context.t('newNetwork')}
|
{this.context.t('newNetwork')}
|
||||||
|
Loading…
Reference in New Issue
Block a user