From 79867bcebe72b83dd16a41524998cb916cb5e793 Mon Sep 17 00:00:00 2001
From: Hassan Malik <41640681+hmalik88@users.noreply.github.com>
Date: Wed, 1 Dec 2021 14:45:55 -0800
Subject: [PATCH] Adding snaps authorship pill (#12740)
* added npm icon
* added snaps-authorship-pill component and story
* updated npm icon
* added classname
* added comments
* changed label to an h7
* updated default label, removed unnecessary font-weight prop
* moved npm icon to flask/icons and added storybook file
* added hover/focus logic
* updated hover logic
* updated hover logic
* added authorship pill scss to app-components, removed unnecessary handlers
* removed npm icon, added font-awesome icon, added font-awesome brands to scss imports
* removed icons directory, updated scss file to use the proper color for npm icon, updated component with correct size and added class to change color
* fixed linter errors
* added link to pill and its story, changed title of story
* changed link to open in new tab, moved classname to root element and made it inline-block
* fixed proptype comment
* fixed linter error
---
ui/components/app/app-components.scss | 1 +
.../app/flask/snaps-authorship-pill/index.js | 1 +
.../flask/snaps-authorship-pill/index.scss | 16 ++++++
.../snaps-authorship-pill.js | 56 +++++++++++++++++++
.../snaps-authorship-pill.stories.js | 25 +++++++++
ui/css/design-system/typography.scss | 1 +
6 files changed, 100 insertions(+)
create mode 100644 ui/components/app/flask/snaps-authorship-pill/index.js
create mode 100644 ui/components/app/flask/snaps-authorship-pill/index.scss
create mode 100644 ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.js
create mode 100644 ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.stories.js
diff --git a/ui/components/app/app-components.scss b/ui/components/app/app-components.scss
index 4327df503..f83e5c476 100644
--- a/ui/components/app/app-components.scss
+++ b/ui/components/app/app-components.scss
@@ -19,6 +19,7 @@
@import 'edit-gas-fee-popover/edit-gas-item/index';
@import 'edit-gas-fee-popover/network-status/index';
@import 'edit-gas-fee-popover/network-status/status-slider/index';
+@import 'flask/snaps-authorship-pill/index';
@import 'gas-customization/gas-modal-page-container/index';
@import 'gas-customization/gas-price-button-group/index';
@import 'gas-customization/index';
diff --git a/ui/components/app/flask/snaps-authorship-pill/index.js b/ui/components/app/flask/snaps-authorship-pill/index.js
new file mode 100644
index 000000000..79acafe31
--- /dev/null
+++ b/ui/components/app/flask/snaps-authorship-pill/index.js
@@ -0,0 +1 @@
+export { default } from './snaps-authorship-pill';
diff --git a/ui/components/app/flask/snaps-authorship-pill/index.scss b/ui/components/app/flask/snaps-authorship-pill/index.scss
new file mode 100644
index 000000000..3ff6cb3eb
--- /dev/null
+++ b/ui/components/app/flask/snaps-authorship-pill/index.scss
@@ -0,0 +1,16 @@
+@import "design-system";
+
+.snaps-authorship-pill {
+ display: inline-block;
+
+ &:hover,
+ &:focus {
+ .chip {
+ background-color: $ui-1;
+ }
+ }
+}
+
+.snaps-authorship-icon {
+ color: $ui-4;
+}
diff --git a/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.js b/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.js
new file mode 100644
index 000000000..584c3c686
--- /dev/null
+++ b/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.js
@@ -0,0 +1,56 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import classnames from 'classnames';
+import Chip from '../../../ui/chip';
+import Box from '../../../ui/box';
+import Typography from '../../../ui/typography';
+import {
+ COLORS,
+ TYPOGRAPHY,
+} from '../../../../helpers/constants/design-system';
+
+const SnapsAuthorshipPill = ({ packageName, className, url }) => {
+ return (
+
+
+
+
+ }
+ backgroundColor={COLORS.WHITE}
+ >
+
+ {packageName}
+
+
+
+ );
+};
+
+SnapsAuthorshipPill.propTypes = {
+ /**
+ * NPM package name of the snap
+ */
+ packageName: PropTypes.string,
+ /**
+ * The className of the SnapsAuthorshipPill
+ */
+ className: PropTypes.string,
+ /**
+ * The url of the snap's package
+ */
+ url: PropTypes.string,
+};
+
+export default SnapsAuthorshipPill;
diff --git a/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.stories.js b/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.stories.js
new file mode 100644
index 000000000..2bd50d0df
--- /dev/null
+++ b/ui/components/app/flask/snaps-authorship-pill/snaps-authorship-pill.stories.js
@@ -0,0 +1,25 @@
+import React from 'react';
+import SnapsAuthorshipPill from '.';
+
+export default {
+ title: 'Components/App/Flask/SnapsAuthorshipPill',
+ id: __filename,
+ component: SnapsAuthorshipPill,
+ argTypes: {
+ packageName: {
+ control: 'text',
+ },
+ url: {
+ control: 'text',
+ },
+ },
+};
+
+export const DefaultStory = (args) => ;
+
+DefaultStory.storyName = 'Default';
+
+DefaultStory.args = {
+ packageName: 'npm-package-name',
+ url: 'https://www.npmjs.com/package/@airswap/protocols',
+};
diff --git a/ui/css/design-system/typography.scss b/ui/css/design-system/typography.scss
index 12b7d37ea..36544cd19 100644
--- a/ui/css/design-system/typography.scss
+++ b/ui/css/design-system/typography.scss
@@ -1,6 +1,7 @@
$fa-font-path: '/fonts/fontawesome';
@import '../../../node_modules/@fortawesome/fontawesome-free/scss/fontawesome';
+@import '../../../node_modules/@fortawesome/fontawesome-free/scss/brands';
@import '../../../node_modules/@fortawesome/fontawesome-free/scss/solid';
@import '../../../node_modules/@fortawesome/fontawesome-free/scss/regular';