2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2018-11-26 02:21:25 +01:00
|
|
|
import * as ICONS from 'constants/icons';
|
2017-12-21 22:08:54 +01:00
|
|
|
import React from 'react';
|
2021-07-07 09:10:28 +02:00
|
|
|
import { lazyImport } from 'util/lazyImport';
|
2020-12-11 19:33:27 +01:00
|
|
|
import { useIsMobile } from 'effects/use-screensize';
|
2021-06-11 08:06:29 +02:00
|
|
|
|
2021-07-07 09:10:28 +02:00
|
|
|
const Button = lazyImport(() => import('component/button' /* webpackChunkName: "button" */));
|
|
|
|
const Icon = lazyImport(() => import('component/common/icon' /* webpackChunkName: "icon" */));
|
2021-10-26 08:15:08 +02:00
|
|
|
const WunderbarSuggestions = lazyImport(() => import('component/wunderbarSuggestions' /* webpackChunkName: "wb" */));
|
2018-10-04 07:59:47 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
2021-06-16 04:27:58 +02:00
|
|
|
doOpenMobileSearch: (any) => void,
|
2021-06-03 04:59:01 +02:00
|
|
|
channelsOnly?: boolean,
|
|
|
|
noTopSuggestion?: boolean,
|
|
|
|
noBottomLinks?: boolean,
|
|
|
|
customSelectAction?: (string) => void,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
2020-12-03 18:29:47 +01:00
|
|
|
export default function WunderBar(props: Props) {
|
2021-06-03 04:59:01 +02:00
|
|
|
const { doOpenMobileSearch, channelsOnly, noTopSuggestion, noBottomLinks, customSelectAction } = props;
|
2020-12-11 19:33:27 +01:00
|
|
|
const isMobile = useIsMobile();
|
2020-12-03 18:29:47 +01:00
|
|
|
|
2020-12-11 19:33:27 +01:00
|
|
|
return isMobile ? (
|
2021-06-11 08:06:29 +02:00
|
|
|
<React.Suspense fallback={null}>
|
2021-06-25 10:02:45 +02:00
|
|
|
<Button
|
|
|
|
icon={ICONS.SEARCH}
|
|
|
|
className="wunderbar__mobile-search"
|
|
|
|
onClick={() => doOpenMobileSearch({ ...props })}
|
|
|
|
/>
|
2021-06-11 08:06:29 +02:00
|
|
|
</React.Suspense>
|
2020-12-11 19:33:27 +01:00
|
|
|
) : (
|
2021-06-11 08:06:29 +02:00
|
|
|
<React.Suspense
|
|
|
|
fallback={
|
|
|
|
<div className="wunderbar__wrapper wunderbar wunderbar__input" aria-disabled>
|
|
|
|
<Icon icon={ICONS.SEARCH} aria-disabled />
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<WunderbarSuggestions
|
|
|
|
channelsOnly={channelsOnly}
|
|
|
|
noTopSuggestion={noTopSuggestion}
|
|
|
|
noBottomLinks={noBottomLinks}
|
|
|
|
customSelectAction={customSelectAction}
|
|
|
|
/>
|
|
|
|
</React.Suspense>
|
2020-12-03 18:29:47 +01:00
|
|
|
);
|
|
|
|
}
|