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

Limit the amount of swaps in the Exchange view #445

Merged
merged 3 commits into from
Jul 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion app/locales/en-US/exchange.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"quit": "Quit",
"swaps": {
"all": "All",
"title": "Swaps"
"title": "Recent Swaps",
"viewAllSwaps": "View all swaps"
}
}
21 changes: 19 additions & 2 deletions app/renderer/components/SwapList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import {api} from 'electron-util';
import React from 'react';
import {format as formatDate} from 'date-fns';
import appContainer from 'containers/App';
import tradesContainer from 'containers/Trades';
import Empty from 'components/Empty';
import Link from 'components/Link';
import SwapDetails from 'components/SwapDetails';
import {translate} from '../translate';
import './SwapList.scss';

const t = translate('swap');
const t = translate(['swap', 'exchange']);

// eslint-disable-next-line no-unused-vars
class CancelButton extends React.Component {
Expand Down Expand Up @@ -66,11 +68,15 @@ const SwapItem = ({swap}) => (
</div>
);

const SwapList = ({swaps, showCancel}) => {
const SwapList = ({swaps, limit, showCancel}) => {
if (swaps.length === 0) {
return <Empty show text={t('list.empty')}/>;
}

if (limit) {
swaps = swaps.slice(0, limit);
}

return (
<div className="SwapList">
{
Expand All @@ -82,6 +88,17 @@ const SwapList = ({swaps, showCancel}) => {
/>
))
}
{limit &&
<Link
className="view-all-swaps"
onClick={() => {
appContainer.setActiveView('Trades');
tradesContainer.setActiveView('SwapHistory');
}}
>
{t('swaps.viewAllSwaps')}
</Link>
}
</div>
);
};
Expand Down
9 changes: 9 additions & 0 deletions app/renderer/components/SwapList.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.SwapList {
display: flex;
flex-direction: column;
flex: 1;
overflow-x: hidden;
overflow-y: auto;
Expand Down Expand Up @@ -182,6 +184,13 @@
.cancel :not([disabled]) {
filter: hue-rotate(130deg) saturate(160%);
}

.view-all-swaps {
align-self: center;
margin: 20px 0;
font-size: 14px;
opacity: 0.8;
}
}

@media (min-width: 1400px) {
Expand Down
6 changes: 4 additions & 2 deletions app/renderer/views/Exchange/Swaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import './Swaps.scss';

const t = translate('exchange');

const swapLimit = 50;

const TabButton = props => (
<span
className={
Expand All @@ -31,7 +33,7 @@ const TabView = ({component}) => (
);

const All = () => (
<SwapList swaps={exchangeContainer.state.swapHistory}/>
<SwapList swaps={exchangeContainer.state.swapHistory} limit={swapLimit}/>
);

const Split = () => {
Expand All @@ -43,7 +45,7 @@ const Split = () => {
);

return (
<SwapList swaps={filteredData}/>
<SwapList swaps={filteredData} limit={swapLimit}/>
);
};

Expand Down