Skip to content
Browse files

No Hits component

  • Loading branch information...
1 parent 025fd14 commit 6ec6ad9b22a77a49913ed286bba99b999973356e @joemcelroy joemcelroy committed
View
1 lib/src/components/index.d.ts
@@ -5,6 +5,7 @@ export * from "./search/filters/selected-filters/src/SelectedFilters";
export * from "./search/filters/hierarchical-menu-filter/src/HierarchicalMenuFilter";
export * from "./search/filters/numeric-refinement-list-filter/src/NumericRefinementListFilter";
export * from "./search/hits/src/Hits";
+export * from "./search/hits/src/NoHits";
export * from "./search/hits-stats/src/HitsStats";
export * from "./search/pagination/src/Pagination";
export * from "./search/search-box/src/SearchBox";
View
1 lib/src/components/index.js
@@ -8,6 +8,7 @@ __export(require("./search/filters/selected-filters/src/SelectedFilters"));
__export(require("./search/filters/hierarchical-menu-filter/src/HierarchicalMenuFilter"));
__export(require("./search/filters/numeric-refinement-list-filter/src/NumericRefinementListFilter"));
__export(require("./search/hits/src/Hits"));
+__export(require("./search/hits/src/NoHits"));
__export(require("./search/hits-stats/src/HitsStats"));
__export(require("./search/pagination/src/Pagination"));
__export(require("./search/search-box/src/SearchBox"));
View
2 lib/src/components/index.js.map
@@ -1 +1 @@
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,iBAAc,6CAA6C,CAAC,EAAA;AAC5D,iBAAc,kEAAkE,CAAC,EAAA;AACjF,iBAAc,iDAAiD,CAAC,EAAA;AAChE,iBAAc,uDAAuD,CAAC,EAAA;AACtE,iBAAc,sEAAsE,CAAC,EAAA;AACrF,iBAAc,iFAAiF,CAAC,EAAA;AAChG,iBAAc,wBAAwB,CAAC,EAAA;AACvC,iBAAc,mCAAmC,CAAC,EAAA;AAClD,iBAAc,oCAAoC,CAAC,EAAA;AACnD,iBAAc,mCAAmC,CAAC,EAAA;AAClD,iBAAc,+CAA+C,CAAC,EAAA;AAC9D,iBAAc,kFAAkF,CAAC,EAAA"}
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,iBAAc,6CAA6C,CAAC,EAAA;AAC5D,iBAAc,kEAAkE,CAAC,EAAA;AACjF,iBAAc,iDAAiD,CAAC,EAAA;AAChE,iBAAc,uDAAuD,CAAC,EAAA;AACtE,iBAAc,sEAAsE,CAAC,EAAA;AACrF,iBAAc,iFAAiF,CAAC,EAAA;AAChG,iBAAc,wBAAwB,CAAC,EAAA;AACvC,iBAAc,0BAA0B,CAAC,EAAA;AACzC,iBAAc,mCAAmC,CAAC,EAAA;AAClD,iBAAc,oCAAoC,CAAC,EAAA;AACnD,iBAAc,mCAAmC,CAAC,EAAA;AAClD,iBAAc,+CAA+C,CAAC,EAAA;AAC9D,iBAAc,kFAAkF,CAAC,EAAA"}
View
1 lib/src/components/search/hits/src/Hits.d.ts
@@ -13,6 +13,5 @@ export declare class Hits extends SearchkitComponent<HitsProps, any> {
};
renderResult(result: any): JSX.Element;
renderInitialView(): JSX.Element;
- renderNoResults(): JSX.Element;
render(): JSX.Element;
}
View
6 lib/src/components/search/hits/src/Hits.js
@@ -34,9 +34,6 @@ var Hits = (function (_super) {
Hits.prototype.renderInitialView = function () {
return (React.createElement("div", {"data-qa": "initial-loading", "className": this.bemBlocks.container("initial-loading")}));
};
- Hits.prototype.renderNoResults = function () {
- return (React.createElement("div", {"data-qa": "no-results", "className": this.bemBlocks.container("no-results")}, this.translate("No results")));
- };
Hits.prototype.render = function () {
var hits = this.getHits();
var hasHits = hits.length > 0;
@@ -44,9 +41,6 @@ var Hits = (function (_super) {
if (this.isInitialLoading()) {
results = this.renderInitialView();
}
- else if (!hasHits) {
- results = this.renderNoResults();
- }
else {
results = _.map(hits, this.renderResult.bind(this));
}
View
2 lib/src/components/search/hits/src/Hits.js.map
@@ -1 +1 @@
-{"version":3,"file":"Hits.js","sourceRoot":"","sources":["../../../../../../src/components/search/hits/src/Hits.tsx"],"names":["Hits","Hits.constructor","Hits.componentWillMount","Hits.defineAccessor","Hits.defineBEMBlocks","Hits.renderResult","Hits.renderInitialView","Hits.renderNoResults","Hits.render"],"mappings":";;;;;AAAA,IAAY,CAAC,WAAM,QAAQ,CAAC,CAAA;AAC5B,IAAY,KAAK,WAAM,OAAO,CAAC,CAAA;AAC/B,QAAO,sBAAsB,CAAC,CAAA;AAE9B,qBAMO,kBAEP,CAAC,CAFwB;AAOzB;IAA0BA,wBAAkCA;IAA5DA;QAA0BC,8BAAkCA;IAoE5DA,CAACA;IA1DAD,iCAAkBA,GAAlBA;QACCE,gBAAKA,CAACA,kBAAkBA,WAAEA,CAAAA;QAC1BA,EAAEA,CAAAA,CAACA,IAAIA,CAACA,KAAKA,CAACA,eAAeA,CAACA,CAACA,CAACA;YAC/BA,IAAIA,CAACA,SAASA,CAACA,WAAWA,CACzBA,IAAIA,wBAAiBA,CAACA,IAAIA,CAACA,KAAKA,CAACA,eAAeA,CAACA,CAACA,CAAAA;QACpDA,CAACA;IACFA,CAACA;IAEDF,6BAAcA,GAAdA;QACCG,MAAMA,CAACA,IAAIA,uBAAgBA,CAACA,IAAIA,CAACA,KAAKA,CAACA,WAAWA,CAACA,CAAAA;IACpDA,CAACA;IAEDH,8BAAeA,GAAfA;QACCI,IAAIA,KAAKA,GAAGA,CAACA,IAAIA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,MAAMA,CAACA,CAAAA;QACtCA,MAAMA,CAACA;YACNA,SAASA,EAAEA,KAAKA;YAChBA,IAAIA,EAAKA,KAAKA,SAAMA;SACpBA,CAAAA;IACFA,CAACA;IAEDJ,2BAAYA,GAAZA,UAAaA,MAAUA;QACtBK,MAAMA,CAACA,CACNA,qBAACA,GAAGA,KAACA,OAAOA,GAACA,KAAKA,GAACA,SAASA,GAAEA,IAAIA,CAACA,SAASA,CAACA,IAAIA,EAAEA,CAACA,GAAGA,CAACA,IAAIA,CAACA,SAASA,CAACA,SAASA,CAACA,MAAMA,CAACA,CAAEA,GAACA,GAAGA,GAAEA,MAAMA,CAACA,GAAIA,EACrGA,CACNA,CAAAA;IACFA,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A,OAAQA,CACDA,CACTA,CAACA;IACHA,CAACA;IAjEMR,cAASA,GAAGA,CAACA,CAACA,QAAQA,CAACA;QAC7BA,WAAWA,EAACA,KAAKA,CAACA,SAASA,CAACA,MAAMA,CAACA,UAAUA;QAC7CA,eAAeA,EAACA,KAAKA,CAACA,SAASA,CAACA,OAAOA,CACtCA,KAAKA,CAACA,SAASA,CAACA,MAAMA,CACtBA;KACDA,EAAEA,yBAAkBA,CAACA,SAASA,CAACA,CAAAA;IA6DjCA,WAACA;AAADA,CAACA,AApED,EAA0B,yBAAkB,EAoE3C;AApEY,YAAI,OAoEhB,CAAA"}
+{"version":3,"file":"Hits.js","sourceRoot":"","sources":["../../../../../../src/components/search/hits/src/Hits.tsx"],"names":["Hits","Hits.constructor","Hits.componentWillMount","Hits.defineAccessor","Hits.defineBEMBlocks","Hits.renderResult","Hits.renderInitialView","Hits.render"],"mappings":";;;;;AAAA,IAAY,CAAC,WAAM,QAAQ,CAAC,CAAA;AAC5B,IAAY,KAAK,WAAM,OAAO,CAAC,CAAA;AAC/B,QAAO,sBAAsB,CAAC,CAAA;AAE9B,qBAMO,kBAEP,CAAC,CAFwB;AAOzB;IAA0BA,wBAAkCA;IAA5DA;QAA0BC,8BAAkCA;IA4D5DA,CAACA;IAlDAD,iCAAkBA,GAAlBA;QACCE,gBAAKA,CAACA,kBAAkBA,WAAEA,CAAAA;QAC1BA,EAAEA,CAAAA,CAACA,IAAIA,CAACA,KAAKA,CAACA,eAAeA,CAACA,CAACA,CAACA;YAC/BA,IAAIA,CAACA,SAASA,CAACA,WAAWA,CACzBA,IAAIA,wBAAiBA,CAACA,IAAIA,CAACA,KAAKA,CAACA,eAAeA,CAACA,CAACA,CAAAA;QACpDA,CAACA;IACFA,CAACA;IAEDF,6BAAcA,GAAdA;QACCG,MAAMA,CAACA,IAAIA,uBAAgBA,CAACA,IAAIA,CAACA,KAAKA,CAACA,WAAWA,CAACA,CAAAA;IACpDA,CAACA;IAEDH,8BAAeA,GAAf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AACA;QAEDA,MAAMA,CAACA,CACNA,qBAACA,GAAGA,KAACA,OAAOA,GAACA,MAAMA,GAACA,SAASA,GAAEA,IAAIA,CAACA,SAASA,CAACA,SAASA,EAAGA,GACxDA,OAAQA,CACDA,CACTA,CAACA;IACHA,CAACA;IAzDMP,cAASA,GAAGA,CAACA,CAACA,QAAQA,CAACA;QAC7BA,WAAWA,EAACA,KAAKA,CAACA,SAASA,CAACA,MAAMA,CAACA,UAAUA;QAC7CA,eAAeA,EAACA,KAAKA,CAACA,SAASA,CAACA,OAAOA,CACtCA,KAAKA,CAACA,SAASA,CAACA,MAAMA,CACtBA;KACDA,EAAEA,yBAAkBA,CAACA,SAASA,CAACA,CAAAA;IAqDjCA,WAACA;AAADA,CAACA,AA5DD,EAA0B,yBAAkB,EA4D3C;AA5DY,YAAI,OA4DhB,CAAA"}
View
9 lib/src/components/search/hits/src/NoHits.d.ts
@@ -0,0 +1,9 @@
+import { SearchkitComponent, SearchkitComponentProps } from "../../../../core";
+export interface NoHitsProps extends SearchkitComponentProps {
+}
+export declare class NoHits extends SearchkitComponent<NoHitsProps, any> {
+ defineBEMBlocks(): {
+ container: string;
+ };
+ render(): JSX.Element;
+}
View
28 lib/src/components/search/hits/src/NoHits.js
@@ -0,0 +1,28 @@
+var __extends = (this && this.__extends) || function (d, b) {
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+};
+var React = require("react");
+require("../styles/no-hits.scss");
+var core_1 = require("../../../../core");
+var NoHits = (function (_super) {
+ __extends(NoHits, _super);
+ function NoHits() {
+ _super.apply(this, arguments);
+ }
+ NoHits.prototype.defineBEMBlocks = function () {
+ var block = (this.props.mod || "no-hits");
+ return {
+ container: block
+ };
+ };
+ NoHits.prototype.render = function () {
+ if (this.hasHits())
+ return null;
+ return (React.createElement("div", {"data-qa": "no-hits", "className": this.bemBlocks.container()}, "no results found"));
+ };
+ return NoHits;
+})(core_1.SearchkitComponent);
+exports.NoHits = NoHits;
+//# sourceMappingURL=NoHits.js.map
View
1 lib/src/components/search/hits/src/NoHits.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"NoHits.js","sourceRoot":"","sources":["../../../../../../src/components/search/hits/src/NoHits.tsx"],"names":["NoHits","NoHits.constructor","NoHits.defineBEMBlocks","NoHits.render"],"mappings":";;;;;AACA,IAAY,KAAK,WAAM,OAAO,CAAC,CAAA;AAC/B,QAAO,wBAAwB,CAAC,CAAA;AAEhC,qBAGO,kBAEP,CAAC,CAFwB;AAKzB;IAA4BA,0BAAoCA;IAAhEA;QAA4BC,8BAAoCA;IAkBhEA,CAACA;IAhBAD,gCAAeA,GAAfA;QACCE,IAAIA,KAAKA,GAAGA,CAACA,IAAIA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,SAASA,CAACA,CAAAA;QACzCA,MAAMA,CAACA;YACNA,SAASA,EAAEA,KAAKA;SAChBA,CAAAA;IACFA,CAACA;IAEDF,uBAAMA,GAANA;QACGG,EAAEA,CAACA,CAACA,IAAIA,CAACA,OAAOA,EAAEA,CAACA;YAACA,MAAMA,CAACA,IAAIA,CAAAA;QAEjCA,MAAMA,CAACA,CACNA,qBAACA,GAAGA,KAACA,OAAOA,GAACA,SAASA,GAACA,SAASA,GAAEA,IAAIA,CAACA,SAASA,CAACA,SAASA,EAAGA,sBAEpDA,CACTA,CAACA;IACHA,CAACA;IACFH,aAACA;AAADA,CAACA,AAlBD,EAA4B,yBAAkB,EAkB7C;AAlBY,cAAM,SAkBlB,CAAA"}
View
4 lib/src/components/search/hits/styles/no-hits.scss
@@ -0,0 +1,4 @@
+.no-hits {
+ text-align:center;
+ margin-top:60px;
+}
View
1 src/components/index.ts
@@ -5,6 +5,7 @@ export * from "./search/filters/selected-filters/src/SelectedFilters";
export * from "./search/filters/hierarchical-menu-filter/src/HierarchicalMenuFilter";
export * from "./search/filters/numeric-refinement-list-filter/src/NumericRefinementListFilter";
export * from "./search/hits/src/Hits";
+export * from "./search/hits/src/NoHits";
export * from "./search/hits-stats/src/HitsStats";
export * from "./search/pagination/src/Pagination";
export * from "./search/search-box/src/SearchBox";
View
8 src/components/search/hits/src/Hits.tsx
@@ -58,12 +58,6 @@ export class Hits extends SearchkitComponent<HitsProps, any> {
)
}
- renderNoResults() {
- return (
- <div data-qa="no-results" className={this.bemBlocks.container("no-results")}>{this.translate("No results")}</div>
- )
- }
-
render() {
let hits:Array<Object> = this.getHits()
let hasHits = hits.length > 0
@@ -71,8 +65,6 @@ export class Hits extends SearchkitComponent<HitsProps, any> {
if (this.isInitialLoading()) {
results = this.renderInitialView()
- } else if (!hasHits) {
- results = this.renderNoResults()
} else {
results = _.map(hits, this.renderResult.bind(this))
}
View
31 src/components/search/hits/src/NoHits.tsx
@@ -0,0 +1,31 @@
+import * as _ from "lodash";
+import * as React from "react";
+import "../styles/no-hits.scss";
+
+import {
+ SearchkitComponent,
+ SearchkitComponentProps
+} from "../../../../core"
+
+export interface NoHitsProps extends SearchkitComponentProps {
+}
+
+export class NoHits extends SearchkitComponent<NoHitsProps, any> {
+
+ defineBEMBlocks() {
+ let block = (this.props.mod || "no-hits")
+ return {
+ container: block
+ }
+ }
+
+ render() {
+ if (this.hasHits()) return null
+
+ return (
+ <div data-qa="no-hits" className={this.bemBlocks.container()}>
+ no results found
+ </div>
+ );
+ }
+}
View
4 src/components/search/hits/styles/no-hits.scss
@@ -0,0 +1,4 @@
+.no-hits {
+ text-align:center;
+ margin-top:60px;
+}
View
1 tsconfig.json
@@ -26,6 +26,7 @@
"./src/components/search/hits-stats/src/HitsStats.tsx",
"./src/components/search/hits-stats/test/HitsStatsSpec.tsx",
"./src/components/search/hits/src/Hits.tsx",
+ "./src/components/search/hits/src/NoHits.tsx",
"./src/components/search/pagination/src/Pagination.tsx",
"./src/components/search/pagination/test/PaginationSpec.tsx",
"./src/components/search/search-box/src/Autocomplete.tsx",
View
1 webpack.test.config.js
@@ -6,7 +6,6 @@ module.exports = {
output: {
path: path.join(__dirname, 'dist')
},
- watch:true,
resolve: {
extensions:[".js", ".ts", ".tsx","", ".webpack.js", ".web.js"],
alias: {

0 comments on commit 6ec6ad9

Please sign in to comment.
Something went wrong with that request. Please try again.