-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(js-widget): add example (algolia/create-instantsearch-app#461)
* add an example * tweak spacing * update tests
- Loading branch information
Showing
9 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# {{name}} | ||
# {{ name }} | ||
|
||
{{ description }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
body { | ||
font-family: sans-serif; | ||
} | ||
|
||
[class^=ais-] { | ||
font-size: 1em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.css@7/themes/algolia-min.css"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>{{ name }} example</title> | ||
</head> | ||
<body> | ||
<div id="search-box"></div> | ||
<div id="example"></div> | ||
<div id="hits"></div> | ||
<script src="index.ts"></script> | ||
</body> | ||
</html> |
35 changes: 35 additions & 0 deletions
35
src/templates/InstantSearch.js widget/example/index.ts.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import algoliasearch from 'algoliasearch/lite'; | ||
import instantsearch from 'instantsearch.js/es'; | ||
import { configure, hits, searchBox } from 'instantsearch.js/es/widgets'; | ||
|
||
import { {{ camelCaseName }} } from '../src'; | ||
|
||
const search = instantsearch({ | ||
indexName: 'instant_search', | ||
searchClient: algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76'), | ||
}); | ||
|
||
search.addWidgets([ | ||
{{ camelCaseName }}({ container: '#example' }), | ||
|
||
searchBox({ container: '#search-box' }), | ||
configure({ | ||
attributesToSnippet: ['description:10'], | ||
snippetEllipsisText: '[…]', | ||
}), | ||
hits({ | ||
container: '#hits', | ||
templates: { | ||
item: ` | ||
<p> | ||
{{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}} | ||
</p> | ||
<small> | ||
{{#helpers.snippet}}{ "attribute": "description" }{{/helpers.snippet}} | ||
</small> | ||
`, | ||
}, | ||
}), | ||
]); | ||
|
||
search.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { {{ camelCaseName }} } from './widget'; | ||
export { connect{{ pascalCaseName }} } from './connector'; | ||
export { create{{ pascalCaseName }}Renderer } from './renderer'; | ||
export * from './widget'; | ||
export * from './connector'; | ||
export * from './renderer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters