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,12 @@
* under the License.
*/
import React from 'react';
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import { EuiText, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiSpacer } 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 @@ -47,11 +48,25 @@ export function DiscoverFieldBucket({ field, bucket, onAddFilter }: Props) {

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}>
<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>
</EuiFlexItem>
<EuiFlexItem grow={false} className="eui-textTruncate">
<EuiText color="secondary" size="xs" className="eui-textTruncate">
{bucket.percent}%
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
<StringFieldProgressBar
value={bucket.value}
percent={bucket.percent}
count={bucket.count}
/>
</EuiFlexItem>
{field.filterable && (
<EuiFlexItem grow={false}>
Expand Down Expand Up @@ -90,7 +105,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 @@ -128,7 +128,6 @@
display: block;
}


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

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

export function StringFieldProgressBar(props: Props) {
export function StringFieldProgressBar({ value, percent, count }: Props) {
const tooltipContent = `${value} ${count}`;
return (
<EuiToolTip
anchorClassName="dscProgressBarTooltip__anchor"
content={props.count}
content={tooltipContent}
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>
<EuiProgress value={percent} max={100} color="secondary" aria-hidden={true} size="s" />
</EuiToolTip>
);
}