-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add icons to search preview document flyout
- Loading branch information
Sloane Perrault
committed
Mar 28, 2023
1 parent
c2910f9
commit b68b0e5
Showing
5 changed files
with
92 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ise_search/public/applications/enterprise_search_content/components/engine/field_icon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { EuiTokenProps } from '@elastic/eui'; | ||
import { FieldIcon as KbnFieldIcon } from '@kbn/react-field'; | ||
|
||
// Remappings from type to a supported `FieldIcon` type | ||
const typeToFieldIconType: Partial<Record<string, string>> = { | ||
integer: 'number', | ||
}; | ||
|
||
// Mappings for types missing from `FieldIcon` | ||
const typeToEuiIconMap: Partial<Record<string, EuiTokenProps>> = { | ||
object: { color: 'euiColorVis3', iconType: 'tokenObject' }, | ||
}; | ||
|
||
export interface FieldIconProps { | ||
type: string; | ||
} | ||
|
||
export const FieldIcon: React.FC<FieldIconProps> = (props) => { | ||
const type = typeToFieldIconType[props.type] || props.type; | ||
const overrides = typeToEuiIconMap[type] || {}; | ||
return <KbnFieldIcon type={type} {...overrides} />; | ||
}; |