Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
10fe263
chore(searchbox): migration guide
Sep 17, 2018
8499965
feat(searchbox): remove powered-by
Sep 17, 2018
4acfb9c
feat(searchbox): remove non-wrapped input feature
Sep 17, 2018
1182b34
feat(searchbox): searchOnEnterKeyPressOnly -> searchAsYouType
Sep 17, 2018
7992ccd
feat(searchbox): move UI elements options into templates and cssClasses
Sep 18, 2018
319635d
feat(searchbox): update markup
Sep 18, 2018
be2e8c3
Merge branch 'feat/3.0' into feat/3.0-searchbox
Sep 19, 2018
d934419
feat(searchbox): implement UX refinements
Sep 24, 2018
77e14e3
docs(v3): correctly reference the update to `showSubmit`
Sep 24, 2018
2f086c3
docs(searchbox): update storiest
Sep 24, 2018
f8d8e69
docs(searchbox): better input error message
Sep 24, 2018
622f665
fix(searchbox): favor submit event
Sep 24, 2018
a01763d
chore: clean up
Sep 24, 2018
98127de
fix(searchbox): autofocus now only supports boolean and defaults to f…
Sep 24, 2018
fb9fe83
chore: remove instances of autofocus to false
francoischalifour Sep 25, 2018
d6866e0
feat: update autofocus code and tests
francoischalifour Sep 25, 2018
8698522
feat(stories): remove placeholder
francoischalifour Sep 25, 2018
fba87fc
docs(searchbox): remove IE8 comment
francoischalifour Sep 27, 2018
0d51cc3
feat(searchbox): blur on enter
francoischalifour Sep 27, 2018
12f9c77
feat(searchbox): remove IE8 support
francoischalifour Oct 1, 2018
2e36eac
refactor(searchbox): invert listener events condition
francoischalifour Oct 1, 2018
615e100
fix(searchbox): remove unused function
francoischalifour Oct 2, 2018
e6f4072
feat(searchbox): apply changes
francoischalifour Oct 3, 2018
ee0e2d5
fix(searchbox): query with input value
francoischalifour Oct 4, 2018
1ff5c0a
fix: merge conflicts
francoischalifour Oct 11, 2018
d4c60cd
fix(searchbox): allow custom CSS
francoischalifour Oct 11, 2018
b363da6
fix(searchbox): do not render at init
francoischalifour Oct 11, 2018
725f992
feat(searchbox): update error messages
francoischalifour Oct 11, 2018
da5673a
feat(searchbox): simplify widget import
francoischalifour Oct 11, 2018
002d8d0
docs(migration): update
francoischalifour Oct 12, 2018
97fdf6c
docs(searchbox): update
francoischalifour Oct 12, 2018
f2c6c24
fix: merge conflicts
francoischalifour Oct 12, 2018
658d8a8
feat(searchbox): focus on reset and add empty action
francoischalifour Oct 16, 2018
94b797f
docs(searchbox): add explanation
francoischalifour Oct 16, 2018
43ec998
test(searchbox): test markup
francoischalifour Oct 16, 2018
f3eba24
docs(searchbox): add missing options
francoischalifour Oct 16, 2018
b13d468
feat(searchbox): add autofocus story
francoischalifour Oct 16, 2018
0c4f45a
fix(searchbox): fix loadingIcon class
francoischalifour Oct 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 18 additions & 51 deletions dev/app/builtin/stories/search-box.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,110 +14,77 @@ export default () => {
window.search.addWidget(
instantsearch.widgets.searchBox({
container,
placeholder: 'Search for products',
poweredBy: true,
})
);
})
)
.add(
'display loading indicator',
'with a custom placeholder',
wrapWithHits(container => {
window.search.addWidget(
instantsearch.widgets.searchBox({
container,
placeholder: 'Search for products',
poweredBy: true,
loadingIndicator: true,
})
);
})
)
.add(
'display loading indicator with a template',
'with autofocus',
wrapWithHits(container => {
window.search.addWidget(
instantsearch.widgets.searchBox({
container,
placeholder: 'Search for products',
poweredBy: true,
loadingIndicator: {
template: '⚡️',
},
autofocus: true,
})
);
})
)
.add(
'with custom templates',
'do not display the loading indicator',
wrapWithHits(container => {
window.search.addWidget(
instantsearch.widgets.searchBox({
container,
placeholder: 'Search for products',
poweredBy: true,
magnifier: {
template: '<div class="ais-search-box--magnifier">🔍</div>',
},
reset: {
template: '<div class="ais-search-box--reset">✖️</div>',
},
templates: {
poweredBy: 'Algolia',
},
showLoadingIndicator: false,
})
);
})
)
.add(
'search on enter',
'display loading indicator with a template',
wrapWithHits(container => {
window.search.addWidget(
instantsearch.widgets.searchBox({
container,
placeholder: 'Search for products',
poweredBy: true,
searchOnEnterKeyPressOnly: true,
})
);
})
)
.add(
'input with initial value',
wrapWithHits(container => {
container.innerHTML = '<input value="ok"/>';
const input = container.firstChild;
container.appendChild(input);
window.search.addWidget(
instantsearch.widgets.searchBox({
container: input,
templates: {
loadingIndicator: '⚡️',
},
})
);
})
)
.add(
'with a provided input',
'with custom templates',
wrapWithHits(container => {
container.innerHTML = '<input/>';
const input = container.firstChild;
container.appendChild(input);
window.search.addWidget(
instantsearch.widgets.searchBox({
container: input,
container,
templates: {
submit: '<div class="ais-search-box--magnifier">🔍</div>',
reset: '<div class="ais-search-box--reset">✖️</div>',
},
})
);
})
)
.add(
'with a provided input and the loading indicator',
'search on enter',
wrapWithHits(container => {
container.innerHTML = '<input/>';
const input = container.firstChild;
container.appendChild(input);
window.search.addWidget(
instantsearch.widgets.searchBox({
container: input,
loadingIndicator: true,
container,
searchAsYouType: false,
})
);
})
Expand Down
1 change: 0 additions & 1 deletion docgen/assets/js/bindRunExamples.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ function appendDefaultSearchWidgets(index) {
instantsearch.widgets.searchBox({
container: `#search-box-container-${index}`,
placeholder: "Search for products",
autofocus: false
})
);

Expand Down
2 changes: 1 addition & 1 deletion docgen/src/examples/tourism/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ window.addEventListener('load', function() {
instantsearch.widgets.searchBox({
container: '#q',
placeholder: 'Where are you going?',
magnifier: false
showSubmit: false
})
);

Expand Down
86 changes: 83 additions & 3 deletions docgen/src/guides/v3-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ search.addWidget(
item: data => {
data.count = 0;
return data;
}
}
},
},
})
);
```
Expand Down Expand Up @@ -311,7 +311,7 @@ With the redo button:
| ------------ | ------------ |
| `escapeHits` | `escapeHTML` |

* `escapeHTML` defaults to `true`
- `escapeHTML` defaults to `true`

#### CSS classes

Expand Down Expand Up @@ -1015,6 +1015,86 @@ Widget removed.
</div>
```

