Skip to content

Commit

Permalink
feat: brave node indicator (#966)
Browse files Browse the repository at this point in the history
This adds brave badge to indicate that companion is backed by the node
managed by the brave browser: https://brave.com/ipfs-support/
  • Loading branch information
lidel authored Jan 20, 2021
1 parent 1c9b00a commit 7e938e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions add-on/icons/brave-ipfs-logo-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions add-on/icons/brave-ipfs-logo-on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions add-on/src/popup/logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
<img
alt="IPFS"
src="${path}/${logoFileName}"
src="${path}/${logoFileName(ipfsNodeType, isIpfsOnline)}"
class="v-mid ${isIpfsOnline ? '' : 'o-40'} ${isIpfsOnline && heartbeat ? 'heartbeat' : ''}"
style="width:${size}px; height:${size}px" />
`
}

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

0 comments on commit 7e938e6

Please sign in to comment.