UNPKG

@atlaskit/global-search

Version:

A cross-product search component (batteries included)

66 lines (60 loc) 2.29 kB
import React from 'react'; import styled from 'styled-components'; // AFP-2532 TODO: Fix automatic suppressions below // eslint-disable-next-line @atlassian/tangerine/import/entry-points import { gridSize } from '@atlaskit/theme'; import { ResultItemGroup } from '@atlaskit/quick-search'; import Badge from '@atlaskit/badge'; import ResultList from './ResultList'; import { injectIntl } from 'react-intl'; import ShowMoreButton from './ShowMoreButton'; const TitlelessGroupWrapper = styled.div` margin-top: ${gridSize() * 1.5}px; `; const BadgeContainer = styled.span` margin-left: ${gridSize()}px; `; export class ResultGroup extends React.Component { render() { const { title, results, sectionIndex, showTotalSize, totalSize, showMoreButton, onShowMoreClicked, onSearchMoreAdvancedSearch, query } = this.props; if (results.length === 0) { return null; } const moreButton = showMoreButton ? /*#__PURE__*/React.createElement(ShowMoreButton, { resultLength: results.length, onShowMoreClicked: onShowMoreClicked, onSearchMoreAdvancedSearch: onSearchMoreAdvancedSearch, totalSize: totalSize, query: query // this will force new show more button every click show more to fix scrolling , key: `show_more_${results.length}` }) : null; if (!title) { return /*#__PURE__*/React.createElement(TitlelessGroupWrapper, null, /*#__PURE__*/React.createElement(ResultList, { analyticsData: this.props.analyticsData, results: results, sectionIndex: sectionIndex }), moreButton); } const titleView = showTotalSize ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, title), /*#__PURE__*/React.createElement(BadgeContainer, null, /*#__PURE__*/React.createElement(Badge, { max: 99 }, totalSize))) : /*#__PURE__*/React.createElement("span", null, title); return /*#__PURE__*/React.createElement(ResultItemGroup, { title: titleView }, /*#__PURE__*/React.createElement(ResultList, { analyticsData: this.props.analyticsData, results: results, sectionIndex: sectionIndex }), moreButton); } } export default injectIntl(ResultGroup);