### SearchBox

#### Options

| Before | After |
| --------------------------- | ---------------------------------------- |
| `poweredBy` | use the `poweredBy` widget |
| `wrapInput` | use the `connectSearchBox` connector |
| `searchOnEnterKeyPressOnly` | `searchAsYouType` (default: `true`) |
| `reset` | `showReset` |
| `magnifier` | `showSubmit` |
| `loadingIndicator` | `showLoadingIndicator` (default: `true`) |

With the drop of `wrapInput`, we decided not to accept `input`s as containers anymore. If you want complete control over the rendering, you should use the `connectSearchBox` connector.

The search box does not support `powered-by`. If you're using a community plan, you need to use the `poweredBy` widget to display the Algolia logo.

Configuration options for `reset`, `submit` and `loadingIndicator` have been moved to `templates` and `cssClasses`. For example, in the case of `reset`:

- `reset.template` => `templates.reset`
- `reset.cssClasses.root` => `cssClasses.reset`

Finally, `autofocus` is now set to `false` by default and does not support the `"auto"` value anymore.

#### CSS classes

| Before | After |
| ------------------------------------------- | -------------------------------- |
| `ais-search-box` | `ais-SearchBox` |
| | `ais-SearchBox-form` |
| `ais-search-box--input` | `ais-SearchBox-input` |
| `ais-search-box--magnifier-wrapper` | |
| `ais-search-box--magnifier` | `ais-SearchBox-submit` |
| | `ais-SearchBox-submitIcon` |
| `ais-search-box--reset-wrapper` | |
| `ais-search-box--reset` | `ais-SearchBox-reset` |
| | `ais-SearchBox-resetIcon` |
| `ais-search-box--loading-indicator-wrapper` | |
| `ais-search-box--loading-indicator` | `ais-SearchBox-loadingIndicator` |
| | `ais-SearchBox-loadingIcon` |

#### Markup

