-
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
[Lens] Update frame to put suggestions at the bottom #42997
Changes from 5 commits
342b009
587cd80
d702d0a
8281629
27885a5
f6e7e70
144fbca
4d7fc88
4342a18
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 |
---|---|---|
@@ -1,21 +1,57 @@ | ||
.lnsSidebar__suggestions { | ||
> * { | ||
margin-top: $euiSizeS; | ||
// SASSTODO: Create this in EUI | ||
@mixin lnsOverflowShadowHorizontal { | ||
$hideHeight: $euiScrollBarCorner * 1.25; | ||
mask-image: linear-gradient(to right, | ||
transparentize(red, .9) 0%, | ||
transparentize(red, 0) $hideHeight, | ||
transparentize(red, 0) calc(100% - #{$hideHeight}), | ||
transparentize(red, .9) 100% | ||
); | ||
} | ||
|
||
.lnsSuggestionsPanel__title { | ||
margin: $euiSizeS 0 $euiSizeXS; | ||
} | ||
|
||
.lnsSuggestionsPanel__suggestions { | ||
@include euiScrollBar; | ||
@include lnsOverflowShadowHorizontal; | ||
padding-top: $euiSizeXS; | ||
overflow-x: auto; | ||
overflow-y: hidden; | ||
display: flex; | ||
|
||
// Padding / negative margins to make room for overflow shadow | ||
padding-left: $euiSizeXS; | ||
margin-left: -$euiSizeXS; | ||
|
||
// Add margin to the next of the same type | ||
> * + * { | ||
margin-left: $euiSizeS; | ||
} | ||
} | ||
|
||
$suggestionHeight: 120px; | ||
$suggestionHeight: 100px; | ||
|
||
.lnsSuggestionPanel__button { | ||
flex: 0 0 auto; | ||
width: 150px !important; | ||
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. May as well make a var for this one as well. |
||
height: $suggestionHeight; | ||
// Allows the scrollbar to stay flush to window | ||
margin-bottom: $euiSize; | ||
} | ||
|
||
.lnsSidebar__suggestionIcon { | ||
color: $euiColorDarkShade; | ||
width: 100%; | ||
height: $suggestionHeight; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: $euiSize; | ||
padding: $euiSizeS; | ||
} | ||
|
||
.lnsSuggestionChartWrapper { | ||
height: $suggestionHeight; | ||
pointer-events: none; | ||
} | ||
.lnsSuggestionChartWrapper { | ||
height: $suggestionHeight - $euiSize; | ||
pointer-events: none; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
import React, { useState, useEffect } from 'react'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { EuiIcon, EuiTitle, EuiPanel, EuiIconTip } from '@elastic/eui'; | ||
import { EuiIcon, EuiTitle, EuiPanel, EuiIconTip, EuiToolTip } from '@elastic/eui'; | ||
import { toExpression } from '@kbn/interpreter/common'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { Action } from './state_management'; | ||
|
@@ -51,46 +51,49 @@ const SuggestionPreview = ({ | |
}, [previewExpression]); | ||
|
||
return ( | ||
<EuiPanel | ||
paddingSize="s" | ||
data-test-subj="suggestion" | ||
onClick={() => { | ||
dispatch(toSwitchAction(suggestion)); | ||
}} | ||
> | ||
<EuiTitle size="xxxs"> | ||
<EuiToolTip content={suggestion.title}> | ||
<EuiPanel | ||
className="lnsSuggestionPanel__button" | ||
paddingSize="none" | ||
data-test-subj="lnsSuggestion" | ||
onClick={() => { | ||
dispatch(toSwitchAction(suggestion)); | ||
}} | ||
> | ||
{/* <EuiText size="xs"> | ||
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. nit: commented out code 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. Yeah I had left it in to remind whoever was helping with tests what the test was targeting before. I'll remove it now |
||
<h4 data-test-subj="suggestion-title">{suggestion.title}</h4> | ||
</EuiTitle> | ||
{expressionError ? ( | ||
<div className="lnsSidebar__suggestionIcon"> | ||
<EuiIconTip | ||
size="xxl" | ||
color="danger" | ||
type="cross" | ||
aria-label={i18n.translate('xpack.lens.editorFrame.previewErrorLabel', { | ||
defaultMessage: 'Preview rendering failed', | ||
})} | ||
content={i18n.translate('xpack.lens.editorFrame.previewErrorTooltip', { | ||
defaultMessage: 'Preview rendering failed', | ||
})} | ||
</EuiText> */} | ||
{expressionError ? ( | ||
<div className="lnsSidebar__suggestionIcon"> | ||
<EuiIconTip | ||
size="xxl" | ||
color="danger" | ||
type="cross" | ||
aria-label={i18n.translate('xpack.lens.editorFrame.previewErrorLabel', { | ||
defaultMessage: 'Preview rendering failed', | ||
})} | ||
content={i18n.translate('xpack.lens.editorFrame.previewErrorTooltip', { | ||
defaultMessage: 'Preview rendering failed', | ||
})} | ||
/> | ||
</div> | ||
) : previewExpression ? ( | ||
<ExpressionRendererComponent | ||
className="lnsSuggestionChartWrapper" | ||
expression={previewExpression} | ||
onRenderFailure={(e: unknown) => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Failed to render preview: `, e); | ||
setExpressionError(true); | ||
}} | ||
/> | ||
</div> | ||
) : previewExpression ? ( | ||
<ExpressionRendererComponent | ||
className="lnsSuggestionChartWrapper" | ||
expression={previewExpression} | ||
onRenderFailure={(e: unknown) => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Failed to render preview: `, e); | ||
setExpressionError(true); | ||
}} | ||
/> | ||
) : ( | ||
<div className="lnsSidebar__suggestionIcon"> | ||
<EuiIcon size="xxl" color="subdued " type={suggestion.previewIcon} /> | ||
</div> | ||
)} | ||
</EuiPanel> | ||
) : ( | ||
<div className="lnsSidebar__suggestionIcon"> | ||
<EuiIcon size="xxl" type={suggestion.previewIcon} /> | ||
</div> | ||
)} | ||
</EuiPanel> | ||
</EuiToolTip> | ||
); | ||
}; | ||
|
||
|
@@ -125,33 +128,35 @@ function InnerSuggestionPanel({ | |
} | ||
|
||
return ( | ||
<div className="lnsSidebar__suggestions"> | ||
<EuiTitle size="xs"> | ||
<div className="lnsSuggestionsPanel"> | ||
<EuiTitle className="lnsSuggestionsPanel__title" size="xxs"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.lens.editorFrame.suggestionPanelTitle" | ||
defaultMessage="Suggestions" | ||
/> | ||
</h3> | ||
</EuiTitle> | ||
{suggestions.map(suggestion => { | ||
const previewExpression = suggestion.previewExpression | ||
? prependDatasourceExpression( | ||
suggestion.previewExpression, | ||
datasourceMap, | ||
datasourceStates | ||
) | ||
: null; | ||
return ( | ||
<SuggestionPreview | ||
suggestion={suggestion} | ||
dispatch={dispatch} | ||
ExpressionRenderer={ExpressionRendererComponent} | ||
previewExpression={previewExpression ? toExpression(previewExpression) : undefined} | ||
key={`${suggestion.visualizationId}-${suggestion.title}`} | ||
/> | ||
); | ||
})} | ||
<div className="lnsSuggestionsPanel__suggestions"> | ||
{suggestions.map(suggestion => { | ||
const previewExpression = suggestion.previewExpression | ||
? prependDatasourceExpression( | ||
suggestion.previewExpression, | ||
datasourceMap, | ||
datasourceStates | ||
) | ||
: null; | ||
return ( | ||
<SuggestionPreview | ||
suggestion={suggestion} | ||
dispatch={dispatch} | ||
ExpressionRenderer={ExpressionRendererComponent} | ||
previewExpression={previewExpression ? toExpression(previewExpression) : undefined} | ||
key={`${suggestion.visualizationId}-${suggestion.title}`} | ||
/> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
} |
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.
This is nice. Made an issue so we remember.
elastic/eui#2215
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.
TY!