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

(feature) App download section #657

Merged
merged 31 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2323943
Add platforms constants
May 22, 2023
3571a2f
Implement getOS utility
May 22, 2023
c3fbd7c
Improve checks, update default export
May 22, 2023
2e3f606
Add electron versions config
May 22, 2023
e0566f1
Improve app versions config
May 22, 2023
74886b5
Add download app section keys and descriptions
May 22, 2023
b336c86
Add nav column styling
May 23, 2023
a8eba52
Add app dowload card and column wrapper
May 23, 2023
85ed7dc
Implement optional dowload app card rendering only for the web
May 23, 2023
11d36c6
[wip] App download component
May 23, 2023
45ec118
Fix app download url const
May 23, 2023
d46e73b
Add app download card to tne main
May 23, 2023
410a6df
Update export
May 23, 2023
a3ac381
Update default dev config
May 23, 2023
2490eef
Rework and improve app download component
May 24, 2023
8965b88
Update styles import
May 24, 2023
74bbcc0
Add download card title
May 24, 2023
2c1e4d9
App download styling
May 24, 2023
722d2ed
Improve app version naming, cleanup
May 24, 2023
901964d
Adjust nav menu width
May 24, 2023
acbe492
Add subtitle
May 24, 2023
e3bc0a5
Update styling and spacing
May 24, 2023
cff9d81
Add features list, update button
May 24, 2023
3c240d9
Add features list styling
May 24, 2023
40ad1af
Update download btn title
May 24, 2023
88c17a7
Update cards components styling
May 24, 2023
9a7b6db
Unused vars cleanup, lint fix
May 24, 2023
cd93f26
Implement getDownloadLink helper
May 25, 2023
992875c
Optimize app download, cleanup
May 25, 2023
31a3258
Memoize generated link
May 25, 2023
17672b0
Lint fix
May 25, 2023
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
10 changes: 10 additions & 0 deletions public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@
"averagewinloss": {
"title": "Average Win/Loss"
},
"download_app": {
"title": "Get the ultimate reporting experience with our desktop app",
"description": "Gain access to advanced features that will supercharge your data analysis.",
"risk": "Concentration Risk",
"win_loss": "Win/Loss Streaks",
"tax": "Tax Reports",
"snapshots": "Snapshots",
"more": "And more...",
"download_reports": "Download Bitfinex Reports"
},
"candles": {
"title": "Candles",
"amount": "Amount",
Expand Down
20 changes: 20 additions & 0 deletions src/components/AppDownload/AppDownload.helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import config from 'var/electronVersion'
import { getOS, PLATFORMS } from 'utils/getOS'

const { getElectronReleaseLink } = config

export const getDownloadLink = (version) => {
const platform = getOS()

switch (platform) {
case PLATFORMS.mac:
return getElectronReleaseLink({ version, platform, ext: 'zip' })
case PLATFORMS.windows:
return getElectronReleaseLink({ version, platform, ext: 'exe' })
case PLATFORMS.linux:
default:
return getElectronReleaseLink({ version, platform, ext: 'AppImage.zip' })
}
}

export default getDownloadLink
64 changes: 64 additions & 0 deletions src/components/AppDownload/AppDownload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React, { useState, useEffect, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { Button, Intent } from '@blueprintjs/core'

import config from 'var/electronVersion'

import getDownloadLink from './AppDownload.helpers'

const {
DEFAULT_ELECTRON_VERSION,
LATEST_ELECTRON_RELEASE_LINK,
} = config

const AppDownload = () => {
const { t } = useTranslation()
const [isLoading, setIsLoading] = useState(true)
const [latestAppVersion, setLatestAppVersion] = useState(DEFAULT_ELECTRON_VERSION)

useEffect(() => {
const fetchData = async () => {
const data = await fetch(LATEST_ELECTRON_RELEASE_LINK)
const json = await data.json()
const latestVersion = json?.tag_name
if (latestVersion) {
setLatestAppVersion(latestVersion)
}
setIsLoading(false)
}
fetchData()
}, [])

const link = useMemo(
() => getDownloadLink(latestAppVersion),
[latestAppVersion],
)

return (
<div className='app-download'>
<h2 className='app-download--title'>
{t('download_app.title')}
</h2>
<h3 className='app-download--sub-title'>
{t('download_app.description')}
</h3>
<ul className='app-download--list'>
<li>{t('download_app.risk')}</li>
<li>{t('download_app.win_loss')}</li>
<li>{t('download_app.tax')}</li>
<li>{t('download_app.snapshots')}</li>
<li>{t('download_app.more')}</li>
</ul>
<Button
loading={isLoading}
intent={Intent.SUCCESS}
className='app-download--btn'
onClick={() => window.open(link)}
>
{t('download_app.download_reports')}
</Button>
</div>
)
}

export default AppDownload
38 changes: 38 additions & 0 deletions src/components/AppDownload/_AppDownload.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.app-download {
padding: 24px;

&--title {
margin: 0;
font-size: 16px;
max-width: 240px;
margin-bottom: 6px;
}

&--sub-title {
margin: 0;
font-size: 14px;
max-width: 240px;
color: var(--color2);
margin-bottom: 15px;
}

&--list {
padding-left: 20px;

li {
font-size: 14px;
color: var(--color2);
padding-bottom: 6px;
}
}

&--btn {
min-height: 40px;
padding: 5px 20px;

.bp3-button-text {
font-size: 15px;
font-weight: 700;
}
}
}
1 change: 1 addition & 0 deletions src/components/AppDownload/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './AppDownload'
14 changes: 11 additions & 3 deletions src/components/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
import { Route, Switch } from 'react-router-dom'
import { Card } from '@blueprintjs/core'

import AppDownload from 'components/AppDownload'
import AccountBalance from 'components/AccountBalance'
import AccountSummary from 'components/AccountSummary'
import AffiliatesEarnings from 'components/AffiliatesEarnings'
Expand Down Expand Up @@ -148,9 +149,16 @@ class Main extends PureComponent {

return authStatus && !authIsShown ? (
<>
<Card className='nav-menu-card'>
<NavMenu className='bitfinex-nav-menu--main' />
</Card>
<div className='nav-menu'>
<Card className='nav-menu-card'>
<NavMenu className='bitfinex-nav-menu--main' />
</Card>
{!showFrameworkMode && (
<Card className='nav-menu-card app-download'>
<AppDownload />
</Card>
)}
</div>
<div className='bitfinex-dataset'>
<Switch>
<Route
Expand Down
21 changes: 14 additions & 7 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
@import './popover.scss';
@import './radio.scss';

@import "components/AccountSummary/_AccountSummary.scss";
@import "components/Auth/_Auth.scss";
@import "components/AccountSummary/_AccountSummary.scss";
@import "components/AppDownload/_AppDownload.scss";
@import "components/Candles/_Candles.scss";
@import "components/ConcentrationRisk/_ConcentrationRisk.scss";
@import "components/ErrorDialog/_ErrorDialog.scss";
Expand Down Expand Up @@ -73,12 +74,18 @@ html {
}
}

.nav-menu-card {
padding: 0;
margin: 10px 10px 10px 20px;
background-color: var(--bgColor2);
border-radius: 10px;
overflow: hidden;
.nav-menu {
display: flex;
flex-direction: column;

&-card {
padding: 0;
height: auto;
overflow: hidden;
border-radius: 10px;
margin: 10px 10px 10px 20px;
background-color: var(--bgColor2);
}
}

.bitfinex-dataset {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/NavMenu/_NavMenu.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.bitfinex-nav-menu {
display: inline-block;
width: 282px;
width: 290px;
padding: 0;
border-radius: 0;
clip-path: inset(0 -1px 0 0);
Expand Down
29 changes: 29 additions & 0 deletions src/utils/getOS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import _includes from 'lodash/includes'
import _isUndefined from 'lodash/isUndefined'

export const PLATFORMS = {
mac: 'mac',
windows: 'win',
linux: 'linux',
}

export const getOS = () => {
if (_isUndefined(typeof window)) {
return null
}

const { userAgent } = window.navigator

if (_includes(userAgent, 'Win')) {
return PLATFORMS.windows
}
if (_includes(userAgent, 'Mac')) {
return PLATFORMS.mac
}
return PLATFORMS.linux
}

export default {
getOS,
PLATFORMS,
}
20 changes: 20 additions & 0 deletions src/var/electronVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import _replace from 'lodash/replace'

const DEFAULT_ELECTRON_VERSION = '3.0.1'

const APP_RELEASES_URL = 'https://github.com/bitfinexcom/bfx-report-electron/releases/download/'

const config = {
GITHUB_LINK: 'https://github.com/bitfinexcom/bfx-report-electron',
LATEST_ELECTRON_RELEASE_LINK: 'https://api.github.com/repos/bitfinexcom/bfx-report-electron/releases/latest',
DEFAULT_ELECTRON_VERSION,
getElectronReleaseLink: ({ version, platform, ext = 'zip' }) => {
const currExt = version === DEFAULT_ELECTRON_VERSION
? 'zip'
: ext

return `${APP_RELEASES_URL}/${version}/BitfinexReport-${_replace(version, 'v', '')}-x64-${platform}.${currExt}`
},
}

export default config