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

(improvement) Columns filter representation #697

Merged
merged 32 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e9d3133
Merge pull request #696 from bitfinexcom/staging
prdn Aug 23, 2023
5ac8d50
Add plus icon for cols filter
Aug 21, 2023
f79c196
Adjust icon size
Aug 21, 2023
a2d37e8
Update filters keys/descriptions
Aug 21, 2023
4e1881d
Improve cols-filter btn styling
Aug 21, 2023
133ffb0
Add and adjust columns filter icon
Aug 21, 2023
ff46e7c
Adjust filter field styling and positioning
Aug 21, 2023
87f79d5
Fix unused intent import
Aug 21, 2023
a6142e5
Update translations
Aug 21, 2023
ea1c6ee
[wip] Dynamic filters titles
Aug 21, 2023
05e5509
Adds columns filter helpers
Aug 21, 2023
8075d1c
Improve filter section title handling, cleanup
Aug 21, 2023
0d0cc0b
Clean outdated classnames
Aug 21, 2023
5ce1921
Improve getFiltersTitle helper
Aug 21, 2023
aa6bee8
lint fix
Aug 22, 2023
b6db685
Extract getActiveFilters for better reusability
Aug 22, 2023
99cbd0b
Adjust filters input
Aug 22, 2023
5e3cd01
Implement filters styling helper
Aug 22, 2023
3e92e67
Update cols no filter case representation
Aug 22, 2023
5e31a2c
Imlement dynamic filters styling
Aug 22, 2023
9690def
Adjust time range representation
Aug 22, 2023
8675939
Actualize selectors active state styling
Aug 22, 2023
43237c6
Improve multi-select representation
Aug 22, 2023
af081e0
Update columns filters active states styling
Aug 22, 2023
2da17dc
Rework refresh btn component
Aug 22, 2023
37da30e
Fix select representation on mobiles
Aug 22, 2023
5d71b47
Actualize refresh button styling
Aug 22, 2023
7946aab
Adjust cols filter dialog spacing
Aug 22, 2023
cfa7f69
Rework and optimize refresh btn
Aug 22, 2023
e34f84b
Outdated component cleanup
Aug 22, 2023
9902fe0
Actualize refresh btn export
Aug 22, 2023
e322c2b
Optimize index
Aug 23, 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
2 changes: 2 additions & 0 deletions public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@
"clear": "Clear",
"cancel": "Cancel",
"apply": "Apply",
"none": "None",
"filters": {
"title": "Filters",
"contains": "Contains",
"beginsWith": "Begins with",
"endsWith": "Ends with",
Expand Down
2 changes: 2 additions & 0 deletions src/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { ReactComponent as NOTEBOOK } from './notebook.svg'
import { ReactComponent as OFFLINE } from './offline.svg'
import { ReactComponent as ORDERS } from './orders.svg'
import { ReactComponent as PIE_CHART } from './pie-chart.svg'
import { ReactComponent as PLUS } from './plus.svg'
import { ReactComponent as PLUS_CIRCLE } from './plus-circle.svg'
import { ReactComponent as REFRESH_DOUBLE } from './refresh-double.svg'
import { ReactComponent as SEARCH } from './search.svg'
Expand Down Expand Up @@ -98,6 +99,7 @@ export default {
OFFLINE,
ORDERS,
PIE_CHART,
PLUS,
PLUS_CIRCLE,
REFRESH_DOUBLE,
SEARCH,
Expand Down
3 changes: 3 additions & 0 deletions src/icons/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions src/ui/ColumnsFilter/ColumnsFilter.helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import _size from 'lodash/size'
import _filter from 'lodash/filter'
import _isEmpty from 'lodash/isEmpty'
import _toString from 'lodash/toString'

const getActiveFilters = (filters) => _filter(
filters, filter => !_isEmpty(_toString(filter?.value ?? '')),
)

export const getFiltersClassNames = (filters) => {
const activeFilters = getActiveFilters(filters)
return _size(activeFilters) > 0 ? '' : 'no-filters'
}

export const getFiltersTitle = (filters, t) => {
if (_size(filters) > 0) {
const activeFilters = getActiveFilters(filters)
const filtersTitle = _size(activeFilters) > 1
? t('columnsfilter.filters.title')
: t('columnsfilter.title')

return _size(activeFilters) > 0
? `${_size(activeFilters)} ${filtersTitle}`
: t('columnsfilter.none')
}

return t('columnsfilter.none')
}

export default {
getFiltersTitle,
getFiltersClassNames,
}
19 changes: 9 additions & 10 deletions src/ui/ColumnsFilter/ColumnsFilter.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { PureComponent } from 'react'
import { withTranslation } from 'react-i18next'
import classNames from 'classnames'
import {
Button,
InputGroup,
Intent,
} from '@blueprintjs/core'
import _isEqual from 'lodash/isEqual'
import _isString from 'lodash/isString'


import ColumnsSelect from 'ui/ColumnsSelect'
import DateInput from 'ui/DateInput'
import Icon from 'icons'
Expand All @@ -25,6 +24,7 @@ import { propTypes, defaultProps } from './ColumnsFilter.props'
import { FILTERS_SELECTOR } from './ColumnSelector/ColumnSelector.columns'
import SideSelector from './Selectors/SideSelector'
import WalletSelector from './Selectors/WalletSelector'
import { getFiltersTitle, getFiltersClassNames } from './ColumnsFilter.helpers'

const MAX_FILTERS = 7
const { DATE } = DATA_TYPES
Expand Down Expand Up @@ -200,18 +200,17 @@ class ColumnsFilter extends PureComponent {
const { isOpen, filters } = this.state

const hasChanges = this.haveFiltersChanged()
const hasAppliedFilters = currentFilters.some(filter => filter.value)
const buttonClasses = classNames('button--large', { 'columns-filter--active': hasAppliedFilters })
const filtersTitle = getFiltersTitle(currentFilters, t)
const filtersClassName = getFiltersClassNames(currentFilters)

return (
<>
<div className='columns-filter-wrapper'>
<Button
onClick={this.toggleDialog}
className={buttonClasses}
intent={Intent.SUCCESS}
>
{t('columnsfilter.title')}
<Button onClick={this.toggleDialog}>
<span className={filtersClassName}>
{filtersTitle}
</span>
<Icon.PLUS />
</Button>
</div>

Expand Down
27 changes: 24 additions & 3 deletions src/ui/ColumnsFilter/_ColumnsFilter.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@

.bp3-button {
height: 34px;
min-width: 95px;
min-width: 133px;
font-size: 14px;
background-color: var(--multiBg);
border: none;

&:active, &:hover {
border: none;
}

&-text {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;

.no-filters {
color: var(--color2);
}
}
}
}

Expand Down Expand Up @@ -68,8 +85,8 @@
margin-right: 13px;

.bp3-input {
height: 40px;
line-height: 40px;
height: 33px;
line-height: 33px;
}

&--select {
Expand Down Expand Up @@ -164,6 +181,10 @@

@media screen and (max-width: 576px) {
.columns-filter {
&-dialog {
min-width: 100%;
}

&-item {
max-width: 380px;
padding: 30px 0;
Expand Down
3 changes: 2 additions & 1 deletion src/ui/MultiSelect/_MultiSelect.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
&.bp3-input {
box-shadow: none;
background-color: var(--multiBg);
border: 1px solid var(--borderColor);
border: none;
}

&-arrow {
position: absolute;
top: 5px;
right: 8px;
cursor: pointer;
}

input {
Expand Down
27 changes: 12 additions & 15 deletions src/ui/RefreshButton/RefreshButton.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import React from 'react'
import { withTranslation } from 'react-i18next'
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import { useTranslation } from 'react-i18next'
import { Button, Intent } from '@blueprintjs/core'

import Icon from 'icons'
import Tooltip from 'ui/Tooltip'

const RefreshButton = (props) => {
const { onClick, t } = props
const RefreshButton = ({ onClick }) => {
const { t } = useTranslation()

return (
<Tooltip
content={t('timeframe.refresh')}
usePortal={false}
targetClassName='refresh-button'
<Button
onClick={onClick}
intent={Intent.SUCCESS}
className='refresh-button'
>
<Icon.REFRESH_DOUBLE onClick={onClick} />
</Tooltip>
{t('columnsfilter.title')}
</Button>
)
}

RefreshButton.propTypes = {
onClick: PropTypes.func.isRequired,
t: PropTypes.func.isRequired,
}

export default withTranslation('translations')(RefreshButton)
export default memo(RefreshButton)
15 changes: 2 additions & 13 deletions src/ui/RefreshButton/_RefreshButton.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
.refresh-button {
height: 24px;
height: 34px;
min-width: 74px;
cursor: pointer;
}

@media screen and (min-width: 2560px) {
.refresh-button {
height: 28px;
margin-bottom: 10px;

svg {
width: 28px;
height: 28px;
}
}
}
4 changes: 1 addition & 3 deletions src/ui/RefreshButton/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import RefreshButton from './RefreshButton'

export default RefreshButton
export { default } from './RefreshButton'
34 changes: 33 additions & 1 deletion src/ui/Select/_Select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,46 @@
padding-right: 8px;
background-color: var(--multiBg);
color: var(--color);
border: 1px solid var(--borderColor);
border: none;
box-shadow: none;
justify-content: space-between;

&:active, &:hover {
border: none;
}
}

&--language .bp3-button {
width: 140px;

&:active, &:hover {
border: none;
}
}

&--balance-precision .bp3-button {
width: 150px;

&:active, &:hover {
border: none;
}
}

&--unrealized-profit .bp3-button {
width: 160px;

&:active, &:hover {
border: none;
}
}

&--report-type .bp3-button {
width: fit-content;

&:active, &:hover {
border: none;
}

.bp3-button-text {
display: flex;
align-items: center;
Expand All @@ -39,6 +59,10 @@

&--timeframe .bp3-button {
width: 100px;

&:active, &:hover {
border: none;
}
}

&-menu {
Expand Down Expand Up @@ -320,6 +344,14 @@
}
}

@media screen and (max-width: 576px) {
.bitfinex-select {
.bp3-button {
min-width: fit-content;
}
}
}

@media screen and (max-width: 390px) {
.bitfinex-select {
.bp3-button {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/TimeRange/_TimeRange.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
vertical-align: middle;
color: var(--timeRangeColor);
background-color: var(--multiBg);
border: 1px solid var(--borderColor);
border-radius: 4px;
min-height: 34px;

svg {
margin-left: 10px;
Expand Down