Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat(Results): add index (position) (#382)
Browse files Browse the repository at this point in the history
This reveals the relative hit position, and is needed for example for analytics
  • Loading branch information
Haroenv authored Jan 24, 2018
1 parent 5efb171 commit 16c2c64
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<slot name="header"></slot>

<slot v-for="result in results" :result="result">
<slot v-for="(result, index) in results" :result="result" :index="index">
Result 'objectID': {{ result.objectID }}
</slot>

Expand Down
38 changes: 38 additions & 0 deletions stories/Results.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { previewWrapper } from './utils';
import { storiesOf } from '@storybook/vue';

storiesOf('Results', module)
.addDecorator(previewWrapper)
.add('default', () => ({
template: `
<ais-results />
`,
}))
.add('header & footer', () => ({
template: `
<ais-results>
<div slot="header">--- Header ---</div>
<div slot="footer">--- Footer ---</div>
</ais-results>
`,
}))
.add('with index', () => ({
template: `
<ais-results>
<div slot-scope="{ result, index }">
{{index + 1}}. {{result.objectID}}
</div>
</ais-results>
`,
}))
.add('all slots', () => ({
template: `
<ais-results>
<div slot="header">--- Header ---</div>
<div slot-scope="{ result, index }">
{{index + 1}}. {{result.objectID}}
</div>
<div slot="footer">--- Footer ---</div>
</ais-results>
`,
}));

0 comments on commit 16c2c64

Please sign in to comment.