Skip to content

Commit

Permalink
Merge pull request #565 from ipfs-shipyard/feat/add-landing-pages
Browse files Browse the repository at this point in the history
feat: add welcome page
  • Loading branch information
lidel authored Sep 18, 2018
2 parents e4388fd + 1d609cf commit 5c7be88
Show file tree
Hide file tree
Showing 14 changed files with 494 additions and 2 deletions.
76 changes: 76 additions & 0 deletions add-on/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,81 @@
"page_proxyAccessDialog_denyButton_text": {
"message": "Deny",
"description": "Button text for denying a permission (page_proxyAccessDialog_allowButton_text)"
},
"page_landingWelcome_title": {
"message": "IPFS Companion - Welcome!",
"description": "Page title (page_landingWelcome_title)"
},
"page_landingWelcome_logo_title": {
"message": "IPFS Companion",
"description": "Extension name after the IPFS logo (page_landingWelcome_logo_title)"
},
"page_landingWelcome_welcome_title": {
"message": "You are all set!",
"description": "Ready message title (page_landingWelcome_welcome_title)"
},
"page_landingWelcome_welcome_peers": {
"message": "Right now your node is connected to <0>$1</0> peers.",
"description": "Ready message copy (page_landingWelcome_welcome_peers)"
},
"page_landingWelcome_welcome_discover": {
"message": "Discover what you <0>can do with Companion</0> and dive into the distributed web with IPFS!",
"description": "Ready message copy (page_landingWelcome_welcome_discover)"
},
"page_landingWelcome_installSteps_title": {
"message": "Is your IPFS daemon running?",
"description": "Install steps title (page_landingWelcome_installSteps_title)"
},
"page_landingWelcome_installSteps_install": {
"message": "If you haven't installed IPFS please do so <0>with these instructions</0>.",
"description": "Install steps copy (page_landingWelcome_installSteps_install)"
},
"page_landingWelcome_installSteps_run": {
"message": "Then make sure to have an IPFS daemon running in your terminal:",
"description": "Install steps run message (page_landingWelcome_installSteps_run)"
},
"page_landingWelcome_resources_title_new_ipfs": {
"message": "New to IPFS?",
"description": "Resources title (page_landingWelcome_resources_title_new_ipfs)"
},
"page_landingWelcome_resources_new_ipfs": {
"message": "Read the <0>documentation</0> to learn about the basic <1>concepts</1> and working with IPFS.",
"description": "Resources copy (page_landingWelcome_resources_new_ipfs)"
},
"page_landingWelcome_resources_title_discover": {
"message": "Discover!",
"description": "Resources title (page_landingWelcome_resources_title_discover)"
},
"page_landingWelcome_resources_discover": {
"message": "Find <0>useful resources</0> for using IPFS and <1>building things</1> on top of it.",
"description": "Resources copy (page_landingWelcome_resources_discover)"
},
"page_landingWelcome_resources_title_got_questions": {
"message": "Got questions?",
"description": "Resources title (page_landingWelcome_resources_title_got_questions)"
},
"page_landingWelcome_resources_got_questions": {
"message": "Visit the <0>Discussion and Support Forum</0>.",
"description": "Resources copy (page_landingWelcome_resources_got_questions)"
},
"page_landingWelcome_resources_title_want_to_help": {
"message": "Want to help?",
"description": "Resources title (page_landingWelcome_resources_title_want_to_help)"
},
"page_landingWelcome_resources_want_to_help": {
"message": "Join the <0>IPFS Community</0>! Contribute with <1>code</1>, <2>documentation</2>, <3>translations</3> or help by <4>supporting other users</4>.",
"description": "Resources copy (page_landingWelcome_resources_want_to_help)"
},
"page_landingWelcome_videos_alpha_demo": {
"message": "IPFS Alpha Demo",
"description": "Videos section title (page_landingWelcome_videos_alpha_demo)"
},
"page_landingWelcome_videos_permanent_web": {
"message": "The Permanent Web",
"description": "Videos section title (page_landingWelcome_videos_permanent_web)"
},
"page_landingWelcome_projects_title": {
"message": "Related Projects",
"description": "Projects section title (page_landingWelcome_projects_title)"
}
}
1 change: 1 addition & 0 deletions add-on/images/ipld.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/images/libp2p.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/images/multiformats.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion add-on/src/background/background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
'use strict'
/* eslint-env browser, webextensions */

