From 7e938e6fd1dc7366046ff1b9ff2a56ae27f914bd Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 20 Jan 2021 18:09:14 +0100 Subject: [PATCH] feat: brave node indicator (#966) This adds brave badge to indicate that companion is backed by the node managed by the brave browser: https://brave.com/ipfs-support/ --- add-on/icons/brave-ipfs-logo-off.svg | 1 + add-on/icons/brave-ipfs-logo-on.svg | 1 + add-on/src/popup/logo.js | 12 +++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 add-on/icons/brave-ipfs-logo-off.svg create mode 100644 add-on/icons/brave-ipfs-logo-on.svg diff --git a/add-on/icons/brave-ipfs-logo-off.svg b/add-on/icons/brave-ipfs-logo-off.svg new file mode 100644 index 000000000..5df86bf17 --- /dev/null +++ b/add-on/icons/brave-ipfs-logo-off.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/add-on/icons/brave-ipfs-logo-on.svg b/add-on/icons/brave-ipfs-logo-on.svg new file mode 100644 index 000000000..1b351bc35 --- /dev/null +++ b/add-on/icons/brave-ipfs-logo-on.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/add-on/src/popup/logo.js b/add-on/src/popup/logo.js index e2ee0da41..ad9771dba 100644 --- a/add-on/src/popup/logo.js +++ b/add-on/src/popup/logo.js @@ -2,17 +2,23 @@ /* eslint-env browser, webextensions */ const html = require('choo/html') +const { braveNodeType } = require('../lib/ipfs-client/brave') function logo ({ path, size = 52, ipfsNodeType = 'external', isIpfsOnline = true, heartbeat = true }) { - const logoTypePrefix = ipfsNodeType.startsWith('embedded') ? 'js-' : '' - const logoFileName = `${logoTypePrefix}ipfs-logo-${isIpfsOnline ? 'on' : 'off'}.svg` return html` IPFS ` } +function logoFileName (nodeType, isIpfsOnline) { + let prefix + if (nodeType.startsWith('embedded')) prefix = 'js-' + if (nodeType === braveNodeType) prefix = 'brave-' + return `${prefix || ''}ipfs-logo-${isIpfsOnline ? 'on' : 'off'}.svg` +} + module.exports = logo