```html
<div class="ais-SearchBox">
<form class="ais-SearchBox-form" novalidate>
<input class="ais-SearchBox-input" autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="Search for products" spellcheck="false" maxlength="512" type="search" value="" />
<button class="ais-SearchBox-submit" type="submit" title="Submit the search query.">
<svg class="ais-SearchBox-submitIcon" xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 40 40">
<path d="M26.804 29.01c-2.832 2.34-6.465 3.746-10.426 3.746C7.333 32.756 0 25.424 0 16.378 0 7.333 7.333 0 16.378 0c9.046 0 16.378 7.333 16.378 16.378 0 3.96-1.406 7.594-3.746 10.426l10.534 10.534c.607.607.61 1.59-.004 2.202-.61.61-1.597.61-2.202.004L26.804 29.01zm-10.426.627c7.323 0 13.26-5.936 13.26-13.26 0-7.32-5.937-13.257-13.26-13.257C9.056 3.12 3.12 9.056 3.12 16.378c0 7.323 5.936 13.26 13.258 13.26z"></path>
</svg>
</button>
<button class="ais-SearchBox-reset" type="reset" title="Clear the search query." hidden>
<svg class="ais-SearchBox-resetIcon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="10" height="10">
<path d="M8.114 10L.944 2.83 0 1.885 1.886 0l.943.943L10 8.113l7.17-7.17.944-.943L20 1.886l-.943.943-7.17 7.17 7.17 7.17.943.944L18.114 20l-.943-.943-7.17-7.17-7.17 7.17-.944.943L0 18.114l.943-.943L8.113 10z"></path>
</svg>
</button>
<span class="ais-SearchBox-loadingIndicator" hidden>
<svg width="16" height="16" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg" stroke="#444" class="ais-SearchBox-loadingIcon">
<g fill="none" fillRule="evenodd">
<g transform="translate(1 1)" strokeWidth="2">
<circle strokeOpacity=".5" cx="18" cy="18" r="18" />
<path d="M36 18c0-9.94-8.06-18-18-18">
<animateTransform
attributeName="transform"
type="rotate"
from="0 18 18"
to="360 18 18"
dur="1s"
repeatCount="indefinite"
/>
</path>
</g>
</g>
</svg>
</span>
</form>
<div>
```

### SortBy

#### Options
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export {
export { default as numericMenu } from './numeric-menu/numeric-menu';
export { default as pagination } from './pagination/pagination.js';
export { default as rangeInput } from './range-input/range-input.js';
export { default as searchBox } from '../widgets/search-box/search-box.js';
export { default as searchBox } from './search-box/search-box.js';
export { default as rangeSlider } from './range-slider/range-slider.js';
export { default as sortBy } from './sort-by/sort-by.js';
export { default as ratingMenu } from './rating-menu/rating-menu';
Expand Down
115 changes: 115 additions & 0 deletions src/widgets/search-box/__tests__/__snapshots__/search-box-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`searchBox() markup renders correctly 1`] = `
<div
class="ais-SearchBox"
>
<form
action=""
class="ais-SearchBox-form"
novalidate=""
>
<input
autocapitalize="off"
autocomplete="off"
autocorrect="off"
class="ais-SearchBox-input"
placeholder=""
role="textbox"
spellcheck="false"
type="text"
value=""
/>
<button
class="ais-SearchBox-submit"
title="Submit the search query"
type="submit"
>
<svg
class="ais-SearchBox-submitIcon"
height="10"
viewBox="0 0 40 40"
width="10"
xmlns="http://www.w3.org/2000/svg"
>

<path
d="M26.804 29.01c-2.832 2.34-6.465 3.746-10.426 3.746C7.333 32.756 0 25.424 0 16.378 0 7.333 7.333 0 16.378 0c9.046 0 16.378 7.333 16.378 16.378 0 3.96-1.406 7.594-3.746 10.426l10.534 10.534c.607.607.61 1.59-.004 2.202-.61.61-1.597.61-2.202.004L26.804 29.01zm-10.426.627c7.323 0 13.26-5.936 13.26-13.26 0-7.32-5.937-13.257-13.26-13.257C9.056 3.12 3.12 9.056 3.12 16.378c0 7.323 5.936 13.26 13.258 13.26z"
/>

</svg>
</button>
<button
class="ais-SearchBox-reset"
hidden=""
title="Clear the search query"
type="reset"
>
<svg
class="ais-SearchBox-resetIcon"
height="10"
viewBox="0 0 20 20"
width="10"
xmlns="http://www.w3.org/2000/svg"
>

<path
d="M8.114 10L.944 2.83 0 1.885 1.886 0l.943.943L10 8.113l7.17-7.17.944-.943L20 1.886l-.943.943-7.17 7.17 7.17 7.17.943.944L18.114 20l-.943-.943-7.17-7.17-7.17 7.17-.944.943L0 18.114l.943-.943L8.113 10z"
/>

</svg>
</button>
<span
class="ais-SearchBox-loadingIndicator"
hidden=""
>
<svg
class="ais-SearchBox-loadingIcon"
height="16"
stroke="#444"
viewBox="0 0 38 38"
width="16"
xmlns="http://www.w3.org/2000/svg"
>

<g
fill="none"
fillrule="evenodd"
>

<g
strokewidth="2"
transform="translate(1 1)"
>

<circle
cx="18"
cy="18"
r="18"
strokeopacity=".5"
/>

<path
d="M36 18c0-9.94-8.06-18-18-18"
>

<animatetransform
attributeName="transform"
dur="1s"
from="0 18 18"
repeatCount="indefinite"
to="360 18 18"
type="rotate"
/>

</path>

</g>

</g>

</svg>
</span>
</form>
</div>
`;
Loading