Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(instantsearch-ui-components): introduce FrequentlyBoughtTogether component #6114

Merged
merged 38 commits into from
Apr 15, 2024
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
440e9cc
chore: update algoliasearch version
dhayab Mar 28, 2024
81b4400
feat(helper): add methods to request and retrieve recommendations
dhayab Mar 28, 2024
0eac184
add tests
dhayab Mar 29, 2024
98018d8
emit placeholder change event and test events better
dhayab Mar 29, 2024
84937b3
Merge branch 'master' into feat/helper-recommend-methods
dhayab Mar 29, 2024
6f064f8
bump bundle sizes
dhayab Mar 29, 2024
9469f26
Merge branch 'master' into feat/helper-recommend-methods
dhayab Apr 2, 2024
2cc4743
retrieve recommend queries on all index widgets through derived helpers
dhayab Apr 3, 2024
2a70204
add tests for derived helper
dhayab Apr 3, 2024
2518d91
bump bundlesize
dhayab Apr 3, 2024
7ab1436
feat(recommend): add FBT to instantsearch-ui-components
raed667 Apr 3, 2024
d326cab
fix: split component files to fix type errors
raed667 Apr 4, 2024
60f8c9c
fix babel spread issue
raed667 Apr 4, 2024
ab5dd33
replace classes auc with ais
raed667 Apr 4, 2024
e8544c6
fix: address feedback
raed667 Apr 4, 2024
7ade025
fix: address feedback by adding tests and TS types
raed667 Apr 4, 2024
e041a2f
wip: map recommend results to widgets
aymeric-giraudet Apr 4, 2024
8813c64
remove comment
raed667 Apr 4, 2024
60a9ef6
Merge branch 'feat/map-recommend-results' into feat-recommend-fbt-ui-…
raed667 Apr 5, 2024
60f052b
fix: results
aymeric-giraudet Apr 5, 2024
c90ef99
fix: typescript
aymeric-giraudet Apr 5, 2024
418cffb
fix types
aymeric-giraudet Apr 5, 2024
5c69418
bundlesize
aymeric-giraudet Apr 5, 2024
46c2531
Merge branch 'master' into feat/map-recommend-results
aymeric-giraudet Apr 5, 2024
deab535
Merge branch 'feat/map-recommend-results' into feat-recommend-fbt-ui-…
raed667 Apr 5, 2024
6c1dc58
Merge branch 'feat/map-recommend-results' into feat-recommend-fbt-ui-…
raed667 Apr 5, 2024
f1eb001
fix linit issue
raed667 Apr 5, 2024
8375968
wip
sarahdayan Apr 8, 2024
b37546e
wip
sarahdayan Apr 8, 2024
cb00cee
fix: fix build
sarahdayan Apr 8, 2024
44b40fe
fix: add __position
sarahdayan Apr 8, 2024
853d96a
Update packages/algoliasearch-helper/src/algoliasearch.helper.js
raed667 Apr 8, 2024
f9c44d2
add support and types for sendEvent
dhayab Apr 9, 2024
4dbc64c
fix tests
dhayab Apr 9, 2024
a62a979
fix: fix issues with sendEvent and test it
sarahdayan Apr 9, 2024
30d0f35
fix: stop passing createElement and Fragment to ItemComponent
sarahdayan Apr 9, 2024
087f1f3
style: lint
sarahdayan Apr 10, 2024
7dd719c
feat: remove default click event
sarahdayan Apr 15, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ scripts/*/CHANGELOG.md
# private files
.env
.idea/
.vscode/

# Caches
.eslintcache
Expand Down
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ module.exports = (api) => {
// false positive (babel doesn't know types)
// this is actually only called on arrays
'String.prototype.includes',

// false positive (spread)
'Object.getOwnPropertyDescriptors',
];
if (defaultShouldInject && !exclude.includes(name)) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"path": "packages/vue-instantsearch/vue2/umd/index.js",
"maxSize": "66.5 kB"
"maxSize": "67 kB"
},
{
"path": "packages/vue-instantsearch/vue3/umd/index.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/** @jsx createElement */

import { cx } from '../lib';

import { createDefaultHeaderComponent } from './recommend-shared/DefaultHeader';
import { createListViewComponent } from './recommend-shared/ListView';

import type {
RecommendTranslations,
Renderer,
ComponentProps,
RecommendComponentProps,
} from '../types';

export type FrequentlyBoughtTogetherProps<
TObject,
TComponentProps extends Record<string, unknown> = Record<string, unknown>
> = ComponentProps<'div'> & RecommendComponentProps<TObject, TComponentProps>;

export function createFrequentlyBoughtTogetherComponent({
createElement,
Fragment,
}: Renderer) {
return function FrequentlyBoughtTogether<TObject>(
userProps: FrequentlyBoughtTogetherProps<TObject>
) {
const {
classNames = {},
fallbackComponent: FallbackComponent = () => null,
headerComponent: HeaderComponent = createDefaultHeaderComponent({
createElement,
Fragment,
}),
itemComponent: ItemComponent,
view: View = createListViewComponent({ createElement, Fragment }),
items,
status,
translations: userTranslations,
sendEvent,
...props
} = userProps;

const translations: Required<RecommendTranslations> = {
title: 'Frequently bought together',
sliderLabel: 'Frequently bought together products',
...userTranslations,
};

if (items.length === 0 && status === 'idle') {
return <FallbackComponent />;
}

return (
<section
{...props}
className={cx('ais-FrequentlyBoughtTogether', classNames.root)}
>
<HeaderComponent
classNames={{
...classNames,
title: cx('ais-FrequentlyBoughtTogether-title', classNames.title),
}}
recommendations={items}
translations={translations}
/>

<View
classNames={{
...classNames,
container: cx(
'ais-FrequentlyBoughtTogether-container',
classNames.container
),
list: cx('ais-FrequentlyBoughtTogether-list', classNames.list),
item: cx('ais-FrequentlyBoughtTogether-item', classNames.item),
}}
translations={translations}
itemComponent={ItemComponent}
items={items}
sendEvent={sendEvent}
/>
</section>
);
};
}
3 changes: 1 addition & 2 deletions packages/instantsearch-ui-components/src/components/Hits.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/** @jsx createElement */
import { cx } from '../lib';

import type { ComponentProps, Renderer } from '../types';
import type { ComponentProps, Renderer, SendEventForHits } from '../types';

// Should be imported from a shared package in the future
type Hit = Record<string, unknown> & {
objectID: string;
};
type SendEventForHits = (...props: unknown[]) => void;

export type HitsProps<THit> = ComponentProps<'div'> & {
hits: THit[];
Expand Down
Loading