@atlaskit/global-search
Version:
A cross-product search component (batteries included)
39 lines (33 loc) • 1.16 kB
JavaScript
import React from 'react';
import styled from 'styled-components';
import BoardIcon from '@atlaskit/icon/glyph/board';
import IssueIcon from '@atlaskit/icon/glyph/issue';
import FilterIcon from '@atlaskit/icon/glyph/filter'; // AFP-2532 TODO: Fix automatic suppressions below
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
import { gridSize } from '@atlaskit/theme';
import { ContentType } from '../model/Result';
const IconWrapper = styled.div`
width: ${7 * gridSize() / 2}px;
height: ${7 * gridSize() / 2}px;
align-items: center;
display: flex;
`;
const getIconComponent = contentType => {
switch (contentType) {
case ContentType.JiraIssue:
return IssueIcon;
case ContentType.JiraBoard:
return BoardIcon;
case ContentType.JiraFilter:
return FilterIcon;
default:
return null;
}
};
export const getDefaultAvatar = contentType => {
const IconComponent = getIconComponent(contentType);
return IconComponent ? /*#__PURE__*/React.createElement(IconWrapper, null, /*#__PURE__*/React.createElement(IconComponent, {
label: contentType || '',
size: "medium"
})) : null;
};