diff --git a/docs/src/components/SearchBox.md b/docs/src/components/SearchBox.md
index 0f518e9a9..446466091 100644
--- a/docs/src/components/SearchBox.md
+++ b/docs/src/components/SearchBox.md
@@ -24,8 +24,8 @@ A search input with a clear and submit button.
Name | Type | Default | Description | Required
---|---|---|---|---
placeholder | String | `'Search hereβ¦'` | The input placeholder | no
-submit-title | String | `'search'` | The submit button text | no
-clear-title | String | `'clear'` | The clear button text | no
+submit-title | String | `'search'` | The submit button's alternative text | no
+reset-title | String | `'clear'` | The clear button's alternative text | no
autofocus | Boolean | `false` | Whether to automatically focus on the input when rendered | no
show-loading-indicator | Boolean | `false` | Show a spinner in the search box if a delay is passed and no results are returned yet | no
class-names | Object | | Override class names | no
@@ -35,6 +35,9 @@ class-names | Object | | Override class names | no
Name | Scope | Description
---|---|---
default | `{ currentRefinement: String, isSearchStalled: Boolean, refine: String => void }` | Slot to override the DOM output
+loading-indicator | | Slot to override the loading indicator
+reset-icon | | Slot to override the reset icon
+submit-icon | | Slot to override the submit icon
## CSS classes
diff --git a/src/components/SearchBox.vue b/src/components/SearchBox.vue
index 758fc168f..2a9f95b38 100644
--- a/src/components/SearchBox.vue
+++ b/src/components/SearchBox.vue
@@ -14,9 +14,23 @@
:show-loading-indicator="showLoadingIndicator"
:should-show-loading-indicator="state.isSearchStalled"
:submit-title="submitTitle"
- :clear-title="clearTitle"
+ :reset-title="resetTitle"
+ :class-names="classNames"
v-model="currentRefinement"
- />
+ >
+
+
+
+
@@ -53,7 +67,7 @@ export default {
type: String,
default: 'Search',
},
- clearTitle: {
+ resetTitle: {
type: String,
default: 'Clear',
},
diff --git a/src/components/SearchInput.vue b/src/components/SearchInput.vue
index e7fefb5a6..e9881768d 100644
--- a/src/components/SearchInput.vue
+++ b/src/components/SearchInput.vue
@@ -7,6 +7,7 @@
@submit.prevent="onFormSubmit"
@reset.prevent="onFormReset"
>
+
-
{
);
});
-test('with clear title', () => {
+test('with reset title', () => {
__setState(defaultState);
const wrapper = mount(SearchBox, {
propsData: {
- clearTitle: 'Clear Title',
+ resetTitle: 'Clear Title',
},
});
@@ -166,3 +166,63 @@ test('refine on empty string on form reset', () => {
expect(state.refine).toHaveBeenCalledWith('');
});
+
+test('overriding slots', () => {
+ __setState({
+ ...defaultState,
+ isSearchStalled: true,
+ });
+ const wrapper = mount(SearchBox, {
+ propsData: {
+ showLoadingIndicator: true,
+ },
+ slots: {
+ 'submit-icon': 'SUBMIT',
+ 'reset-icon': 'RESET',
+ 'loading-indicator': 'LOADING...',
+ },
+ });
+
+ expect(wrapper.find('.ais-SearchBox-submit').html()).toMatch(/SUBMIT/);
+ expect(wrapper.find('.ais-SearchBox-reset').html()).toMatch(/RESET/);
+ expect(wrapper.find('.ais-SearchBox-loadingIndicator').html()).toMatch(
+ /LOADING.../
+ );
+
+ expect(wrapper.find('.ais-SearchBox-submit').html()).toMatchInlineSnapshot(`
+
+
+
+`);
+ expect(wrapper.find('.ais-SearchBox-reset').html()).toMatchInlineSnapshot(`
+
+
+
+`);
+ expect(wrapper.find('.ais-SearchBox-loadingIndicator').html())
+ .toMatchInlineSnapshot(`
+
+
+
+ LOADING...
+
+
+
+`);
+});
diff --git a/stories/SearchBox.stories.js b/stories/SearchBox.stories.js
index 12f4740b3..bc42edef5 100644
--- a/stories/SearchBox.stories.js
+++ b/stories/SearchBox.stories.js
@@ -7,7 +7,7 @@ storiesOf('ais-search-box', module)
template: '',
}))
.add('with loading indicator', () => ({
- template: '',
+ template: '',
}))
.add('with autofocus', () => ({
template: '',
@@ -24,6 +24,21 @@ storiesOf('ais-search-box', module)
`,
}))
+ .add('with custom rendering of icons', () => ({
+ template: `
+
+
+ β
+
+
+ π
+
+
+ π
+
+
+ `,
+ }))
.add('with a Panel', () => ({
template: `