-
Notifications
You must be signed in to change notification settings - Fork 157
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn lint:fix
src/components/SearchBox.vue
Outdated
@@ -3,13 +3,29 @@ | |||
<slot> | |||
<ais-input :search-store="searchStore" :placeholder="placeholder" :autofocus="autofocus"></ais-input> | |||
<button type="submit" :class="bem('submit')"> | |||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 40 40"> | |||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 40 40" v-if="!searchStore.isSearchStalled"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works really nice 😄
Maybe have this as an option though
src/components/SearchBox.vue
Outdated
<title>{{ submitTitle }}</title> | ||
<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" | ||
fillRule="evenodd" | ||
/> | ||
</svg> | ||
<svg width="1em" height="1em" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg" stroke="#000" v-if="searchStore.isSearchStalled"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a slot I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more blockers now I think
src/components/SearchBox.vue
Outdated
<title>{{ submitTitle }}</title> | ||
<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" | ||
fillRule="evenodd" | ||
/> | ||
</svg> | ||
<svg width="1em" height="1em" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg" stroke="#000" v-if="showLoadingIndicator && searchStore.isSearchStalled"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would still be nice to have this as a slot :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Will make this happen :)
}; | ||
|
||
const onHelperSearch = function() { | ||
if (!this._stalledSearchTimer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is a big deal, but maybe it could not be done only if the stalled search feature is enabled? Might be hard to find out about it here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature is always there, for simplicity sake.
I've updated this PR to be consistent with the other InstantSearch implementations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nice @bobylito .
I made a few comments.
For me the only real thing I would change is remove the new options
parameter introduced on all factory methods.
The reasoning being that the state should only originate from a single source of truth.
I hope that makes sense.
src/components/SearchBox.vue
Outdated
@@ -24,8 +44,7 @@ | |||
</form> | |||
</template> | |||
|
|||
<script> | |||
import algoliaComponent from '../component'; | |||
<script>import algoliaComponent from '../component'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the weird syntax is coming back here @Haroenv . Expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not expected, maybe @bobylito's vim setup, should be put on the new line IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll double check. Maybe I didn't update the packages that do the formating 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it's not an error from any linter / formatter. I might have just removed it by mistake :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure it's because of the linter or something.
Happens to me all the time but can't remember what the real issue was.
@@ -72,7 +76,8 @@ export default { | |||
if (!this.searchStore) { | |||
this._localSearchStore = createFromAlgoliaCredentials( | |||
this.appId, | |||
this.apiKey | |||
this.apiKey, | |||
{ stalledSearchDelay: this.stalledSearchDelay } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we consider not adding another "options" parameter, and introduce a getter instead?
So far, the Store is just proxying as much as possible.
Also, if tomorrow the stalledSearchDelay
is added to the helper, we won't require the option anymore and it would be an issue to be able to have it in the helper + as an option, because we won't know which one to keep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. However my thinking behind choosing this as an option is that this is a feature in the scope of InstantSearch, not the helper. This might evolve but the way it is implemented right now is the way it is in the other libraries.
src/components/SearchBox.vue
Outdated
@@ -2,7 +2,27 @@ | |||
<form role="search" action="" @submit.prevent="onFormSubmit"> | |||
<slot> | |||
<ais-input :search-store="searchStore" :placeholder="placeholder" :autofocus="autofocus"></ais-input> | |||
<button type="submit" :class="bem('submit')"> | |||
<div v-if="showLoadingIndicator" :style="searchStore.isSearchStalled ? 'display:block;' : 'display:none;'" :class="bem('loading-indicator')" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably go for v-show="showLoadingIndicator && searchStore.isSearchStalled"
and remove the style
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed for that it would make more sense given the vue-specifics. However I chose that in order to have consistency accross all implementations. This is the exact same markup and changes on it depending on the value of isSearchStalled
in all implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good 🎸
src/components/SearchBox.vue
Outdated
@@ -2,7 +2,27 @@ | |||
<form role="search" action="" @submit.prevent="onFormSubmit"> | |||
<slot> | |||
<ais-input :search-store="searchStore" :placeholder="placeholder" :autofocus="autofocus"></ais-input> | |||
<button type="submit" :class="bem('submit')"> | |||
<div v-if="showLoadingIndicator" :style="searchStore.isSearchStalled ? 'display:block;' : 'display:none;'" :class="bem('loading-indicator')" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the hidden
attribute, which implies display: none;
but is better for a11y
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:hidden="!searchStore.isSearchStalled"
Updated per your suggestion @Haroenv thanks :) |
…ading-indicator feat: provide a loading indicator
This PR provides a way for the searchbox to display a spinner when the search is stalled.
The approach taken here is similar to the one from react-instantsearch: the mechanism that detects the stalled search is actually implemented at the top level. As in RIS this makes the implementation of this state update easier in multiple widgets, which seems like a good strategy.
On the UI implementation, because vue-IS doesn't implement any style, the magnifying glass svg is toggle with a spinner in the template. The effect is good as far as I can tell.
Missing elements:
Question:
Related to algolia/instantsearch#2509