generated from rohberg/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Isolate SearchBarSection. Hide delete button if querystring empty
- Loading branch information
Showing
3 changed files
with
57 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useIntl } from 'react-intl'; | ||
import { Icon as IconSemantic } from 'semantic-ui-react'; | ||
import { onQueryChanged, SearchBar, withState } from 'react-searchkit'; | ||
|
||
import messages from '../../messages'; | ||
|
||
const _SearchBarSection = (props) => { | ||
const intl = useIntl(); | ||
|
||
const payloadOfReset = { | ||
searchQuery: { | ||
sortBy: 'bestmatch', | ||
sortOrder: 'asc', | ||
layout: 'list', | ||
page: 1, | ||
size: 10, | ||
queryString: '', | ||
}, | ||
}; | ||
|
||
const onResetHandler = (event) => { | ||
onQueryChanged(payloadOfReset); | ||
}; | ||
|
||
return ( | ||
<div className="searchbar-wrapper"> | ||
<SearchBar | ||
placeholder={' '} | ||
autofocus="false" | ||
uiProps={{ | ||
icon: 'search', | ||
iconPosition: 'left', | ||
}} | ||
actionProps={{ | ||
content: intl.formatMessage(messages.search), | ||
}} | ||
/> | ||
<IconSemantic | ||
basic="true" | ||
icon="true" | ||
name="delete" | ||
className={ | ||
props.currentQueryState.queryString.length ? 'selected' : 'unselected' | ||
} | ||
onClick={(event) => onResetHandler(event)} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default withState(_SearchBarSection); |
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 |
---|---|---|
|
@@ -54,6 +54,9 @@ | |
color: #fff; | ||
font-size: 1.2rem; | ||
font-weight: 700; | ||
&.unselected { | ||
opacity: 0; | ||
} | ||
} | ||
} | ||
|
||
|