Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"@elastic/apm-rum": "5.17.0",
"@elastic/apm-rum-core": "5.23.0",
"@elastic/apm-rum-react": "2.0.6",
"@elastic/charts": "71.2.0",
"@elastic/charts": "71.3.0",
"@elastic/datemath": "5.0.3",
"@elastic/ebt": "1.4.1",
"@elastic/ecs": "9.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type SecondaryTrend =
baselineValue: number | 'primary';
};

type TitleFontWeightString = Extract<TitleFontWeight, string>;

export interface MetricVisualizationState {
layerId: string;
layerType: LensLayerType;
Expand Down Expand Up @@ -60,7 +62,7 @@ export interface MetricVisualizationState {
primaryAlign?: MetricStyle['valueTextAlign'];
iconAlign?: MetricStyle['iconAlign'];
valueFontMode?: ValueFontMode;
titleWeight?: MetricStyle['titleWeight'];
titleWeight?: TitleFontWeightString;
primaryPosition?: MetricStyle['valuePosition'];
secondaryLabelPosition?: SecondaryMetricProps['labelPosition'];
color?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
LENS_METRIC_STATE_DEFAULTS,
} from '@kbn/lens-common';

type TitleFontWeightString = Extract<TitleFontWeight, string>;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update the type to accept 500 when implementing #252834. For now, I just allowed string font weights as before.


/** Get default layout config based on primary metric position */
const getDefaultLayoutConfig = (
primaryMetricPosition: PrimaryMetricPosition,
Expand Down Expand Up @@ -61,6 +63,10 @@ export function MetricAppearanceSettings({
}) {
const hasSecondaryMetric = !!state.secondaryMetricAccessor;
const hasMetricIcon = hasIcon(state.icon);
const titleWeightValue: TitleFontWeightString =
state.titleWeight === 'normal' || state.titleWeight === 'bold'
? state.titleWeight
: (LENS_METRIC_STATE_DEFAULTS.titleWeight as TitleFontWeightString);

const disabledStates = {
subtitle: !!state.breakdownByAccessor,
Expand Down Expand Up @@ -155,7 +161,7 @@ export function MetricAppearanceSettings({
label={i18n.translate('xpack.lens.metric.appearancePopover.fontWeight', {
defaultMessage: 'Font weight',
})}
value={state.titleWeight ?? LENS_METRIC_STATE_DEFAULTS.titleWeight}
value={titleWeightValue}
options={fontWeightOptions}
onChange={(id) => {
setState({
Expand Down Expand Up @@ -340,7 +346,7 @@ const iconPositionOptions: Array<EuiButtonGroupOptionProps & { id: IconPosition
},
];

const fontWeightOptions: Array<EuiButtonGroupOptionProps & { id: TitleFontWeight }> = [
const fontWeightOptions: Array<EuiButtonGroupOptionProps & { id: TitleFontWeightString }> = [
{
id: 'normal',
label: i18n.translate('xpack.lens.metric.appearancePopover.regular', {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2335,10 +2335,10 @@
dependencies:
object-hash "^1.3.0"

"@elastic/charts@71.2.0":
version "71.2.0"
resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-71.2.0.tgz#884bec027ebccbbdd6dc8a6d990415fa90b24cf4"
integrity sha512-y/sf6yKsajsQhEueLU4HlG4z4j1c9VvgxTsX+AEG81zBAJLWfQ+eaO3hbH3cL1qFEm2KJLn5RF3/cpm5wu3ADg==
"@elastic/charts@71.3.0":
version "71.3.0"
resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-71.3.0.tgz#5fba40d1d78fae7cca7f73e6bb0b2b2cd4d683e4"
integrity sha512-F6GkcsVWQcigtAzbRe4MFIkNgkZjjZ9JTL603AcK46WF2zEW3yKQ0KOoEAh85gzbBnEdDksXWWhWPGvY4508cQ==
dependencies:
"@popperjs/core" "^2.11.8"
"@reduxjs/toolkit" "1.9.7"
Expand Down
Loading