-
Notifications
You must be signed in to change notification settings - Fork 943
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1277 from sharetribe/sort-search-results
Sort search results
- Loading branch information
Showing
14 changed files
with
611 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import { string, bool } from 'prop-types'; | ||
import { intlShape, injectIntl } from '../../util/reactIntl'; | ||
|
||
import config from '../../config'; | ||
|
||
import SortByPlain from './SortByPlain'; | ||
import SortByPopup from './SortByPopup'; | ||
|
||
const SortBy = props => { | ||
const { sort, showAsPopup, isKeywordFilterActive, intl, ...rest } = props; | ||
|
||
const { relevanceKey } = config.custom.sortConfig; | ||
|
||
const options = config.custom.sortConfig.options.map(option => { | ||
const isRelevance = option.key === relevanceKey; | ||
return { | ||
...option, | ||
disabled: (isRelevance && !isKeywordFilterActive) || (!isRelevance && isKeywordFilterActive), | ||
}; | ||
}); | ||
const defaultValue = 'createdAt'; | ||
const componentProps = { | ||
urlParam: 'sort', | ||
label: intl.formatMessage({ id: 'SortBy.heading' }), | ||
options, | ||
initialValue: isKeywordFilterActive ? relevanceKey : sort || defaultValue, | ||
...rest, | ||
}; | ||
return showAsPopup ? <SortByPopup {...componentProps} /> : <SortByPlain {...componentProps} />; | ||
}; | ||
|
||
SortBy.defaultProps = { | ||
sort: null, | ||
showAsPopup: false, | ||
}; | ||
|
||
SortBy.propTypes = { | ||
sort: string, | ||
showAsPopup: bool, | ||
isKeywordFilterActive: bool.isRequired, | ||
intl: intlShape.isRequired, | ||
}; | ||
|
||
export default injectIntl(SortBy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
@import '../../marketplace.css'; | ||
|
||
.root { | ||
padding-top: 24px; | ||
padding-bottom: 17px; | ||
border-bottom: 1px solid var(--matterColorNegative); | ||
} | ||
|
||
.filterLabel, | ||
.filterLabelSelected { | ||
@apply --marketplaceH3FontStyles; | ||
|
||
/* Baseline adjustment for label text */ | ||
margin-top: 0; | ||
margin-bottom: 12px; | ||
padding: 4px 0 2px 0; | ||
} | ||
|
||
.filterLabel { | ||
color: var(--matterColorDark); | ||
} | ||
|
||
.filterLabelSelected { | ||
color: var(--marketplaceColor); | ||
} | ||
|
||
.labelButton { | ||
/* Override button styles */ | ||
outline: none; | ||
text-align: left; | ||
border: none; | ||
padding: 0; | ||
cursor: pointer; | ||
} | ||
|
||
.optionsContainerOpen { | ||
height: auto; | ||
padding-bottom: 30px; | ||
} | ||
|
||
.optionsContainerClosed { | ||
height: 0; | ||
overflow: hidden; | ||
} | ||
|
||
.optionBorder, | ||
.optionBorderSelected { | ||
position: absolute; | ||
height: calc(100% - 12px); | ||
top: 4px; | ||
left: -24px; | ||
transition: width var(--transitionStyleButton); | ||
} | ||
|
||
/* left animated "border" like hover element */ | ||
.optionBorder { | ||
width: 0; | ||
background-color: var(--matterColorDark); | ||
} | ||
|
||
/* left static border for selected element */ | ||
.optionBorderSelected { | ||
width: 8px; | ||
background-color: var(--matterColorDark); | ||
} | ||
|
||
.option { | ||
@apply --marketplaceH4FontStyles; | ||
font-weight: var(--fontWeightMedium); | ||
font-size: 18px; | ||
color: var(--matterColor); | ||
|
||
/* Layout */ | ||
display: block; | ||
position: relative; | ||
margin: 0; | ||
padding: 4px 0 8px 20px; | ||
|
||
/* Override button styles */ | ||
outline: none; | ||
border: none; | ||
cursor: pointer; | ||
|
||
&:focus, | ||
&:hover { | ||
color: var(--matterColorDark); | ||
} | ||
|
||
&:hover .menuItemBorder { | ||
width: 6px; | ||
} | ||
|
||
&:disabled { | ||
color: var(--matterColorAnti); | ||
cursor: default; | ||
} | ||
} | ||
|
||
.optionSelected { | ||
composes: option; | ||
color: var(--matterColorDark); | ||
} |
Oops, something went wrong.