-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] Search Applications - Icons for Document Flyout (#…
…153899) ## Summary - Updates document flyout to include icon for the field types <img width="1308" alt="image" src="https://user-images.githubusercontent.com/1699281/228359668-aa036249-4f91-4c07-a07d-c0eb0fc8ad91.png"> ### Checklist Delete any items that are not applicable to this PR. - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- Loading branch information
Sloane Perrault
authored
Mar 29, 2023
1 parent
c770e9d
commit ec58ba6
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} />; | ||
}; |