Skip to content
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

[Discover] Improve styling of graphs in sidebar #69440

Merged
merged 13 commits into from
Jun 26, 2020
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.dscFieldDetails__barContainer {
// Constrains value to the flex item, and allows for truncation when necessary
min-width: 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@
* under the License.
*/
import React from 'react';
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import {
EuiText,
EuiButtonIcon,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
EuiToolTip,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { StringFieldProgressBar } from './string_progress_bar';
import { Bucket } from './types';
import { IndexPatternField } from '../../../../../data/public';
import './discover_field_bucket.scss';

interface Props {
bucket: Bucket;
Expand All @@ -45,13 +53,29 @@ export function DiscoverFieldBucket({ field, bucket, onAddFilter }: Props) {
}
);

const tooltipContent = `${bucket.value}: ${bucket.count} (${bucket.percent}%)`;

return (
<>
<EuiFlexGroup gutterSize="xs" responsive={false}>
<EuiFlexItem className="eui-textTruncate">
<EuiText size="xs" className="eui-textTruncate">
{bucket.display === '' ? emptyTxt : bucket.display}
</EuiText>
<EuiFlexGroup justifyContent="spaceBetween" responsive={false} gutterSize="s">
<EuiFlexItem className="dscFieldDetails__barContainer" grow={1}>
<EuiToolTip content={tooltipContent} delay="long" position="right">
<>
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="xs" responsive={false}>
<EuiFlexItem grow={1} className="eui-textTruncate">
<EuiText size="xs" className="eui-textTruncate">
{bucket.display === '' ? emptyTxt : bucket.display}
</EuiText>
andreadelrio marked this conversation as resolved.
Show resolved Hide resolved
</EuiFlexItem>
<EuiFlexItem grow={false} className="eui-textTruncate">
<EuiText color="secondary" size="xs" className="eui-textTruncate">
{bucket.percent}%
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
<StringFieldProgressBar percent={bucket.percent} />
</>
</EuiToolTip>
</EuiFlexItem>
{field.filterable && (
<EuiFlexItem grow={false}>
andreadelrio marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -90,7 +114,7 @@ export function DiscoverFieldBucket({ field, bucket, onAddFilter }: Props) {
</EuiFlexItem>
)}
</EuiFlexGroup>
<StringFieldProgressBar percent={bucket.percent} count={bucket.count} />
<EuiSpacer size="s" />
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { EuiLink, EuiSpacer, EuiIconTip, EuiText } from '@elastic/eui';
import { EuiLink, EuiIconTip, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { DiscoverFieldBucket } from './discover_field_bucket';
import { getWarnings } from './lib/get_warnings';
Expand Down Expand Up @@ -78,7 +78,6 @@ export function DiscoverFieldDetails({

{details.visualizeUrl && (
<>
<EuiSpacer size={'s'} />
<EuiLink
onClick={() => {
getServices().core.application.navigateToApp(details.visualizeUrl.app, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@
}
}

/*
Fixes EUI known issue https://github.com/elastic/eui/issues/1749
*/
.dscProgressBarTooltip__anchor {
display: block;
}


.dscFieldSearch {
padding: $euiSizeS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,12 @@
* under the License.
*/
import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiProgress, EuiText, EuiToolTip } from '@elastic/eui';
import { EuiProgress } from '@elastic/eui';

interface Props {
percent: number;
count: number;
}

export function StringFieldProgressBar(props: Props) {
return (
<EuiToolTip
anchorClassName="dscProgressBarTooltip__anchor"
content={props.count}
delay="regular"
position="right"
>
<EuiFlexGroup alignItems="center" responsive={false}>
<EuiFlexItem>
<EuiProgress
value={props.percent}
max={100}
color="secondary"
aria-hidden={true}
size="l"
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="xs">{props.percent}%</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
</EuiToolTip>
);
export function StringFieldProgressBar({ percent }: Props) {
return <EuiProgress value={percent} max={100} color="secondary" aria-hidden={true} size="s" />;
andreadelrio marked this conversation as resolved.
Show resolved Hide resolved
}