Notes/apps/client/src/widgets/quick_search_launcher.ts

35 lines
897 B
TypeScript
Raw Normal View History

2024-11-23 09:34:26 +02:00
import utils from "../services/utils.js";
import QuickSearchWidget from "./quick_search.js";
/**
* Similar to the {@link QuickSearchWidget} but meant to be included inside the launcher bar.
2025-01-09 18:07:02 +02:00
*
2024-11-23 09:34:26 +02:00
* <p>
* Adds specific tweaks such as:
2025-01-09 18:07:02 +02:00
*
2024-11-23 09:34:26 +02:00
* - Hiding the widget on mobile.
*/
export default class QuickSearchLauncherWidget extends QuickSearchWidget {
private isHorizontalLayout: boolean;
constructor(isHorizontalLayout: boolean) {
super();
this.isHorizontalLayout = isHorizontalLayout;
}
2024-11-23 09:34:26 +02:00
isEnabled() {
if (!this.isHorizontalLayout) {
// The quick search widget is added somewhere else on the vertical layout.
return false;
}
2024-11-23 09:34:26 +02:00
if (utils.isMobile()) {
// The widget takes too much spaces to be included in the mobile layout.
2024-11-23 09:34:26 +02:00
return false;
}
return super.isEnabled();
}
2025-01-09 18:07:02 +02:00
}