Skip to content

Commit

Permalink
components: SearchBar
Browse files Browse the repository at this point in the history
- upgrade react-searchkit 1.0.0-alpha.3
- removed buttonColor, never used, and in case we use it, it has no effect since its overridden by the .ui.input.action.ils-searchbar styles
- subtitle to SearchError as child
- simplified search message when empty results
- closes inveniosoftware#226
  • Loading branch information
topless committed Oct 7, 2020
1 parent 0928e48 commit 2fa5532
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scroll": "^1.7.16",
"react-searchkit": "^1.0.0-alpha.2",
"react-searchkit": "^1.0.0-alpha.3",
"react-show-more": "^2.0.0",
"react-tagcloud": "^2.0.0",
"redux": "^4.0.5",
Expand Down Expand Up @@ -93,7 +93,7 @@
"react-overridable": "^0.0.2",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-searchkit": "^1.0.0-alpha.2",
"react-searchkit": "^1.0.0-alpha.3",
"react-scripts": "^3.4.1",
"react-scroll": "^1.7.16",
"react-show-more": "^2.0.0",
Expand Down
7 changes: 2 additions & 5 deletions src/lib/components/SearchBar/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class SearchBar extends Component {

render() {
const {
buttonColor,
currentQueryString,
executeSearch: parentSearch,
onKeyPressHandler,
Expand All @@ -54,13 +53,13 @@ class SearchBar extends Component {
...otherProps
} = this.props;
const { currentValue } = this.state;
const searchAction = parentSearch || this.executeSearch;
return (
<>
<Input
action={{
color: buttonColor,
icon: 'search',
onClick: parentSearch || this.executeSearch,
onClick: searchAction,
}}
size="big"
fluid
Expand Down Expand Up @@ -91,7 +90,6 @@ class SearchBar extends Component {
}

SearchBar.propTypes = {
buttonColor: PropTypes.string,
executeSearch: PropTypes.func,
currentQueryString: PropTypes.string,
onKeyPressHandler: PropTypes.func,
Expand All @@ -103,7 +101,6 @@ SearchBar.propTypes = {
};

SearchBar.defaultProps = {
buttonColor: null,
currentQueryString: null,
executeSearch: null,
onKeyPressHandler: null,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/modules/SearchControls/ClearButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class ClearButton extends Component {
labelPosition="left"
onClick={clickHandler}
>
<Icon name="undo" />
<Icon name="close" />
{text}
</Button>
);
Expand All @@ -30,7 +30,7 @@ ClearButton.propTypes = {
};

ClearButton.defaultProps = {
text: 'Clear query',
text: 'Clear search',
fluid: false,
disabled: false,
};
2 changes: 1 addition & 1 deletion src/lib/modules/SearchControls/SearchControlsOverrides.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SearchBar from '@components/SearchBar/SearchBar';
import { SearchBar } from '@components/SearchBar';
import { MenuBucketAggregationValueElementOverrides } from '@modules/SearchControls/overridden/MenuBucketAggregationElement';
import { AvailableLoanBucketAggregationValues } from './overridden/AvailableLoanBucketAggregationValues';
import { AvailableLoanBucketAggregationElement } from './overridden/AvailableLoanBucketAggregationElement';
Expand Down
16 changes: 7 additions & 9 deletions src/lib/modules/SearchControls/SearchEmptyResults.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Segment } from 'semantic-ui-react';
import { Header, Segment } from 'semantic-ui-react';
import ClearButton from '@modules/SearchControls/ClearButton';
import { SearchMessage } from '@modules/SearchControls/SearchMessage';

export default class SearchEmptyResults extends Component {
render() {
const { queryString, resetQuery, extraContent } = this.props;
const currentSearch = `Current search "${queryString}"`;
return (
<SearchMessage title="No results found!" icon="search">
<SearchMessage title="No results found searching for" icon="search">
{queryString && (
<>
<div className="empty-results-current">{currentSearch}</div>
<Segment.Inline>
<ClearButton clickHandler={resetQuery} /> {extraContent}
</Segment.Inline>
</>
<Segment.Inline>
<Header as="h1">{queryString}</Header>
<ClearButton clickHandler={resetQuery} />
{extraContent}
</Segment.Inline>
)}
</SearchMessage>
);
Expand Down
13 changes: 8 additions & 5 deletions src/lib/modules/SearchControls/SearchError.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import _get from 'lodash/get';
import { Header } from 'semantic-ui-react';
import { EmailLink } from '@components/EmailLink';
import { invenioConfig } from '@config';
import { SearchMessage } from '@modules/SearchControls/SearchMessage';
Expand All @@ -18,11 +19,13 @@ export const SearchError = ({ error }) => {
title="Something went wrong while fetching results."
icon="warning"
>
Please try again later. If the problem persists,{' '}
<EmailLink email={invenioConfig.APP.supportEmail}>
contact the technical support
</EmailLink>
.
<Header.Subheader>
Please try again later. If the problem persists,{' '}
<EmailLink email={invenioConfig.APP.supportEmail}>
contact the technical support
</EmailLink>
.
</Header.Subheader>
</SearchMessage>
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/modules/SearchControls/SearchMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ export const SearchMessage = ({ title, icon, children }) => (
{icon && <Icon name={icon} />}
{title}
</Header>
{children && <Header.Subheader>{children}</Header.Subheader>}
{children}
</Segment>
);

SearchMessage.propTypes = {
title: PropTypes.string.isRequired,
children: PropTypes.node,
icon: PropTypes.string,
title: PropTypes.string.isRequired,
};

SearchMessage.defaultProps = {
icon: null,
children: null,
icon: null,
};

0 comments on commit 2fa5532

Please sign in to comment.