Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init ipfs-api or js-ipfs #320

Merged
merged 20 commits into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extract logo component and use on quick upload
  • Loading branch information
olizilla committed Dec 1, 2017
commit f440bb36a2ee212258e0d23f7143b9d688ada934
2 changes: 1 addition & 1 deletion add-on/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"description": "A label in Node status section of Browser Action pop-up"
},
"panel_quickUpload": {
"message": "Quick Upload",
"message": "Share files via IPFS",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lidel what's the workflow for language changes like this, should we change back to English in the other language files to denote that it needs to be re-translated?

Copy link
Member

@lidel lidel Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alanshaw Yes, this is what should be done, but I think this step can be skipped now that we use Crowdin.

Crowdin will change them back to english after I upload new version of source locale (en), at least that is what happened when I've added new keys (other locales automatically got english stubs).

(I manually sync github<->crowdin before releases)

"description": "A menu item in Browser Action pop-up"
},
"panel_openWebui": {
Expand Down
12 changes: 6 additions & 6 deletions add-on/icons/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.
12 changes: 6 additions & 6 deletions add-on/icons/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.
16 changes: 8 additions & 8 deletions add-on/icons/js-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.
16 changes: 8 additions & 8 deletions add-on/icons/js-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.
2 changes: 1 addition & 1 deletion add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async function addFromURL (info) {
// TODO: feature detect and push to client type specific modules.
function getIpfsPathAndLocalAddress (hash) {
const path = `/ipfs/${hash}`
if (state.ipfsNodeType === 'embedded' && chrome.protocol.registerStringProtocol) {
if (state.ipfsNodeType === 'embedded' && chrome && chrome.protocol && chrome.protocol.registerStringProtocol) {
return {path, localAddress: `ipfs://${hash}`}
} else {
const url = new URL(path, state.gwURLString).toString()
Expand Down
14 changes: 7 additions & 7 deletions add-on/src/popup/browser-action/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

const browser = require('webextension-polyfill')
const html = require('choo/html')
const logo = require('../logo')

module.exports = function header ({ ipfsNodeType, onToggleNodeType, isIpfsOnline }) {
const logoTypePrefix = ipfsNodeType === 'embedded' ? 'js-' : ''
const logoFileName = `${logoTypePrefix}ipfs-logo-${isIpfsOnline ? 'on' : 'off'}.svg`
return html`
<div class="pv3 br2 br--top ba bw1 b--white" style="background: linear-gradient(to bottom, #041727 0%,#043b55 100%)">
<div class="tc mb2" title="${isIpfsOnline ? '' : 'offline'}">
<img
src="../../../icons/${logoFileName}"
class="${isIpfsOnline ? 'online' : ''}"
id="ipfs-logo"
style="width: 52px" />
${logo({
size: 52,
path: '../../../icons',
ipfsNodeType,
isIpfsOnline
})}
</div>
<h1 class="f5 mt2 mb2 tc white normal">IPFS node</h1>
<div class="pt1">
Expand Down
30 changes: 0 additions & 30 deletions add-on/src/popup/browser-action/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,3 @@
.outline-0--focus:focus {
outline: 0;
}

@keyframes heart-beat {
0% {
transform: scale(1);
}
5% {
transform: scale(1.05);
filter: drop-shadow(0 0 1.05em rgba(95, 203, 207, 0.5));
}
10% {
transform: scale(1.025);
filter: drop-shadow(0 0 1.025em rgba(95, 203, 207, 0.25));
}
15% {
transform: scale(1.075);
filter: drop-shadow(0 0 1.075em rgba(95, 203, 207, 0.5));
}
50% {
transform: scale(1);
}
100% {
transform: scale(1);
}
}

#ipfs-logo.online {
animation-name: heart-beat;
animation-iteration-count: infinite;
animation-duration: 2.5s;
}
29 changes: 29 additions & 0 deletions add-on/src/popup/heartbeat.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@keyframes heartbeat {
0% {
transform: scale(1);
}
5% {
transform: scale(1.05);
filter: drop-shadow(0 0 1.05em rgba(95, 203, 207, 0.5));
}
10% {
transform: scale(1.025);
filter: drop-shadow(0 0 1.025em rgba(95, 203, 207, 0.25));
}
15% {
transform: scale(1.075);
filter: drop-shadow(0 0 1.075em rgba(95, 203, 207, 0.5));
}
50% {
transform: scale(1);
}
100% {
transform: scale(1);
}
}

.heartbeat {
animation-name: heartbeat;
animation-iteration-count: infinite;
animation-duration: 2.5s;
}
20 changes: 20 additions & 0 deletions add-on/src/popup/logo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'
/* eslint-env browser, webextensions */

const html = require('choo/html')
require('./heartbeat.css')

function logo ({ path, size = 52, ipfsNodeType = 'external', isIpfsOnline = true, heartbeat = true }) {
const logoTypePrefix = ipfsNodeType === 'embedded' ? 'js-' : ''
const logoFileName = `${logoTypePrefix}ipfs-logo-${isIpfsOnline ? 'on' : 'off'}.svg`
return html`
<img
alt="IPFS"
title='IPFS'
src="${path}/${logoFileName}"
class="${isIpfsOnline && heartbeat ? 'heartbeat' : ''}"
style="width:${size}px; height:${size}px" />
`
}

module.exports = logo
5 changes: 5 additions & 0 deletions add-on/src/popup/quick-upload.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import url('node_modules/tachyons/css/tachyons.css');

html, body, #root {
height: 100%;
}
15 changes: 0 additions & 15 deletions add-on/src/popup/quick-upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@
<title>IPFS Upload</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width" />
<style type="text/css">
#icon {
width: 6rem;
height: 6rem;
padding: 0.25rem;
margin-right: 1rem;
display: block;
float: left;
}
#form {
font-family: sans-serif;
display: block;
padding-top: 1.5rem;
}
</style>
</head>

<body>
Expand Down
31 changes: 22 additions & 9 deletions add-on/src/popup/quick-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
/* eslint-env browser, webextensions */

const browser = require('webextension-polyfill')
const IpfsApi = require('ipfs-api')
const Buffer = IpfsApi().Buffer
const choo = require('choo')
const html = require('choo/html')
const logo = require('./logo')

require('./quick-upload.css')

const app = choo()

Expand All @@ -14,7 +15,9 @@ app.route('*', quickUploadPage)
app.mount('#root')

function quickUploadStore (state, emitter) {
state.message = browser.i18n.getMessage('panel_quickUpload')
state.message = ''
state.peerCount = 8
state.ipfsNodeType = 'embedded'

emitter.on('fileInputChange', async (event) => {
const file = event.target.files[0]
Expand Down Expand Up @@ -49,12 +52,22 @@ function quickUploadPage (state, emit) {
const onFileInputChange = (e) => emit('fileInputChange', e)

return html`
<div>
<img src="../../icons/ipfs-logo-on.svg" id="icon"/>
<p id="form">
<span id="quickUploadMessage">${state.message}</span><br>
<input type="file" id="quickUploadInput" onchange=${onFileInputChange} />
</p>
<div class="helvetica white pt3" style="background: linear-gradient(to bottom, #041727 0%,#043b55 100%); height:100%;">
<div class="measure-wide center pa3 tc">
${logo({
size: 100,
path: '../../icons',
heartbeat: false
})}
<h1 id="quickUploadMessage" class='mb1'>
${browser.i18n.getMessage('panel_quickUpload')}
</h1>
<p id="form">
<input type="file" id="quickUploadInput" onchange=${onFileInputChange} />
<br>
${state.message}
</p>
</div>
</div>
`
}