const browser = require('webextension-polyfill')
const createIpfsCompanion = require('../lib/ipfs-companion')
const { onInstalled } = require('../lib/on-installed')

// register onInstalled hook early, otherwise we miss first install event
browser.runtime.onInstalled.addListener(onInstalled)

// init add-on after all libs are loaded
document.addEventListener('DOMContentLoaded', async () => {
Expand Down
17 changes: 17 additions & 0 deletions add-on/src/landing-pages/welcome/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="welcome.css">
<link rel="stylesheet" href="../../popup/heartbeat.css">
</head>

<body class="navy bg-white sans-serif">
<div id="root"></div>
<script src="/dist/bundles/uiCommons.bundle.js"></script>
<script src="/dist/bundles/welcomePage.bundle.js"></script>
</body>

</html>
13 changes: 13 additions & 0 deletions add-on/src/landing-pages/welcome/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'
/* eslint-env browser, webextensions */

const browser = require('webextension-polyfill')
const choo = require('choo')
const createWelcomePageStore = require('./store')
const createWelcomePage = require('./page')

const app = choo()

app.use(createWelcomePageStore(browser.i18n, browser.runtime))
app.route('*', createWelcomePage(browser.i18n))
app.mount('#root')
204 changes: 204 additions & 0 deletions add-on/src/landing-pages/welcome/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
'use strict'

const html = require('choo/html')
const logo = require('../../popup/logo')
const { renderTranslatedLinks, renderTranslatedSpans } = require('../../utils/i18n')

// Assets
const libp2pLogo = '../../../images/libp2p.svg'
const multiformatsLogo = '../../../images/multiformats.svg'
const ipldLogo = '../../../images/ipld.svg'

// Colors
const colorIpfsLogo = '#57cbd0'
const colorWhite = '#ffffff'

function createWelcomePage (i18n) {
return function welcomePage (state, emit) {
const isIpfsOnline = state.isIpfsOnline
const peerCount = state.peerCount

// Set translated title
document.title = i18n.getMessage('page_landingWelcome_title')

return html`
<div class="flex flex-column flex-row-l">
<div id="left-col" class="min-vh-100 flex flex-column justify-center items-center bg-navy white">
${renderCompanionLogo(i18n, isIpfsOnline)}
${isIpfsOnline ? renderWelcome(i18n, peerCount) : renderInstallSteps(i18n, isIpfsOnline)}
</div>
<div id="right-col" class="min-vh-100 flex flex-column justify-around items-center">
${renderResources(i18n)}
${renderVideos(i18n)}
${renderProjects(i18n)}
</div>
</div>
`
}
}

/* ========================================================
Render functions for the left side
======================================================== */

const renderCompanionLogo = (i18n, isIpfsOnline) => {
const logoPath = '../../../icons'
const logoSize = 128
const stateUnknown = isIpfsOnline === null

return html`
<div class="mt4 mb4 flex flex-column justify-center items-center transition-all ${stateUnknown && 'state-unknown'}">
${logo({ path: logoPath, size: logoSize, isIpfsOnline: isIpfsOnline })}
<p class="montserrat mt3 mb0 f2">${i18n.getMessage('page_landingWelcome_logo_title')}</p>
</div>
`
}

const renderWelcome = (i18n, peerCount) => {
const anchorClass = 'white link underline-under hover-aqua'
const copyClass = 'mv0 tc lh-copy f5'
const svgWidth = 80

const checkmarkSvg = () => html`
<svg x="0px" y="0px" viewBox="0 0 84 84" width="${svgWidth}">
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g transform="translate(-802.000000, -218.000000)">
<g transform="translate(805.000000, 221.000000)">
<rect stroke="${colorIpfsLogo}" stroke-width="5" x="0" y="0" width="78" height="78" rx="39"/>
<g transform="translate(15.000000, 23.000000)" fill="${colorWhite}">
<rect transform="translate(10.747845, 24.447908) scale(-1, -1) rotate(-135.000000) translate(-10.747845, -24.447908) " x="-1" y="21.4479076" width="23.495689" height="6" rx="3"/>
<rect transform="translate(30.017983, 17.552092) scale(-1, -1) rotate(-45.000000) translate(-30.017983, -17.552092) " x="8.51798323" y="14.5520924" width="43" height="6" rx="3"/>
</g>
</g>
</g>
</g>
</svg>
`

return html`
<div class="w-80 flex flex-column justify-center">
<div class="mb4 flex flex-column justify-center items-center">
${checkmarkSvg()}
<p class="mt2 mb0 f3">${i18n.getMessage('page_landingWelcome_welcome_title')}</p>
</div>
<p class="${copyClass}">${renderTranslatedSpans('page_landingWelcome_welcome_peers', [peerCount], 'class="aqua fw6"')}</p>
<p class="${copyClass} mb4">${renderTranslatedLinks('page_landingWelcome_welcome_discover', ['https://github.com/ipfs-shipyard/ipfs-companion#features'], `target="_blank" class="${anchorClass}"`)}</p>
</div>
`
}

const renderInstallSteps = (i18n, isIpfsOnline) => {
const copyClass = 'mv0 white f5 lh-copy'
const anchorClass = 'white link underline-under hover-aqua'
const stateUnknown = isIpfsOnline === null

return html`
<div class="w-80 mt3 flex flex-column transition-all ${stateUnknown && 'state-unknown'}">
<p class="mt0 mb2 yellow f4 lh-title">${i18n.getMessage('page_landingWelcome_installSteps_title')}</p>
<p class="${copyClass}">${renderTranslatedLinks('page_landingWelcome_installSteps_install', ['https://docs.ipfs.io/introduction/install/'], `target="_blank" class="${anchorClass}"`)}</p>
<p class="${copyClass}">${i18n.getMessage('page_landingWelcome_installSteps_run')}</p>
<div className='db w-100 mt3 pa3 bg-black-70 bt bw4 br2 snow f7'>
<code className='db'>$ ipfs daemon</code>
<code className='db'>Initializing daemon...</code>
<code className='db'>API server listening on /ip4/127.0.0.1/tcp/5001</code>
</div>
</div>
`
}

/* ========================================================
Render functions for the right side
======================================================== */

const renderResources = (i18n) => {
const labelClass = 'aqua mb1'
const copyClass = 'mt0 mb4 lh-copy'
const anchorClass = 'navy link underline-under hover-aqua'

return html`
<div class="w-80 mv4 navy f5">
<p class="${labelClass}">${i18n.getMessage('page_landingWelcome_resources_title_new_ipfs')}</p>
<p class="${copyClass}">${renderTranslatedLinks('page_landingWelcome_resources_new_ipfs', ['https://docs.ipfs.io', 'https://docs.ipfs.io/guides/concepts'], `target="_blank" class="${anchorClass}"`)}</p>
<p class="${labelClass}">${i18n.getMessage('page_landingWelcome_resources_title_discover')}</p>
<p class="${copyClass}">${renderTranslatedLinks('page_landingWelcome_resources_discover', ['https://awesome.ipfs.io', 'https://github.com/ipfs/ipfs#project-links'], `target="_blank" class="${anchorClass}"`)}</p>
<p class="${labelClass}">${i18n.getMessage('page_landingWelcome_resources_title_got_questions')}</p>
<p class="${copyClass}">${renderTranslatedLinks('page_landingWelcome_resources_got_questions', ['https://discuss.ipfs.io'], `target="_blank" class="${anchorClass}"`)}</p>
<p class="${labelClass}">${i18n.getMessage('page_landingWelcome_resources_title_want_to_help')}</p>
<p class="${copyClass} mv0">${renderTranslatedLinks('page_landingWelcome_resources_want_to_help', ['https://github.com/ipfs/community/#community', 'https://github.com/ipfs/ipfs#project-links', 'https://github.com/ipfs/docs', 'https://www.transifex.com/ipfs/public', 'https://discuss.ipfs.io/c/help'], `target="_blank" class="${anchorClass}"`)}</p>
</div>
`
}

const renderVideos = (i18n) => {
const anchorClass = 'relative overflow-hidden br2 o-70 glow'
const videoWidth = 240
const videoHeight = 180

const overlayDiv = () => html`
<div class="absolute absolute--fill bg-navy o-70"></div>
`

const playSvg = () => html`
<svg class="aspect-ratio--object" x="0px" y="0px" viewBox="-90 -60 ${videoWidth} ${videoHeight}">
<g fill="${colorWhite}">
<polygon points="43,30 23,40 23,20" />
</g>
</svg>
`

return html`
<div class="w-80 flex flex-column flex-row-ns justify-between-ns aqua f5">
<div class="flex flex-column mr1">
<p>${i18n.getMessage('page_landingWelcome_videos_alpha_demo')}</p>
<a class="${anchorClass}" style="height: ${videoHeight}px" href="https://www.youtube.com/watch?feature=player_embedded&v=8CMxDNuuAiQ" target="_blank">
<img width="${videoWidth}" height="${videoHeight}" src="https://ipfs.io/ipfs/zb2rhoo8LXEwek8HLLYsXhra9YuYxRDEun3rHRc18mLvK3A5w" alt="${i18n.getMessage('page_landingWelcome_videos_alpha_demo')}" />
${overlayDiv()}
${playSvg()}
</a>
</div>
<div class="flex flex-column">
<p>${i18n.getMessage('page_landingWelcome_videos_permanent_web')}</p>
<a class="${anchorClass}" style="height: ${videoHeight}px" href="https://www.youtube.com/watch?feature=player_embedded&v=HUVmypx9HGI" target="_blank">
<img width="${videoWidth}" height="${videoHeight}" src="https://ipfs.io/ipfs/zb2rhbCqh6W5Veot1sgZC5v7oLMnrkxq8ikd7auyy9UKSLBBa" alt="${i18n.getMessage('page_landingWelcome_videos_permanent_web')}" />
${overlayDiv()}
${playSvg()}
</a>
</div>
</div>
`
}

const renderProjects = (i18n) => {
const anchorClass = 'flex flex-column items-center navy link hover-aqua'
const logoWidth = 80

return html`
<div class="w-80 mv4 navy f6">
<p class="mb4 aqua f5">${i18n.getMessage('page_landingWelcome_projects_title')}</p>
<div class="flex justify-between-ns">
<a class="${anchorClass}" href="https://multiformats.io/" target="_blank">
<img width="${logoWidth}" src="${multiformatsLogo}" alt="Multiformats Logo">
<p>multiformats.io</p>
</a>
<a class="${anchorClass}" href="https://ipld.io/" target="_blank">
<img width="${logoWidth}" src="${ipldLogo}" alt="IPLD Logo">
<p>ipld.io</p>
</a>
<a class="${anchorClass}" href="https://libp2p.io/" target="_blank">
<img width="${logoWidth}" src="${libp2pLogo}" alt="libp2p Logo">
<p>libp2p.io</p>
</a>
</div>
</div>
`
}

module.exports = createWelcomePage
32 changes: 32 additions & 0 deletions add-on/src/landing-pages/welcome/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict'
/* eslint-env browser, webextensions */

function createWelcomePageStore (i18n, runtime) {
return function welcomePageStore (state, emitter) {
state.isIpfsOnline = null
state.peerCount = null

const port = runtime.connect({ name: 'browser-action-port' })

const onMessage = (message) => {
if (message.statusUpdate) {
const peerCount = message.statusUpdate.peerCount
const isIpfsOnline = peerCount > -1

if (isIpfsOnline !== state.isIpfsOnline || peerCount !== state.peerCount) {
state.isIpfsOnline = isIpfsOnline
state.peerCount = peerCount
emitter.emit('render')
}
}
}

port.onMessage.addListener(onMessage)

emitter.on('DOMContentLoaded', async () => {
emitter.emit('render')
})
}
}

module.exports = createWelcomePageStore
Loading

0 comments on commit 5c7be88

Please sign in to comment.