Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import type {
- SearchMatch,
- SearchResults,
- GlobalSearchResults,
- SearchItemLayout,
- SearchItemLayoutTypes,
- } from 'utils/search/search-types';
- const SEARCH_SIDEBAR_WIDTH = 576;
- const SEARCH_ITEM_COVER_HEIGHT = 60;
- const SEARCH_ITEM_HEIGHT = 68;
- const SEARCH_ITEM_LAYOUT_TYPES: SearchItemLayoutTypes = {
- Cover: 'cover',
- Match: 'match',
- };
- ...
- const LayoutProviderFactory = results => {
- return new LayoutProvider(
- index => {
- const searchItem = results[index];
- if (!searchItem) {
- //TODO: how is that possible?
- return 'unknown';
- }
- return searchItem.layoutType;
- },
- (type: SearchItemLayout, dim) => {
- switch (type) {
- case SEARCH_ITEM_LAYOUT_TYPES.Cover: // HERE
- dim.width = SEARCH_SIDEBAR_WIDTH;
- dim.height = SEARCH_ITEM_COVER_HEIGHT;
- break;
- case SEARCH_ITEM_LAYOUT_TYPES.Match:
- dim.width = SEARCH_SIDEBAR_WIDTH;
- dim.height = SEARCH_ITEM_HEIGHT;
- break;
- default: // for 'unknown'
- dim.width = 0;
- dim.height = 0;
- }
- }
- );
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement