Skip to content

Commit

Permalink
Merge branch 'develop' into upgrade-jest
Browse files Browse the repository at this point in the history
  • Loading branch information
brad-decker authored Aug 18, 2022
2 parents 6584888 + f2514c8 commit 2ed42b8
Show file tree
Hide file tree
Showing 36 changed files with 1,950 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .storybook/metamask-storybook-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export default create({
brandTitle: 'MetaMask Storybook',

// Typography
fontBase: 'Euclid, Roboto, Helvetica, Arial, sans-serif',
fontBase: 'Euclid Circular B, Roboto, Helvetica, Arial, sans-serif',
fontCode: 'Inconsolata, monospace',
});
Binary file added app/fonts/Euclid/EuclidCircularB-Medium.ttf
Binary file not shown.
6 changes: 3 additions & 3 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ function setupController(initState, initLangCode, remoteSourcePort) {
},
);

setupSentryGetStateGlobal(controller.store);
setupSentryGetStateGlobal(controller);

/**
* Assigns the given state to the versioned object (with metadata), and returns that.
Expand Down Expand Up @@ -788,11 +788,11 @@ browser.runtime.onInstalled.addListener(({ reason }) => {
function setupSentryGetStateGlobal(store) {
global.getSentryState = function () {
const fullState = store.getState();
const debugState = maskObject(fullState, SENTRY_STATE);
const debugState = maskObject({ metamask: fullState }, SENTRY_STATE);
return {
browser: window.navigator.userAgent,
store: debugState,
version: global.platform.getVersion(),
version: platform.getVersion(),
};
};
}
16 changes: 16 additions & 0 deletions app/scripts/lib/setupSentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ export default function setupSentry({ release, getState }) {
}
return rewriteReport(report);
},
beforeBreadcrumb(breadcrumb) {
if (getState) {
const appState = getState();
if (
Object.values(appState).length &&
(!appState?.store?.metamask?.participateInMetaMetrics ||
!appState?.store?.metamask?.completedOnboarding ||
breadcrumb?.category === 'ui.input')
) {
return null;
}
} else {
return null;
}
return breadcrumb;
},
});

function rewriteReport(report) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"@material-ui/core": "^4.11.0",
"@metamask/contract-metadata": "^1.31.0",
"@metamask/controllers": "^30.1.0",
"@metamask/design-tokens": "^1.8.0",
"@metamask/design-tokens": "^1.9.0",
"@metamask/eth-ledger-bridge-keyring": "^0.13.0",
"@metamask/eth-token-tracker": "^4.0.0",
"@metamask/etherscan-link": "^2.1.0",
Expand Down
7 changes: 5 additions & 2 deletions ui/components/app/signature-request-original/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
display: flex;
flex-flow: column;
flex: 1 1 auto;
height: 0;
}

&__origin-row {
Expand All @@ -168,6 +167,10 @@
margin-right: 5px;
}

&__origin-icon {
flex: 0 0 24px;
}

&__origin {
margin-left: 5px;
}
Expand All @@ -193,7 +196,7 @@

&__rows {
height: 100%;
overflow-y: scroll;
overflow-y: auto;
overflow-x: hidden;
border-top: 1px solid var(--color-border-default);
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default class SignatureRequestOriginal extends Component {
</div>
{targetSubjectMetadata?.iconUrl ? (
<SiteIcon
className="request-signature__origin-icon"
icon={targetSubjectMetadata.iconUrl}
name={
getURLHostName(targetSubjectMetadata.origin) ||
Expand Down
67 changes: 67 additions & 0 deletions ui/components/component-library/avatar-network/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';

import { AvatarNetwork } from './avatar-network';

# AvatarNetwork

The `AvatarNetwork` is a component responsible for display of the image of a given network

<Canvas>
<Story id="ui-components-component-library-avatar-network-avatar-network-stories-js--default-story" />
</Canvas>

## Props

The `AvatarNetwork` accepts all props below as well as all [Box](/docs/ui-components-ui-box-box-stories-js--default-story) component props

<ArgsTable of={AvatarNetwork} />

### Size

Use the `size` prop to set the size of the `AvatarNetwork`.

Possible sizes include:

- `xs` 16px
- `sm` 24px
- `md` 32px
- `lg` 40px
- `xl` 48px

Defaults to `md`

<Canvas>
<Story id="ui-components-component-library-avatar-network-avatar-network-stories-js--size" />
</Canvas>

### Network Name

Use the `networkName` prop to set the initial alphabet of the `AvatarNetwork`. This will be used as the fallback display if no image url is passed to the `networkImageUrl` prop.

<Canvas>
<Story id="ui-components-component-library-avatar-network-avatar-network-stories-js--network-name" />
</Canvas>

### Network Image Url

Use the `networkImageUrl` prop to set the image to be rendered of the `AvatarNetwork`.

<Canvas>
<Story id="ui-components-component-library-avatar-network-avatar-network-stories-js--network-image-url" />
</Canvas>

### Show Halo

If we want to display the component with halo effect. Only works if an image url is supplied to `networkImageUrl`

<Canvas>
<Story id="ui-components-component-library-avatar-network-avatar-network-stories-js--show-halo" />
</Canvas>

### Color, Background Color And Border Color

Use the `color`, `backgroundColor` and `borderColor` props to set the text color, background-color and border-color of the `AvatarToken`.

<Canvas>
<Story id="ui-components-component-library-avatar-network-avatar-network-stories-js--color-background-color-and-border-color" />
</Canvas>
123 changes: 123 additions & 0 deletions ui/components/component-library/avatar-network/avatar-network.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { BaseAvatar } from '../base-avatar';
import Box from '../../ui/box/box';

import {
COLORS,
SIZES,
DISPLAY,
ALIGN_ITEMS,
JUSTIFY_CONTENT,
} from '../../../helpers/constants/design-system';

export const AvatarNetwork = ({
size = SIZES.MD,
networkName,
networkImageUrl,
showHalo,
color = COLORS.TEXT_DEFAULT,
backgroundColor = COLORS.BACKGROUND_ALTERNATIVE,
borderColor = COLORS.TRANSPARENT,
className,
...props
}) => {
const [showFallback, setShowFallback] = useState(false);

useEffect(() => {
setShowFallback(!networkImageUrl);
}, [networkImageUrl]);

const fallbackString = networkName && networkName[0] ? networkName[0] : '?';

const handleOnError = () => {
setShowFallback(true);
};

return (
<BaseAvatar
size={size}
display={DISPLAY.FLEX}
alignItems={ALIGN_ITEMS.CENTER}
justifyContent={JUSTIFY_CONTENT.CENTER}
className={classnames(
'avatar-network',
showHalo && 'avatar-network--with-halo',
className,
)}
{...{ backgroundColor, borderColor, color, ...props }}
>
{showFallback ? (
fallbackString
) : (
<>
{showHalo && (
<img
src={networkImageUrl}
className={
showHalo ? 'avatar-network__network-image--blurred' : ''
}
aria-hidden="true"
/>
)}
<img
className={
showHalo
? 'avatar-network__network-image--size-reduced'
: 'avatar-network__network-image'
}
onError={handleOnError}
src={networkImageUrl}
alt={networkName || 'network avatar'}
/>
</>
)}
</BaseAvatar>
);
};

AvatarNetwork.propTypes = {
/**
* The networkName accepts the string to render the first alphabet of the Avatar Name
*/
networkName: PropTypes.string,
/**
* The networkImageUrl accepts the string of the image to be rendered
*/
networkImageUrl: PropTypes.string,
/**
* The showHalo accepts a boolean prop to render the image with halo effect
*/
showHalo: PropTypes.bool,
/**
* The size of the AvatarNetwork
* Possible values could be 'SIZES.XS', 'SIZES.SM', 'SIZES.MD', 'SIZES.LG', 'SIZES.XL'
* Defaults to SIZES.MD
*/
size: PropTypes.oneOf(Object.values(SIZES)),
/**
* The background color of the AvatarNetwork
* Defaults to COLORS.BACKGROUND_ALTERNATIVE
*/
backgroundColor: Box.propTypes.backgroundColor,
/**
* The background color of the AvatarNetwork
* Defaults to COLORS.BORDER_DEFAULT
*/
borderColor: Box.propTypes.borderColor,
/**
* The color of the text inside the AvatarNetwork
* Defaults to COLORS.TEXT_DEFAULT
*/
color: Box.propTypes.color,
/**
* Additional classNames to be added to the AvatarNetwork
*/
className: PropTypes.string,
/**
* AvatarNetwork also accepts all Box props including but not limited to
* className, as(change root element of HTML element) and margin props
*/
...Box.propTypes,
};
23 changes: 23 additions & 0 deletions ui/components/component-library/avatar-network/avatar-network.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.avatar-network {
&--with-halo {
position: relative;
}

&__network-image {
width: 100%;

&--blurred {
filter: blur(20px);
}

&--size-reduced {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 62.5%;
height: 62.5%;
border-radius: 50%;
}
}
}
Loading

0 comments on commit 2ed42b8

Please sign in to comment.