mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Update EUI to 0.0.14 * Make metrics text white when on dark color
This commit is contained in:
parent
8b6ca9f6f7
commit
046a262f2c
4 changed files with 25 additions and 6 deletions
|
@ -75,7 +75,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@elastic/datemath": "4.0.2",
|
||||
"@elastic/eui": "0.0.13",
|
||||
"@elastic/eui": "0.0.14",
|
||||
"@elastic/filesaver": "1.1.2",
|
||||
"@elastic/numeral": "2.3.0",
|
||||
"@elastic/test-subj-selector": "0.2.1",
|
||||
|
|
|
@ -16,4 +16,8 @@
|
|||
margin: auto;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.metric-container--light {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import _ from 'lodash';
|
||||
import React, { Component } from 'react';
|
||||
import { getHeatmapColors } from 'ui/vislib/components/color/heatmap_color';
|
||||
import { isColorDark } from '@elastic/eui';
|
||||
import classNames from 'classnames';
|
||||
|
||||
export class MetricVisComponent extends Component {
|
||||
|
||||
|
@ -54,6 +56,14 @@ export class MetricVisComponent extends Component {
|
|||
return colors[label];
|
||||
}
|
||||
|
||||
_needsLightText(bgColor) {
|
||||
const color = /rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(bgColor);
|
||||
if (!color) {
|
||||
return false;
|
||||
}
|
||||
return isColorDark(parseInt(color[1]), parseInt(color[2]), parseInt(color[3]));
|
||||
}
|
||||
|
||||
_processTableGroups(tableGroups) {
|
||||
const config = this.props.vis.params.metric;
|
||||
const isPercentageMode = config.percentageMode;
|
||||
|
@ -101,7 +111,8 @@ export class MetricVisComponent extends Component {
|
|||
label: title,
|
||||
value: value,
|
||||
color: shouldColor && config.style.labelColor ? color : null,
|
||||
bgColor: shouldColor && config.style.bgColor ? color : null
|
||||
bgColor: shouldColor && config.style.bgColor ? color : null,
|
||||
lightText: shouldColor && config.style.bgColor && this._needsLightText(color),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -116,10 +127,14 @@ export class MetricVisComponent extends Component {
|
|||
color: metric.color
|
||||
};
|
||||
|
||||
const containerClassName = classNames('metric-container', {
|
||||
'metric-container--light': metric.lightText
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className="metric-container"
|
||||
className={containerClassName}
|
||||
style={{ backgroundColor: metric.bgColor }}
|
||||
>
|
||||
<div
|
||||
|
|
|
@ -87,9 +87,9 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@elastic/eui@0.0.13":
|
||||
version "0.0.13"
|
||||
resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-0.0.13.tgz#aa3a71c6bfc41978366c29a4254b3a8d1953108f"
|
||||
"@elastic/eui@0.0.14":
|
||||
version "0.0.14"
|
||||
resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-0.0.14.tgz#18842465e11ee96d1b90813e7fd38bef2c65bc8b"
|
||||
dependencies:
|
||||
brace "^0.10.0"
|
||||
classnames "^2.2.5"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue