这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1236f97
Merge pull request #765 from bitfinexcom/staging
prdn Jan 30, 2024
cb297e9
Implement loading placeholder
alexstotsky Jan 19, 2024
bc9f035
Implement shimmering effect
alexstotsky Jan 19, 2024
3dfc584
Update animation background
alexstotsky Jan 19, 2024
a20fe51
Implement loader width randomizer dependent on the base witdh
alexstotsky Jan 22, 2024
c1f7e04
Adjust default color shimmering
alexstotsky Jan 22, 2024
c5f25ba
Update loader styles import
alexstotsky Jan 22, 2024
266c058
Improve loading placeholder sizing
alexstotsky Jan 22, 2024
8b905af
Implement is strong prop handling, upd prop-types
alexstotsky Jan 22, 2024
af4478f
Ceanup
alexstotsky Jan 22, 2024
7e5c87d
Adjust strong and default loaders styling
alexstotsky Jan 22, 2024
3c9860e
Add default and strong placeholders
alexstotsky Jan 22, 2024
e8c61a4
Lint fix and memoize
alexstotsky Jan 22, 2024
546619f
Fix warning
alexstotsky Jan 22, 2024
1658238
Implement preloading state for chart value
alexstotsky Feb 1, 2024
c35db19
Add preloading to chart value percents
alexstotsky Feb 1, 2024
053e705
Rework chart values placheolders
alexstotsky Feb 1, 2024
03c4195
Adjust chart placheolders styling
alexstotsky Feb 1, 2024
c2e50f7
Improve placheolders positioning
alexstotsky Feb 1, 2024
8abe868
Update styling
alexstotsky Feb 1, 2024
2e747de
[wip] Chart data preloading state
alexstotsky Feb 2, 2024
d07298f
Update chart constants
alexstotsky Feb 2, 2024
6f55e1a
Implemented parseChartData handler default state handling
alexstotsky Feb 2, 2024
894d861
Cleanup
alexstotsky Feb 2, 2024
148ce11
Rework account balamce preloading representation
alexstotsky Feb 2, 2024
738f5ee
Adjust paceholder width randomizer to be +-10px
alexstotsky Feb 5, 2024
a437080
Cleanup
alexstotsky Feb 5, 2024
593a364
Lint fix
alexstotsky Feb 5, 2024
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
37 changes: 26 additions & 11 deletions src/components/AppSummary/AppSummary.value.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import _sortBy from 'lodash/sortBy'
import { isEmpty } from '@bitfinex/lib-js-util-base'

