Skip to content

Commit ff8b345

Browse files
sarahdayanHaroenv
andauthored
feat(instantsearch.js): replace Highlight and cx (#6030)
Co-authored-by: Haroen Viaene <[email protected]>
1 parent b4ed187 commit ff8b345

File tree

60 files changed

+409
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+409
-625
lines changed
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
export function cx(
2-
...classNames: Array<string | number | boolean | undefined | null>
3-
) {
4-
return classNames.filter(Boolean).join(' ');
1+
type ClassValue = string | undefined | boolean | null | number;
2+
3+
export function cx(...classNames: Array<ClassValue | ClassValue[]>) {
4+
return classNames
5+
.reduce<ClassValue[]>((acc, className) => {
6+
if (Array.isArray(className)) {
7+
return acc.concat(className);
8+
}
9+
return acc.concat([className]);
10+
}, [])
11+
.filter(Boolean)
12+
.join(' ');
513
}

packages/instantsearch.js/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@
2727
],
2828
"dependencies": {
2929
"@algolia/events": "^4.0.1",
30-
"@algolia/ui-components-highlight-vdom": "^1.2.2",
31-
"@algolia/ui-components-shared": "^1.2.2",
3230
"@types/dom-speech-recognition": "^0.0.1",
3331
"@types/google.maps": "^3.45.3",
3432
"@types/hogan.js": "^3.0.0",
3533
"@types/qs": "^6.5.3",
3634
"algoliasearch-helper": "3.16.2",
3735
"hogan.js": "^3.0.2",
3836
"htm": "^3.0.0",
37+
"instantsearch-ui-components": "^0.2.0",
3938
"preact": "^10.10.0",
4039
"qs": "^6.5.1 < 6.10",
4140
"search-insights": "^2.13.0"

packages/instantsearch.js/src/components/Answers/Answers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h } from 'preact';
55

66
import { warning } from '../../lib/utils';

packages/instantsearch.js/src/components/Breadcrumb/Breadcrumb.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h } from 'preact';
55

66
import Template from '../Template/Template';

packages/instantsearch.js/src/components/ClearRefinements/ClearRefinements.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h } from 'preact';
55

66
import Template from '../Template/Template';

packages/instantsearch.js/src/components/CurrentRefinements/CurrentRefinements.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h } from 'preact';
55

66
import { isSpecialClick, capitalize } from '../../lib/utils';

packages/instantsearch.js/src/components/GeoSearchControls/GeoSearchControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h, Fragment } from 'preact';
55

66
import Template from '../Template/Template';

packages/instantsearch.js/src/components/Highlight/Highlight.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/** @jsx h */
2-
import { cx } from '@algolia/ui-components-shared';
2+
import { cx } from 'instantsearch-ui-components';
33
import { h } from 'preact';
44

55
import { InternalHighlight } from '../InternalHighlight/InternalHighlight';
66

77
import type {
88
HighlightProps as InternalHighlightProps,
99
HighlightClassNames as InternalHighlightClassNames,
10-
} from '@algolia/ui-components-highlight-vdom';
10+
} from 'instantsearch-ui-components';
1111

1212
export type HighlightClassNames = InternalHighlightClassNames;
1313
export type HighlightProps = Omit<InternalHighlightProps, 'classNames'> & {

packages/instantsearch.js/src/components/Hits/Hits.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h } from 'preact';
55

66
import { createInsightsEventHandler } from '../../lib/insights/listener';

packages/instantsearch.js/src/components/InfiniteHits/InfiniteHits.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h } from 'preact';
55

66
import { createInsightsEventHandler } from '../../lib/insights/listener';

packages/instantsearch.js/src/components/InternalHighlight/InternalHighlight.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createHighlightComponent } from '@algolia/ui-components-highlight-vdom';
1+
import { createHighlightComponent } from 'instantsearch-ui-components';
22
import { createElement, Fragment } from 'preact';
33

44
export const InternalHighlight = createHighlightComponent({

packages/instantsearch.js/src/components/InternalHighlight/__tests__/InternalHighlight.test.tsx

Lines changed: 0 additions & 210 deletions
This file was deleted.

packages/instantsearch.js/src/components/MenuSelect/MenuSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h } from 'preact';
55

66
import { find } from '../../lib/utils';

packages/instantsearch.js/src/components/Pagination/Pagination.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h } from 'preact';
55

66
import { isSpecialClick } from '../../lib/utils';

packages/instantsearch.js/src/components/Panel/Panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h } from 'preact';
55
import { useState, useEffect, useRef } from 'preact/hooks';
66

packages/instantsearch.js/src/components/RangeInput/RangeInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h, Component } from 'preact';
55

66
import Template from '../Template/Template';

packages/instantsearch.js/src/components/RefinementList/RefinementList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22

3-
import { cx } from '@algolia/ui-components-shared';
3+
import { cx } from 'instantsearch-ui-components';
44
import { h, createRef, Component } from 'preact';
55

66
import { isSpecialClick, isEqual } from '../../lib/utils';

packages/instantsearch.js/src/components/ReverseHighlight/ReverseHighlight.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/** @jsx h */
2-
import { cx } from '@algolia/ui-components-shared';
2+
import { cx } from 'instantsearch-ui-components';
33
import { h } from 'preact';
44

55
import { InternalHighlight } from '../InternalHighlight/InternalHighlight';
66

77
import type {
88
HighlightProps as InternalHighlightProps,
99
HighlightClassNames as InternalHighlightClassNames,
10-
} from '@algolia/ui-components-highlight-vdom';
10+
} from 'instantsearch-ui-components';
1111

1212
export type ReverseHighlightClassNames = InternalHighlightClassNames;
1313
export type ReverseHighlightProps = Omit<

packages/instantsearch.js/src/components/ReverseSnippet/ReverseSnippet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/** @jsx h */
2-
import { cx } from '@algolia/ui-components-shared';
2+
import { cx } from 'instantsearch-ui-components';
33
import { h } from 'preact';
44

55
import { InternalHighlight } from '../InternalHighlight/InternalHighlight';
66

77
import type {
88
HighlightProps as InternalHighlightProps,
99
HighlightClassNames as InternalHighlightClassNames,
10-
} from '@algolia/ui-components-highlight-vdom';
10+
} from 'instantsearch-ui-components';
1111

1212
export type ReverseSnippetClassNames = InternalHighlightClassNames;
1313
export type ReverseSnippetProps = Omit<InternalHighlightProps, 'classNames'> & {

0 commit comments

Comments
 (0)