-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App Search: Result Component Updates #96184
Changes from 1 commit
31cc2aa
97cbb6f
cd5488e
b2af29b
d3fbe43
8bbf023
f687a1b
8f8ed5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
'drag content actions' | ||
'drag toggle actions'; | ||
overflow: hidden; // Prevents child background-colors from clipping outside of panel border-radius | ||
border: $euiBorderThin; // TODO: Remove after EUI version is bumped beyond 31.8.0 | ||
|
||
&__content { | ||
grid-area: content; | ||
|
@@ -44,9 +45,13 @@ | |
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: $euiSizeL * 2; | ||
width: $euiSize * 2; | ||
border-left: $euiBorderThin; | ||
|
||
&:first-child { | ||
border-left: none; | ||
} | ||
|
||
&:hover, | ||
&:focus { | ||
background-color: $euiPageBackgroundColor; | ||
|
@@ -62,22 +67,3 @@ | |
border-right: $euiBorderThin; | ||
} | ||
} | ||
|
||
/** | ||
* CSS for hover specific logic | ||
* It's mildly horrific, so I pulled it out to its own section here | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 I'm super glad I pulled this out into its own easily delete-able section. H E L L Y E A |
||
*/ | ||
|
||
.appSearchResult--link { | ||
&:hover, | ||
&:focus { | ||
@include euiSlightShadowHover; | ||
} | ||
} | ||
.appSearchResult__content--link:hover { | ||
cursor: pointer; | ||
|
||
& ~ .appSearchResult__actionButtons .appSearchResult__actionButton--link { | ||
background-color: $euiPageBackgroundColor; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,16 +8,15 @@ | |||||
import React, { useState, useMemo } from 'react'; | ||||||
import { DraggableProvidedDragHandleProps } from 'react-beautiful-dnd'; | ||||||
|
||||||
import classNames from 'classnames'; | ||||||
|
||||||
import './result.scss'; | ||||||
|
||||||
import { EuiPanel, EuiIcon } from '@elastic/eui'; | ||||||
import { EuiButtonIcon, EuiPanel, EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui'; | ||||||
import { i18n } from '@kbn/i18n'; | ||||||
|
||||||
import { ReactRouterHelper } from '../../../shared/react_router_helpers/eui_components'; | ||||||
|
||||||
import { Schema } from '../../../shared/types'; | ||||||
|
||||||
import { ENGINE_DOCUMENT_DETAIL_PATH } from '../../routes'; | ||||||
import { generateEncodedPath } from '../../utils/encode_path_params'; | ||||||
|
||||||
|
@@ -56,34 +55,53 @@ export const Result: React.FC<Props> = ({ | |||||
[result] | ||||||
); | ||||||
const numResults = resultFields.length; | ||||||
const typeForField = (fieldName: string) => { | ||||||
if (schemaForTypeHighlights) return schemaForTypeHighlights[fieldName]; | ||||||
}; | ||||||
|
||||||
const documentLink = generateEncodedPath(ENGINE_DOCUMENT_DETAIL_PATH, { | ||||||
engineName: resultMeta.engine, | ||||||
documentId: resultMeta.id, | ||||||
}); | ||||||
const conditionallyLinkedArticle = (children: React.ReactNode) => { | ||||||
return shouldLinkToDetailPage ? ( | ||||||
<ReactRouterHelper to={documentLink}> | ||||||
<article className="appSearchResult__content appSearchResult__content--link"> | ||||||
{children} | ||||||
</article> | ||||||
</ReactRouterHelper> | ||||||
) : ( | ||||||
<article className="appSearchResult__content">{children}</article> | ||||||
); | ||||||
|
||||||
const typeForField = (fieldName: string) => { | ||||||
if (schemaForTypeHighlights) return schemaForTypeHighlights[fieldName]; | ||||||
}; | ||||||
|
||||||
const classes = classNames('appSearchResult', { | ||||||
'appSearchResult--link': shouldLinkToDetailPage, | ||||||
}); | ||||||
const ResultActions = () => { | ||||||
if (!shouldLinkToDetailPage && !actions.length) return null; | ||||||
return ( | ||||||
<EuiFlexItem grow={false}> | ||||||
<EuiFlexGroup gutterSize="s"> | ||||||
{shouldLinkToDetailPage && ( | ||||||
<ReactRouterHelper to={documentLink}> | ||||||
<EuiFlexItem grow={false}> | ||||||
<EuiButtonIcon | ||||||
iconType="eye" | ||||||
aria-label={i18n.translate( | ||||||
'xpack.enterpriseSearch.appSearch.result.documentDetailLink', | ||||||
{ defaultMessage: 'Visit document details' } | ||||||
)} | ||||||
/> | ||||||
</EuiFlexItem> | ||||||
</ReactRouterHelper> | ||||||
)} | ||||||
{actions.map(({ onClick, title, iconType, iconColor }) => ( | ||||||
<EuiFlexItem key={title}> | ||||||
<EuiButtonIcon | ||||||
iconType={iconType} | ||||||
onClick={onClick} | ||||||
color={iconColor ? 'primary' : undefined} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ran across this while writing tests ... I assume this is a mistake and should be:
Suggested change
Can you confirm? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha. Yes. |
||||||
aria-label={title} | ||||||
/> | ||||||
</EuiFlexItem> | ||||||
))} | ||||||
</EuiFlexGroup> | ||||||
</EuiFlexItem> | ||||||
); | ||||||
}; | ||||||
|
||||||
return ( | ||||||
<EuiPanel | ||||||
paddingSize="none" | ||||||
className={classes} | ||||||
hasShadow={false} | ||||||
className="appSearchResult" | ||||||
data-test-subj="AppSearchResult" | ||||||
title={i18n.translate('xpack.enterpriseSearch.appSearch.result.title', { | ||||||
defaultMessage: 'Document {id}', | ||||||
|
@@ -95,26 +113,26 @@ export const Result: React.FC<Props> = ({ | |||||
<EuiIcon type="grab" /> | ||||||
</div> | ||||||
)} | ||||||
{conditionallyLinkedArticle( | ||||||
<> | ||||||
<ResultHeader | ||||||
resultMeta={resultMeta} | ||||||
showScore={!!showScore} | ||||||
isMetaEngine={isMetaEngine} | ||||||
/> | ||||||
{resultFields | ||||||
.slice(0, isOpen ? resultFields.length : RESULT_CUTOFF) | ||||||
.map(([field, value]: [string, FieldValue]) => ( | ||||||
<ResultField | ||||||
key={field} | ||||||
field={field} | ||||||
raw={value.raw} | ||||||
snippet={value.snippet} | ||||||
type={typeForField(field)} | ||||||
/> | ||||||
))} | ||||||
</> | ||||||
)} | ||||||
<article className="appSearchResult__content"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, I'm glad this entire section is no longer linked |
||||||
<ResultHeader | ||||||
resultMeta={resultMeta} | ||||||
showScore={!!showScore} | ||||||
isMetaEngine={isMetaEngine} | ||||||
shouldLinkToDetailPage={shouldLinkToDetailPage} | ||||||
actions={<ResultActions />} | ||||||
/> | ||||||
{resultFields | ||||||
.slice(0, isOpen ? resultFields.length : RESULT_CUTOFF) | ||||||
.map(([field, value]: [string, FieldValue]) => ( | ||||||
<ResultField | ||||||
key={field} | ||||||
field={field} | ||||||
raw={value.raw} | ||||||
snippet={value.snippet} | ||||||
type={typeForField(field)} | ||||||
/> | ||||||
))} | ||||||
</article> | ||||||
{numResults > RESULT_CUTOFF && ( | ||||||
<button | ||||||
type="button" | ||||||
|
@@ -138,33 +156,6 @@ export const Result: React.FC<Props> = ({ | |||||
/> | ||||||
</button> | ||||||
)} | ||||||
<div className="appSearchResult__actionButtons"> | ||||||
{shouldLinkToDetailPage && ( | ||||||
<ReactRouterHelper to={documentLink}> | ||||||
<a | ||||||
className="appSearchResult__actionButton appSearchResult__actionButton--link" | ||||||
aria-label={i18n.translate( | ||||||
'xpack.enterpriseSearch.appSearch.result.documentDetailLink', | ||||||
{ defaultMessage: 'Visit document details' } | ||||||
)} | ||||||
> | ||||||
<EuiIcon type="eye" /> | ||||||
</a> | ||||||
</ReactRouterHelper> | ||||||
)} | ||||||
{actions.map(({ onClick, title, iconType, iconColor }) => ( | ||||||
<button | ||||||
key={title} | ||||||
aria-label={title} | ||||||
title={title} | ||||||
onClick={onClick} | ||||||
className="appSearchResult__actionButton" | ||||||
type="button" | ||||||
> | ||||||
<EuiIcon type={iconType} color={iconColor} /> | ||||||
</button> | ||||||
))} | ||||||
</div> | ||||||
</EuiPanel> | ||||||
); | ||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
.appSearchResultHeaderItem { | ||
display: flex; | ||
.euiFlexItem:not(:first-child):not(:last-child) .appSearchResultHeaderItem { | ||
padding-right: .75rem; | ||
box-shadow: inset -1px 0 0 0 $euiBorderColor; | ||
} | ||
|
||
&__key, | ||
&__value { | ||
line-height: $euiLineHeight; | ||
font-size: $euiFontSizeXS; | ||
} | ||
.appSearchResultHeaderItem { | ||
@include euiCodeFont; | ||
|
||
&__key { | ||
text-transform: uppercase; | ||
font-weight: $euiFontWeightLight; | ||
color: $euiColorDarkShade; | ||
margin-right: $euiSizeXS; | ||
&__score { | ||
color: $euiColorSuccessText; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.