import NoData from 'ui/NoData'
import Loading from 'ui/Loading'
import Chart from 'ui/Charts/Chart'
import LoadingPlaceholder from 'ui/LoadingPlaceholder'
import {
parseChartData,
getFormattedChartLastValue,
Expand Down Expand Up @@ -55,21 +55,36 @@ const AccountSummaryValue = () => {
[chartData],
)

const isLoading = !dataReceived && pageLoading

let showContent
if (!dataReceived && pageLoading) {
showContent = <Loading />
} else if (isEmpty(entries)) {
if (!isLoading && isEmpty(entries)) {
showContent = <NoData title='summary.no_data' />
} else {
showContent = (
<div className='chart-wrapper'>
<div className='chart-value'>
$
{chartLastValue}
</div>
<div className='chart-value-perc'>
{formattedPercValue}
</div>
{isLoading ? (
<LoadingPlaceholder
isStrong
height={22}
baseWidth={72}
/>
) : (
<div className='chart-value'>
$
{chartLastValue}
</div>
)}
{isLoading ? (
<LoadingPlaceholder
height={22}
baseWidth={36}
/>
) : (
<div className='chart-value-perc'>
{ formattedPercValue }
</div>
)}
<Chart
aspect={1.455}
data={chartData}
Expand Down
12 changes: 12 additions & 0 deletions src/components/AppSummary/_AppSummary.scss
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,18 @@
color: var(--tableAmountFractionPosColor);;
}
}

.loading-placeholder {
position: absolute;
top: 50px;
left: 15px;
z-index: 1;

&.strong {
top: 23px;
left: 15px;
}
}
}

.line-chart {
Expand Down
24 changes: 15 additions & 9 deletions src/ui/Charts/Charts.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import _isNaN from 'lodash/isNaN'
import _reduce from 'lodash/reduce'
import _values from 'lodash/values'
import _findIndex from 'lodash/findIndex'
import { isEmpty } from '@bitfinex/lib-js-util-base'

import timeframeConstants from 'ui/TimeFrameSelector/constants'

import { CURRENCY_USD } from './constants'
import { CURRENCY_USD, DEFAULT_CHART_DATA } from './constants'

const formatValue = val => val && +val.toFixed(2)

Expand All @@ -38,14 +39,19 @@ const formatTimestamp = (timestamp, timeframe) => {
}

export const parseChartData = ({ data, timeframe }) => {
const chartData = data.map((entry) => {
const { mts } = entry

return {
name: formatTimestamp(mts, timeframe),
[CURRENCY_USD]: formatValue(entry[CURRENCY_USD]),
}
})
let chartData
if (isEmpty(data)) {
chartData = DEFAULT_CHART_DATA
} else {
chartData = data.map((entry) => {
const { mts } = entry

return {
name: formatTimestamp(mts, timeframe),
[CURRENCY_USD]: formatValue(entry[CURRENCY_USD]),
}
})
}

return {
chartData,
Expand Down
12 changes: 12 additions & 0 deletions src/ui/Charts/constants.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
/* eslint-disable-next-line import/prefer-default-export */
export const CURRENCY_USD = 'USD'

export const DEFAULT_CHART_DATA = [
{ name: '-', USD: 0 },
{ name: '-', USD: 0 },
{ name: '-', USD: 0 },
{ name: '-', USD: 0 },
{ name: '-', USD: 0 },
{ name: '-', USD: 0 },
{ name: '-', USD: 0 },
{ name: '-', USD: 0 },
{ name: '-', USD: 0 },
]
25 changes: 25 additions & 0 deletions src/ui/LoadingPlaceholder/LoadingPlaceholder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'

const LoadingPlaceholder = ({ height, baseWidth, isStrong }) => {
const offset = Math.random() > 0.5 ? 10 : -10
const classes = classNames('loading-placeholder', { strong: isStrong })
const placeholderSize = { height: `${height}px`, width: `${(baseWidth + offset)}px` }

return <div className={classes} style={placeholderSize} />
}

LoadingPlaceholder.propTypes = {
height: PropTypes.number,
isStrong: PropTypes.bool,
baseWidth: PropTypes.number,
}

LoadingPlaceholder.defaultProps = {
height: 22,
baseWidth: 80,
isStrong: false,
}

export default memo(LoadingPlaceholder)
29 changes: 29 additions & 0 deletions src/ui/LoadingPlaceholder/_LoadingPlaceholder.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@keyframes shimmer {
0% {
background-position: -200px 0;
}
100% {
background-position: 200px 0;
}
}

.loading-placeholder {
border-radius: 4px;
background: linear-gradient(
to right,
rgba(42, 63, 77, 0.4) 10%,
rgba(255, 255, 255, 0.2) 30%,
rgba(42, 63, 77, 0.8) 60%);
background-size: 200px 100%;
animation: shimmer 2s infinite linear;
}

.strong {
background: linear-gradient(
to right,
rgba(51, 74, 89, 0.5) 10%,
rgba(255, 255, 255, 0.4) 50%,
rgba(51, 74, 89, 1) 100%);
background-size: 200px 100%;
animation: shimmer 2s infinite linear;
}
1 change: 1 addition & 0 deletions src/ui/LoadingPlaceholder/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './LoadingPlaceholder'
1 change: 1 addition & 0 deletions src/ui/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@import "./GoToRange/_GoToRange.scss";
@import "./JSONFormat/_JSONFormat.scss";
@import "./Loading/_Loading.scss";
@import "./LoadingPlaceholder/_LoadingPlaceholder.scss";
@import "./MultiSelect/_MultiSelect.scss";
@import "./NavMenu/_NavMenu.scss";
@import "./NavMenuDrawer/_NavMenuDrawer.scss";
Expand Down