-
-
-
-
+ loader: (_, { html }) => html`
+
-
`,
- item: (hit) => {
- return `
-
${hit.title}
-
-
${hit._answer.extract}
- `;
- },
+ item: (hit, { html }) => html`
+
${hit.title}
+
+
${hit._answer.extract}
+ `,
},
}),
]);
diff --git a/packages/instantsearch.js/stories/breadcrumb.stories.ts b/packages/instantsearch.js/stories/breadcrumb.stories.ts
index 10a9e274a1..a57e5ccd14 100644
--- a/packages/instantsearch.js/stories/breadcrumb.stories.ts
+++ b/packages/instantsearch.js/stories/breadcrumb.stories.ts
@@ -69,7 +69,7 @@ storiesOf('Metadata/Breadcrumb', module)
'hierarchicalCategories.lvl2',
],
templates: {
- separator: ' + ',
+ separator: () => ' + ',
},
}),
]);
@@ -105,7 +105,7 @@ storiesOf('Metadata/Breadcrumb', module)
'hierarchicalCategories.lvl2',
],
templates: {
- home: 'Home Page',
+ home: () => 'Home Page',
},
}),
]);
diff --git a/packages/instantsearch.js/stories/clear-refinements.stories.ts b/packages/instantsearch.js/stories/clear-refinements.stories.ts
index ce7387c8be..b0ad00a415 100644
--- a/packages/instantsearch.js/stories/clear-refinements.stories.ts
+++ b/packages/instantsearch.js/stories/clear-refinements.stories.ts
@@ -32,7 +32,7 @@ storiesOf('Refinements/ClearRefinements', module)
container,
includedAttributes: ['query'],
templates: {
- resetLabel: 'Clear query',
+ resetLabel: () => 'Clear query',
},
}),
]);
@@ -47,7 +47,7 @@ storiesOf('Refinements/ClearRefinements', module)
container,
excludedAttributes: [],
templates: {
- resetLabel: 'Clear refinements and query',
+ resetLabel: () => 'Clear refinements and query',
},
}),
]);
diff --git a/packages/instantsearch.js/stories/configure-related-items.stories.ts b/packages/instantsearch.js/stories/configure-related-items.stories.ts
index e6b3d1e579..625e333a28 100644
--- a/packages/instantsearch.js/stories/configure-related-items.stories.ts
+++ b/packages/instantsearch.js/stories/configure-related-items.stories.ts
@@ -106,20 +106,18 @@ storiesOf('Basics/ConfigureRelatedItems', module).add(
instantsearch.widgets.hits({
container: widgetParams.container,
templates: {
- item(item) {
- return `
-
-
-
-
-
${item.name}
-
-
- `;
- },
- empty: '',
+ item: (item, { html }) => html`
+
+
+
+
+
${item.name}
+
+
+ `,
+ empty: () => '',
},
}),
]),
@@ -134,26 +132,26 @@ storiesOf('Basics/ConfigureRelatedItems', module).add(
instantsearch.widgets.hits({
container: productContainer,
templates: {
- item: `
-
-
-
- {{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}}
-
-
- {{#helpers.snippet}}{ "attribute": "description" }{{/helpers.snippet}}
-
-
-
-`,
- empty: '',
+ item: (hit, { html, components }) => html`
+
+
+
+
+ ${components.Highlight({ attribute: 'name', hit })})}
+
+
+ ${components.Snippet({ attribute: 'description', hit })})}
+
+
+ `,
+ empty: () => '',
},
cssClasses: {
item: 'hits-item',
diff --git a/packages/instantsearch.js/stories/current-refinements.stories.ts b/packages/instantsearch.js/stories/current-refinements.stories.ts
index 66e5e7e6de..cc36552999 100644
--- a/packages/instantsearch.js/stories/current-refinements.stories.ts
+++ b/packages/instantsearch.js/stories/current-refinements.stories.ts
@@ -141,7 +141,7 @@ storiesOf('Refinements/CurrentRefinements', module)
container: toggleRefinementContainer,
attribute: 'free_shipping',
templates: {
- labelText: 'Free Shipping',
+ labelText: () => 'Free Shipping',
},
}),
]);
diff --git a/packages/instantsearch.js/stories/dynamic-widgets.stories.ts b/packages/instantsearch.js/stories/dynamic-widgets.stories.ts
index c06d86ebf2..e5c05cd0a0 100644
--- a/packages/instantsearch.js/stories/dynamic-widgets.stories.ts
+++ b/packages/instantsearch.js/stories/dynamic-widgets.stories.ts
@@ -34,7 +34,7 @@ storiesOf('Basics/DynamicWidgets', module)
}),
(container) =>
instantsearch.widgets.panel({
- templates: { header: 'hierarchy' },
+ templates: { header: () => 'hierarchy' },
})(instantsearch.widgets.hierarchicalMenu)({
container,
attributes: [
@@ -79,7 +79,7 @@ storiesOf('Basics/DynamicWidgets', module)
}),
(container) =>
instantsearch.widgets.panel({
- templates: { header: 'hierarchy' },
+ templates: { header: () => 'hierarchy' },
})(instantsearch.widgets.hierarchicalMenu)({
container,
attributes: [
diff --git a/packages/instantsearch.js/stories/geo-search.stories.ts b/packages/instantsearch.js/stories/geo-search.stories.ts
index 3acd702e44..95090aa221 100644
--- a/packages/instantsearch.js/stories/geo-search.stories.ts
+++ b/packages/instantsearch.js/stories/geo-search.stories.ts
@@ -224,9 +224,10 @@ stories
instantsearch.widgets.geoSearch({
googleReference: window.google,
templates: {
- reset: '
re-center',
- toggle: '
Redo search when map moved',
- redo: '
Search this area',
+ reset: (_, { html }) => html`
re-center`,
+ toggle: (_, { html }) =>
+ html`
Redo search when map moved`,
+ redo: (_, { html }) => html`
Search this area`,
},
container,
initialPosition,
@@ -382,11 +383,10 @@ stories
},
},
templates: {
- HTMLMarker: `
-
- {{price_formatted}}
-
- `,
+ HTMLMarker: (hit, { html }) =>
+ html`
+ ${hit.price_formatted}
+
`,
},
container,
initialPosition,
@@ -428,11 +428,10 @@ stories
},
},
templates: {
- HTMLMarker: `
-
- {{price_formatted}}
-
- `,
+ HTMLMarker: (hit, { html }) =>
+ html`
+ ${hit.price_formatted}
+
`,
},
container,
initialPosition,
@@ -487,11 +486,10 @@ stories
},
},
templates: {
- HTMLMarker: `
-
- {{price_formatted}}
-
- `,
+ HTMLMarker: (hit, { html }) =>
+ html`
+ ${hit.price_formatted}
+
`,
},
container,
initialPosition,
@@ -567,11 +565,12 @@ stories
},
},
templates: {
- HTMLMarker: `
-
- {{price_formatted}}
-
- `,
+ HTMLMarker: (hit, { html }) => html`
+ ${hit.price_formatted}
+
`,
},
container,
initialPosition,
diff --git a/packages/instantsearch.js/stories/hits.stories.ts b/packages/instantsearch.js/stories/hits.stories.ts
index 281483a44d..d54b63d353 100644
--- a/packages/instantsearch.js/stories/hits.stories.ts
+++ b/packages/instantsearch.js/stories/hits.stories.ts
@@ -39,8 +39,8 @@ storiesOf('Results/Hits', module)
instantsearch.widgets.hits({
container,
templates: {
- item(hit) {
- return instantsearch.highlight({
+ item(hit, { components }) {
+ return components.Highlight({
attribute: 'name',
hit,
});
@@ -70,8 +70,8 @@ storiesOf('Results/Hits', module)
instantsearch.widgets.hits({
container,
templates: {
- item(hit) {
- return instantsearch.reverseHighlight({
+ item(hit, { components }) {
+ return components.ReverseHighlight({
attribute: 'name',
hit,
});
@@ -107,16 +107,20 @@ storiesOf('Results/Hits', module)
instantsearch.widgets.hits({
container,
templates: {
- item(hit) {
- return `
-
${instantsearch.snippet({
- attribute: 'name',
- hit,
- })}
-
${instantsearch.snippet({
- attribute: 'description',
- hit,
- })}
+ item(hit, { html, components }) {
+ return html`
+
+ ${components.Snippet({
+ attribute: 'name',
+ hit,
+ })}
+
+
+ ${components.Snippet({
+ attribute: 'description',
+ hit,
+ })}
+
`;
},
},
@@ -214,12 +218,7 @@ storiesOf('Results/Hits', module)
item: (item, { html, sendEvent }) => html`
${item.name}
diff --git a/packages/instantsearch.js/stories/infinite-hits.stories.ts b/packages/instantsearch.js/stories/infinite-hits.stories.ts
index 70a4d7504d..f268c72c33 100644
--- a/packages/instantsearch.js/stories/infinite-hits.stories.ts
+++ b/packages/instantsearch.js/stories/infinite-hits.stories.ts
@@ -19,7 +19,7 @@ storiesOf('Results/InfiniteHits', module)
instantsearch.widgets.infiniteHits({
container,
templates: {
- item: '{{name}}',
+ item: ({ name }) => name,
},
}),
]);
@@ -32,7 +32,7 @@ storiesOf('Results/InfiniteHits', module)
instantsearch.widgets.infiniteHits({
container,
templates: {
- item: '{{name}}',
+ item: ({ name }) => name,
showMoreText: 'Load more',
},
}),
diff --git a/packages/instantsearch.js/stories/menu-select.stories.ts b/packages/instantsearch.js/stories/menu-select.stories.ts
index a0000fbbd9..683c76cebf 100644
--- a/packages/instantsearch.js/stories/menu-select.stories.ts
+++ b/packages/instantsearch.js/stories/menu-select.stories.ts
@@ -23,7 +23,7 @@ storiesOf('Refinements/MenuSelect', module)
attribute: 'categories',
limit: 10,
templates: {
- item: '{{label}}',
+ item: ({ label }) => label,
},
}),
]);
@@ -38,7 +38,7 @@ storiesOf('Refinements/MenuSelect', module)
attribute: 'categories',
limit: 10,
templates: {
- defaultOption: 'Default choice',
+ defaultOption: () => 'Default choice',
},
}),
]);
diff --git a/packages/instantsearch.js/stories/menu.stories.ts b/packages/instantsearch.js/stories/menu.stories.ts
index bfd45f5392..af6761ec5b 100644
--- a/packages/instantsearch.js/stories/menu.stories.ts
+++ b/packages/instantsearch.js/stories/menu.stories.ts
@@ -68,13 +68,7 @@ storiesOf('Refinements/Menu', module)
showMore: true,
showMoreLimit: 10,
templates: {
- showMoreText: `
- {{#isShowingMore}}
- ⬆️
- {{/isShowingMore}}
- {{^isShowingMore}}
- ⬇️
- {{/isShowingMore}}`,
+ showMoreText: ({ isShowingMore }) => (isShowingMore ? '⬆️' : '⬇️'),
},
}),
]);
diff --git a/packages/instantsearch.js/stories/pagination.stories.ts b/packages/instantsearch.js/stories/pagination.stories.ts
index f3980d0abc..6fdfd78435 100644
--- a/packages/instantsearch.js/stories/pagination.stories.ts
+++ b/packages/instantsearch.js/stories/pagination.stories.ts
@@ -76,10 +76,10 @@ storiesOf('Pagination/Pagination', module)
instantsearch.widgets.pagination({
container,
templates: {
- previous: 'Previous',
- next: 'Next',
- first: 'First',
- last: 'Last',
+ previous: () => 'Previous',
+ next: () => 'Next',
+ first: () => 'First',
+ last: () => 'Last',
},
}),
]);
diff --git a/packages/instantsearch.js/stories/panel.stories.ts b/packages/instantsearch.js/stories/panel.stories.ts
index ad317a9b92..84d3d8e4c3 100644
--- a/packages/instantsearch.js/stories/panel.stories.ts
+++ b/packages/instantsearch.js/stories/panel.stories.ts
@@ -23,7 +23,7 @@ storiesOf('Basics/Panel', module)
withHits(({ search, container, instantsearch }) => {
const brandList = instantsearch.widgets.panel({
templates: {
- header: 'Brand',
+ header: () => 'Brand',
footer: ({ results }) => {
return results ? `${results.nbHits} results` : '';
},
@@ -43,8 +43,8 @@ storiesOf('Basics/Panel', module)
withHits(({ search, container, instantsearch }) => {
const priceList = instantsearch.widgets.panel({
templates: {
- header: 'Price',
- footer: 'Footer',
+ header: () => 'Price',
+ footer: () => 'Footer',
},
})(instantsearch.widgets.rangeInput);
@@ -63,8 +63,8 @@ storiesOf('Basics/Panel', module)
typeof instantsearch.widgets.rangeSlider
>({
templates: {
- header: 'Price',
- footer: 'Footer',
+ header: () => 'Price',
+ footer: () => 'Footer',
},
})(instantsearch.widgets.rangeSlider);
@@ -87,8 +87,8 @@ storiesOf('Basics/Panel', module)
withHits(({ search, container, instantsearch }) => {
const priceList = instantsearch.widgets.panel({
templates: {
- header: 'Price',
- footer: 'The panel is hidden when there are no results.',
+ header: () => 'Price',
+ footer: () => 'The panel is hidden when there are no results.',
},
hidden: ({ results }) => results.nbHits === 0,
})(instantsearch.widgets.rangeInput);
@@ -109,8 +109,8 @@ storiesOf('Basics/Panel', module)
return options && options.state && !options.state.query;
},
templates: {
- header: 'Brand (collapsible)',
- footer: 'The panel collapses on empty query until controlled',
+ header: () => 'Brand (collapsible)',
+ footer: () => 'The panel collapses on empty query until controlled',
},
})(instantsearch.widgets.refinementList);
@@ -130,8 +130,8 @@ storiesOf('Basics/Panel', module)
return options && options.state && !options.state.query;
},
templates: {
- header: 'Collapsible panel',
- footer: 'The panel collapses on empty query until controlled',
+ header: () => 'Collapsible panel',
+ footer: () => 'The panel collapses on empty query until controlled',
collapseButtonText: ({ collapsed }) => (collapsed ? 'More' : 'Less'),
},
})(instantsearch.widgets.refinementList);
@@ -158,7 +158,7 @@ storiesOf('Basics/Panel', module)
header({ canRefine }) {
return `Breadcrumb that can${canRefine ? '' : "'t "} refine`;
},
- footer:
+ footer: () =>
'The panel collapses if it cannot refine. Click "Home". This panel will collapse and you will not see this footer anymore.',
},
})(instantsearch.widgets.breadcrumb);
diff --git a/packages/instantsearch.js/stories/query-rule-context.stories.ts b/packages/instantsearch.js/stories/query-rule-context.stories.ts
index 7bc07873b7..326006abcb 100644
--- a/packages/instantsearch.js/stories/query-rule-context.stories.ts
+++ b/packages/instantsearch.js/stories/query-rule-context.stories.ts
@@ -46,22 +46,20 @@ storiesOf('Metadata/QueryRuleContext', module)
return items.filter((item) => typeof item.banner !== 'undefined');
},
templates: {
- default: ({ items }: { items: CustomDataItem[] }) =>
- items
- .map((item) => {
- const { title, banner, link } = item;
+ default: ({ items }: { items: CustomDataItem[] }, { html }) =>
+ items.map((item) => {
+ const { title, banner, link } = item;
- return `
+ return html`
`;
- })
- .join(''),
+ }),
},
}),
]);
@@ -97,22 +95,20 @@ storiesOf('Metadata/QueryRuleContext', module)
return items.filter((item) => typeof item.banner !== 'undefined');
},
templates: {
- default: ({ items }: { items: CustomDataItem[] }) =>
- items
- .map((item) => {
- const { title, banner, link } = item;
+ default: ({ items }: { items: CustomDataItem[] }, { html }) =>
+ items.map((item) => {
+ const { title, banner, link } = item;
- return `
-
- ${title}
+ return html`
+
+ ${title}
-
-
-
-
- `;
- })
- .join(''),
+
+
+
+
+ `;
+ }),
},
}),
]);
diff --git a/packages/instantsearch.js/stories/query-rule-custom-data.stories.ts b/packages/instantsearch.js/stories/query-rule-custom-data.stories.ts
index 0e4ab81fdd..e6ab22cfb4 100644
--- a/packages/instantsearch.js/stories/query-rule-custom-data.stories.ts
+++ b/packages/instantsearch.js/stories/query-rule-custom-data.stories.ts
@@ -31,26 +31,24 @@ storiesOf('Metadata/QueryRuleCustomData', module)
instantsearch.widgets.queryRuleCustomData({
container: widgetContainer,
templates: {
- default: ({ items }: { items: CustomDataItem[] }) =>
- items
- .map((item) => {
- const { title, banner, link } = item;
+ default: ({ items }: { items: CustomDataItem[] }, { html }) =>
+ items.map((item) => {
+ const { title, banner, link } = item;
- if (!banner) {
- return '';
- }
+ if (!banner) {
+ return html``;
+ }
- return `
+ return html`
`;
- })
- .join(''),
+ }),
},
}),
]);
@@ -116,20 +114,20 @@ storiesOf('Metadata/QueryRuleCustomData', module)
];
},
templates: {
- default({ items }: { items: CustomDataItem[] }) {
+ default({ items }: { items: CustomDataItem[] }, { html }) {
if (items.length === 0) {
- return '';
+ return html``;
}
const { title, banner, link } = items[0];
- return `
-
${title}
+ return html`
+
${title}
-
-
-
- `;
+
+
+
+ `;
},
},
}),
diff --git a/packages/instantsearch.js/stories/range-input.stories.ts b/packages/instantsearch.js/stories/range-input.stories.ts
index 2082579511..7959d27dd6 100644
--- a/packages/instantsearch.js/stories/range-input.stories.ts
+++ b/packages/instantsearch.js/stories/range-input.stories.ts
@@ -73,8 +73,8 @@ storiesOf('Refinements/RangeInput', module)
min: 10,
max: 500,
templates: {
- separatorText: '→',
- submitText: 'Refine',
+ separatorText: () => '→',
+ submitText: () => 'Refine',
},
}),
]);
diff --git a/packages/instantsearch.js/stories/refinement-list.stories.ts b/packages/instantsearch.js/stories/refinement-list.stories.ts
index c23670d5f9..fbf8fd1652 100644
--- a/packages/instantsearch.js/stories/refinement-list.stories.ts
+++ b/packages/instantsearch.js/stories/refinement-list.stories.ts
@@ -39,13 +39,7 @@ storiesOf('Refinements/RefinementList', module)
showMore: true,
showMoreLimit: 10,
templates: {
- showMoreText: `
- {{#isShowingMore}}
- ⬆️
- {{/isShowingMore}}
- {{^isShowingMore}}
- ⬇️
- {{/isShowingMore}}`,
+ showMoreText: ({ isShowingMore }) => (isShowingMore ? '⬆️' : '⬇️'),
},
}),
]);
@@ -73,10 +67,10 @@ storiesOf('Refinements/RefinementList', module)
searchable: true,
searchablePlaceholder: 'Find other brands...',
templates: {
- searchableNoResults: 'No results found',
- searchableSubmit: 'Go',
- searchableReset: 'x',
- searchableLoadingIndicator: '•',
+ searchableNoResults: () => 'No results found',
+ searchableSubmit: () => 'Go',
+ searchableReset: () => 'x',
+ searchableLoadingIndicator: () => '•',
},
}),
]);
diff --git a/packages/instantsearch.js/stories/search-box.stories.ts b/packages/instantsearch.js/stories/search-box.stories.ts
index 72c5ca0295..35bd800bbf 100644
--- a/packages/instantsearch.js/stories/search-box.stories.ts
+++ b/packages/instantsearch.js/stories/search-box.stories.ts
@@ -53,7 +53,7 @@ storiesOf('Basics/SearchBox', module)
instantsearch.widgets.searchBox({
container,
templates: {
- loadingIndicator: '⚡️',
+ loadingIndicator: () => '⚡️',
},
}),
]);
@@ -66,8 +66,10 @@ storiesOf('Basics/SearchBox', module)
instantsearch.widgets.searchBox({
container,
templates: {
- submit: '
🔍
',
- reset: '
✖️
',
+ submit: (_, { html }) =>
+ html`
🔍
`,
+ reset: (_, { html }) =>
+ html`
✖️
`,
},
}),
]);
diff --git a/packages/instantsearch.js/stories/toggle-refinement.stories.ts b/packages/instantsearch.js/stories/toggle-refinement.stories.ts
index 46c03db7d0..ae9e95ac3e 100644
--- a/packages/instantsearch.js/stories/toggle-refinement.stories.ts
+++ b/packages/instantsearch.js/stories/toggle-refinement.stories.ts
@@ -22,7 +22,7 @@ storiesOf('Refinements/ToggleRefinement', module)
container,
attribute: 'free_shipping',
templates: {
- labelText: 'Free Shipping (toggle single value)',
+ labelText: () => 'Free Shipping (toggle single value)',
},
}),
]);
@@ -38,7 +38,7 @@ storiesOf('Refinements/ToggleRefinement', module)
on: 'Sony',
off: 'Canon',
templates: {
- labelText: 'Canon (not checked) or sony (checked)',
+ labelText: () => 'Canon (not checked) or sony (checked)',
},
}),
]);
@@ -52,7 +52,7 @@ storiesOf('Refinements/ToggleRefinement', module)
container: node,
attribute: 'free_shipping',
templates: {
- labelText: 'Free Shipping (toggle single value)',
+ labelText: () => 'Free Shipping (toggle single value)',
},
})
);
diff --git a/packages/instantsearch.js/stories/voice-search.stories.ts b/packages/instantsearch.js/stories/voice-search.stories.ts
index 2b5ba4fb36..2b197a43d8 100644
--- a/packages/instantsearch.js/stories/voice-search.stories.ts
+++ b/packages/instantsearch.js/stories/voice-search.stories.ts
@@ -28,7 +28,7 @@ storiesOf('Basics/VoiceSearch', module)
instantsearch.widgets.voiceSearch({
container,
templates: {
- status: ``,
+ status: () => ``,
},
}),
]);
@@ -88,13 +88,13 @@ storiesOf('Basics/VoiceSearch', module)
instantsearch.widgets.voiceSearch({
container,
templates: {
- status: `
-
status: {{status}}
-
errorCode: {{errorCode}}
-
isListening: {{isListening}}
-
transcript: {{transcript}}
-
isSpeechFinal: {{isSpeechFinal}}
-
isBrowserSupported: {{isBrowserSupported}}
+ status: (data, { html }) => html`
+
status: ${data.status}
+
errorCode: ${data.errorCode}
+
isListening: ${data.isListening}
+
transcript: ${data.transcript}
+
isSpeechFinal: ${data.isSpeechFinal}
+
isBrowserSupported: ${data.isBrowserSupported}
`,
},
}),
@@ -109,13 +109,13 @@ storiesOf('Basics/VoiceSearch', module)
container,
searchAsYouSpeak: true,
templates: {
- status: `
-
status: {{status}}
-
errorCode: {{errorCode}}
-
isListening: {{isListening}}
-
transcript: {{transcript}}
-
isSpeechFinal: {{isSpeechFinal}}
-
isBrowserSupported: {{isBrowserSupported}}
+ status: (data, { html }) => html`
+
status: ${data.status}
+
errorCode: ${data.errorCode}
+
isListening: ${data.isListening}
+
transcript: ${data.transcript}
+
isSpeechFinal: ${data.isSpeechFinal}
+
isBrowserSupported: ${data.isBrowserSupported}
`,
},
}),
@@ -168,12 +168,12 @@ storiesOf('Basics/VoiceSearch', module)
status: 'voice-search-status',
},
templates: {
- status({ isListening, transcript }) {
- return `
-
- ${transcript}
-
- `;
+ status({ isListening, transcript }, { html }) {
+ return html`
+
+ ${transcript}
+
+ `;
},
},
}),