Skip to content
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
ffbcf1b
Extract titles block component and separate extra and value blocks
mariairiartef Jun 11, 2025
8e5a961
Add ability to move value to the top and use grid for text handling
mariairiartef Jun 12, 2025
c97c469
Add default value position
mariairiartef Jun 12, 2025
50449eb
Update width calculation when there is an icon for getting the font size
mariairiartef Jun 13, 2025
593b3fc
Handle title font weight configuration
mariairiartef Jun 16, 2025
1e4fb14
Take into account icon width for value font size calculation only if …
mariairiartef Jun 16, 2025
797dc92
Avoid grid overflowing
mariairiartef Jun 17, 2025
5fcef4d
Add breackpoints to new layout story
mariairiartef Jun 17, 2025
aa3a932
Update progress bar style
mariairiartef Jun 17, 2025
8838f71
Update height when there is an horizontal progress bar
mariairiartef Jun 17, 2025
7abb452
Support different progress bar thickness based on height
mariairiartef Jun 19, 2025
23687a7
Fix typos
mariairiartef Jun 19, 2025
2c7955d
Refactor progress bar types and styles
mariairiartef Jun 20, 2025
a00bccc
Allow smaller breakpoints
mariairiartef Jun 23, 2025
7dc5b9c
Support different colors for subtitle and extra
mariairiartef Jun 23, 2025
0455497
Refactor grid logic rows and columns calculation
mariairiartef Jun 24, 2025
cd7c6f0
Add secondary metric component
mariairiartef Jun 25, 2025
aced3a4
Extract badge component, update and re-organize styles
mariairiartef Jul 1, 2025
03caf3f
Fix lint issues
mariairiartef Jul 1, 2025
8bfbc3f
Re-organize new layout config story
mariairiartef Jul 1, 2025
d4c8d11
Merge branch 'main' into metric-new-positions
mariairiartef Jul 1, 2025
ba0d8de
Move SecondaryMetricProps type to specs and update api
mariairiartef Jul 1, 2025
5757b84
Fix typos
mariairiartef Jul 1, 2025
fc433a1
Add test case for new config
mariairiartef Jul 1, 2025
147a33a
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Jul 1, 2025
baaffb4
Add resize to new story
mariairiartef Jul 1, 2025
439ff18
Update progress bar styles
mariairiartef Jul 2, 2025
6f6a86e
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Jul 2, 2025
7f74114
Fix progress bar styles border
mariairiartef Jul 2, 2025
57ac6e3
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Jul 2, 2025
2525c01
Update target styles
mariairiartef Jul 2, 2025
c9f273b
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Jul 2, 2025
9690d35
Fix progress styles
mariairiartef Jul 2, 2025
3fa66b6
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Jul 2, 2025
cec8aa9
Add missing styles for zero baseline
mariairiartef Jul 3, 2025
0ed6b85
Update e2e/tests/metric_stories.test.ts
mariairiartef Jul 3, 2025
f0d1895
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Jul 3, 2025
926bca1
Update height based sizes considering the width
mariairiartef Jul 3, 2025
8cf460b
Add aria description to secondary metric
mariairiartef Jul 4, 2025
e2750f7
Update subtitle text color and use different color picker palette in …
mariairiartef Jul 9, 2025
e57cb11
Fix new metric layout story resizer
mariairiartef Jul 10, 2025
1378c77
Add border color prop to badge component
mariairiartef Jul 10, 2025
baac74d
Update secondaty metric content styles
mariairiartef Jul 14, 2025
784daef
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Jul 14, 2025
00ea9ab
Update api
mariairiartef Jul 14, 2025
a3d9cd5
Merge branch 'main' into metric-new-positions
mariairiartef Jul 18, 2025
2a906ce
Rename layout story
mariairiartef Jul 28, 2025
2fe1771
Delete comment
mariairiartef Jul 28, 2025
2e788a8
Update font weight type
mariairiartef Jul 28, 2025
c051d23
Apply title suggestion
mariairiartef Jul 28, 2025
bdd449c
Create color tokens for badge
mariairiartef Jul 28, 2025
c64f4e3
Update metric style theme
mariairiartef Jul 28, 2025
955035e
Update story test
mariairiartef Jul 28, 2025
bb4f5e7
Update styles when top element is center-aligned and there is an icon
mariairiartef Jul 28, 2025
524e518
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Jul 29, 2025
bcf8455
Fix styles when there is no label in secondary metric
mariairiartef Aug 1, 2025
a6d8a05
Add ability to add icon to badge component
mariairiartef Aug 1, 2025
16a360f
Create file for metric scss variables
mariairiartef Aug 1, 2025
15f42c7
Update badge styles when no value
mariairiartef Aug 1, 2025
cab7d3b
Add tests for different metric layout configurations
mariairiartef Aug 1, 2025
954c671
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Aug 1, 2025
a770838
Merge branch 'main' into metric-new-positions
mariairiartef Aug 4, 2025
949b0ec
Fix prettier issue
mariairiartef Aug 4, 2025
9a23af9
Update layout stories and tests
mariairiartef Aug 4, 2025
26c2b94
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Aug 4, 2025
b426ece
Delete snapshots
mariairiartef Aug 4, 2025
09df91a
Update tests
mariairiartef Aug 4, 2025
cc7b4ef
Remove circular dependency
mariairiartef Aug 4, 2025
1f2e878
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Aug 4, 2025
eb7ef8e
Merge branch 'main' into metric-new-positions
mariairiartef Aug 5, 2025
8b2d00c
Apply theme suggestions
mariairiartef Aug 6, 2025
aed04e7
Move variables into variables.scss file
mariairiartef Aug 6, 2025
df3f01f
Move text contrast options type
mariairiartef Aug 6, 2025
79021ee
Rename getContrastRecommendation function
mariairiartef Aug 6, 2025
8cc2b60
Apply suggestions
mariairiartef Aug 6, 2025
a7d3a86
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Aug 6, 2025
30755e1
Update tests
mariairiartef Aug 7, 2025
0ce9bd8
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Aug 7, 2025
868fff0
Fix overflow body content and add test
mariairiartef Aug 8, 2025
580fcd7
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Aug 8, 2025
bd58c93
Update layout story and tests
mariairiartef Aug 11, 2025
23debd5
test(vrt): update screenshots [skip ci]
elastic-datavis[bot] Aug 11, 2025
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions e2e/tests/metric_stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,62 @@ test.describe('Metric', () => {
}
});

test.describe('Layout configuration', () => {
test(`with default secondary and 'after' badge position`, async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/metric-alpha--layout&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-Aria description_Secondary metric=This is a description&knob-Bar background_Colors=rgb(194, 201, 214) &knob-Blending background_Colors=rgba(255,255,255,1)&knob-Color by value_Secondary metric=true&knob-Custom extra_Secondary metric=last <b>5m</b>&knob-Extra element alignment_Text configuration and position=left&knob-Is numeric metric=true&knob-Metric color_Colors=rgb(246, 217, 143)&knob-Metric icon align_Text configuration and position=right&knob-Primary metric alignment_Text configuration and position=left&knob-Primary metric font size (only if custom font size selected)_Text configuration and position=40&knob-Primary metric font size mode_Text configuration and position=default&knob-Primary metric position_Text configuration and position=top&knob-Progress bar direction=vertical&knob-Progress max=100&knob-Secondary metric trend icon side_Secondary metric=right&knob-Secondary metric trend icon_Secondary metric=↑&knob-Secondary metric value color_Secondary metric=rgb(93, 191, 149)&knob-Secondary metric value position_Secondary metric=after&knob-Secondary metric value_Secondary metric=87.20&knob-Show extra_Secondary metric=true&knob-Show metric icon_Text configuration and position=&knob-Subtitle=Little description of this component&knob-Title=Count of records&knob-Title and subtitle alignment_Text configuration and position=left&knob-Title weight_Text configuration and position=normal&knob-Trend a11y description=The trend shows a peak of CPU usage in the last 5 minutes&knob-Trend a11y title=The Cluster CPU Usage trend&knob-Trend data points=30&knob-Trend shape=area&knob-Value=55.23&knob-Visualization type=bar&knob-Value prefix=&knob-Value postfix= %&knob-Use custom extra_Secondary metric=&knob-Label_Secondary metric=Last week&knob-Use value color_Colors=&knob-Value color_Colors=#065B58&knob-Use blending background_Colors=&knob-Show value icon=`,
{
action: async () => await common.setResizeDimensions(page)({ height: 180, width: 180 }),
},
);
});

test(`with default secondary and 'before' badge position`, async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/metric-alpha--layout&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-Aria description_Secondary metric=This is a description&knob-Bar background_Colors=rgb(194, 201, 214) &knob-Blending background_Colors=rgba(255,255,255,1)&knob-Color by value_Secondary metric=true&knob-Custom extra_Secondary metric=last <b>5m</b>&knob-Extra element alignment_Text configuration and position=left&knob-Is numeric metric=true&knob-Metric color_Colors=rgb(246, 217, 143)&knob-Metric icon align_Text configuration and position=right&knob-Primary metric alignment_Text configuration and position=left&knob-Primary metric font size (only if custom font size selected)_Text configuration and position=40&knob-Primary metric font size mode_Text configuration and position=default&knob-Primary metric position_Text configuration and position=top&knob-Progress bar direction=vertical&knob-Progress max=100&knob-Secondary metric trend icon side_Secondary metric=right&knob-Secondary metric trend icon_Secondary metric=↑&knob-Secondary metric value color_Secondary metric=rgb(93, 191, 149)&knob-Secondary metric value position_Secondary metric=before&knob-Secondary metric value_Secondary metric=87.20&knob-Show extra_Secondary metric=true&knob-Show metric icon_Text configuration and position=&knob-Subtitle=Little description of this component&knob-Title=Count of records&knob-Title and subtitle alignment_Text configuration and position=left&knob-Title weight_Text configuration and position=normal&knob-Trend a11y description=The trend shows a peak of CPU usage in the last 5 minutes&knob-Trend a11y title=The Cluster CPU Usage trend&knob-Trend data points=30&knob-Trend shape=area&knob-Value=55.23&knob-Visualization type=bar&knob-Value prefix=&knob-Value postfix= %&knob-Use custom extra_Secondary metric=&knob-Label_Secondary metric=Last week&knob-Use value color_Colors=&knob-Value color_Colors=#065B58&knob-Use blending background_Colors=&knob-Show value icon=`,
{
action: async () => await common.setResizeDimensions(page)({ height: 180, width: 180 }),
},
);
});

test(`with value at the top, center aligned, and a metric icon`, async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/metric-alpha--layout&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-Aria description_Secondary metric=This is a description&knob-Bar background_Colors=rgb(194, 201, 214) &knob-Blending background_Colors=rgba(255,255,255,1)&knob-Color by value_Secondary metric=true&knob-Custom extra_Secondary metric=last <b>5m</b>&knob-Extra element alignment_Text configuration and position=left&knob-Is numeric metric=true&knob-Metric color_Colors=rgb(246, 217, 143)&knob-Metric icon align_Text configuration and position=right&knob-Primary metric alignment_Text configuration and position=center&knob-Primary metric font size (only if custom font size selected)_Text configuration and position=40&knob-Primary metric font size mode_Text configuration and position=default&knob-Primary metric position_Text configuration and position=top&knob-Progress bar direction=vertical&knob-Progress max=100&knob-Secondary metric trend icon side_Secondary metric=right&knob-Secondary metric trend icon_Secondary metric=↑&knob-Secondary metric value color_Secondary metric=rgb(93, 191, 149)&knob-Secondary metric value position_Secondary metric=after&knob-Secondary metric value_Secondary metric=87.20&knob-Show extra_Secondary metric=true&knob-Show metric icon_Text configuration and position=true&knob-Subtitle=Little description of this component&knob-Title=Count of records&knob-Title and subtitle alignment_Text configuration and position=center&knob-Title weight_Text configuration and position=normal&knob-Trend a11y description=The trend shows a peak of CPU usage in the last 5 minutes&knob-Trend a11y title=The Cluster CPU Usage trend&knob-Trend data points=30&knob-Trend shape=area&knob-Value=55.23&knob-Visualization type=bar&knob-Value prefix=&knob-Value postfix= %&knob-Use custom extra_Secondary metric=&knob-Label_Secondary metric=Last week&knob-Use value color_Colors=&knob-Value color_Colors=#065B58&knob-Use blending background_Colors=&knob-Show value icon=`,
{
action: async () => await common.setResizeDimensions(page)({ height: 180, width: 180 }),
},
);
});

test(`with titles at the top, center aligned, and a metric icon`, async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/metric-alpha--layout&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-Aria description_Secondary metric=This is a description&knob-Bar background_Colors=rgb(194, 201, 214) &knob-Blending background_Colors=rgba(255,255,255,1)&knob-Color by value_Secondary metric=true&knob-Custom extra_Secondary metric=last <b>5m</b>&knob-Extra element alignment_Text configuration and position=left&knob-Is numeric metric=true&knob-Metric color_Colors=rgb(246, 217, 143)&knob-Metric icon align_Text configuration and position=right&knob-Primary metric alignment_Text configuration and position=center&knob-Primary metric font size (only if custom font size selected)_Text configuration and position=40&knob-Primary metric font size mode_Text configuration and position=default&knob-Primary metric position_Text configuration and position=bottom&knob-Progress bar direction=vertical&knob-Progress max=100&knob-Secondary metric trend icon side_Secondary metric=right&knob-Secondary metric trend icon_Secondary metric=↑&knob-Secondary metric value color_Secondary metric=rgb(93, 191, 149)&knob-Secondary metric value position_Secondary metric=after&knob-Secondary metric value_Secondary metric=87.20&knob-Show extra_Secondary metric=true&knob-Show metric icon_Text configuration and position=true&knob-Subtitle=Little description of this component&knob-Title=Count of records&knob-Title and subtitle alignment_Text configuration and position=center&knob-Title weight_Text configuration and position=normal&knob-Trend a11y description=The trend shows a peak of CPU usage in the last 5 minutes&knob-Trend a11y title=The Cluster CPU Usage trend&knob-Trend data points=30&knob-Trend shape=area&knob-Value=55.23&knob-Visualization type=bar&knob-Value prefix=&knob-Value postfix= %&knob-Use custom extra_Secondary metric=&knob-Label_Secondary metric=Last week&knob-Use value color_Colors=&knob-Value color_Colors=#065B58&knob-Use blending background_Colors=&knob-Show value icon=`,
{
action: async () => await common.setResizeDimensions(page)({ height: 180, width: 180 }),
},
);
});

test(`with default secondary metric with badge and no label`, async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/metric-alpha--layout&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-Aria description_Secondary metric=This is a description&knob-Bar background_Colors=rgb(194, 201, 214) &knob-Blending background_Colors=rgba(255,255,255,1)&knob-Color by value_Secondary metric=true&knob-Custom extra_Secondary metric=last <b>5m</b>&knob-Extra element alignment_Text configuration and position=left&knob-Is numeric metric=true&knob-Metric color_Colors=rgb(246, 217, 143)&knob-Metric icon align_Text configuration and position=right&knob-Primary metric alignment_Text configuration and position=left&knob-Primary metric font size (only if custom font size selected)_Text configuration and position=40&knob-Primary metric font size mode_Text configuration and position=default&knob-Primary metric position_Text configuration and position=top&knob-Progress bar direction=vertical&knob-Progress max=100&knob-Secondary metric trend icon side_Secondary metric=right&knob-Secondary metric trend icon_Secondary metric=↑&knob-Secondary metric value color_Secondary metric=rgb(93, 191, 149)&knob-Secondary metric value position_Secondary metric=after&knob-Secondary metric value_Secondary metric=87.20&knob-Show extra_Secondary metric=true&knob-Show metric icon_Text configuration and position=&knob-Subtitle=Little description of this component&knob-Title=Count of records&knob-Title and subtitle alignment_Text configuration and position=left&knob-Title weight_Text configuration and position=normal&knob-Trend a11y description=The trend shows a peak of CPU usage in the last 5 minutes&knob-Trend a11y title=The Cluster CPU Usage trend&knob-Trend data points=30&knob-Trend shape=area&knob-Value=55.23&knob-Visualization type=bar&knob-Value prefix=&knob-Value postfix= %&knob-Use custom extra_Secondary metric=&knob-Label_Secondary metric=&knob-Use value color_Colors=&knob-Value color_Colors=#065B58&knob-Use blending background_Colors=&knob-Show value icon=`,
{
action: async () => await common.setResizeDimensions(page)({ height: 180, width: 180 }),
},
);
});

test(`with default secondary metric with no badge and no label`, async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)(
`http://localhost:9001/?path=/story/metric-alpha--layout&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-Aria description_Secondary metric=This is a description&knob-Bar background_Colors=rgb(194, 201, 214) &knob-Blending background_Colors=rgba(255,255,255,1)&knob-Color by value_Secondary metric=&knob-Custom extra_Secondary metric=last <b>5m</b>&knob-Extra element alignment_Text configuration and position=left&knob-Is numeric metric=true&knob-Metric color_Colors=rgb(246, 217, 143)&knob-Metric icon align_Text configuration and position=right&knob-Primary metric alignment_Text configuration and position=left&knob-Primary metric font size (only if custom font size selected)_Text configuration and position=40&knob-Primary metric font size mode_Text configuration and position=default&knob-Primary metric position_Text configuration and position=top&knob-Progress bar direction=vertical&knob-Progress max=100&knob-Secondary metric trend icon side_Secondary metric=right&knob-Secondary metric trend icon_Secondary metric=↑&knob-Secondary metric value color_Secondary metric=rgb(93, 191, 149)&knob-Secondary metric value position_Secondary metric=after&knob-Secondary metric value_Secondary metric=87.20&knob-Show extra_Secondary metric=true&knob-Show metric icon_Text configuration and position=&knob-Subtitle=Little description of this component&knob-Title=Count of records&knob-Title and subtitle alignment_Text configuration and position=left&knob-Title weight_Text configuration and position=normal&knob-Trend a11y description=The trend shows a peak of CPU usage in the last 5 minutes&knob-Trend a11y title=The Cluster CPU Usage trend&knob-Trend data points=30&knob-Trend shape=area&knob-Value=55.23&knob-Visualization type=bar&knob-Value prefix=&knob-Value postfix= %&knob-Use custom extra_Secondary metric=&knob-Label_Secondary metric=&knob-Use value color_Colors=&knob-Value color_Colors=#065B58&knob-Use blending background_Colors=&knob-Show value icon=`,
{
action: async () => await common.setResizeDimensions(page)({ height: 180, width: 180 }),
},
);
});
});

pwEach.describe(['trend', 'bar', 'none'])(
(v) => `Metric - ${v} type`,
(type) => {
Expand Down
47 changes: 42 additions & 5 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ export type MetricBase = {
extra?: ReactElement | ComponentType<{
fontSize: number;
color: string;
}>;
}> | SecondaryMetricProps;
icon?: ComponentType<{
width: number;
height: number;
Expand All @@ -2086,6 +2086,11 @@ export type MetricElementEvent = {
columnIndex: number;
};

// Warning: (ae-forgotten-export) The symbol "FontWeight" needs to be exported by the entry point index.d.ts
//
// @public
export type MetricFontWeight = Extract<FontWeight, 'bold' | 'normal'>;

// @alpha (undocumented)
export interface MetricSpec extends Spec {
// (undocumented)
Expand All @@ -2099,7 +2104,7 @@ export interface MetricSpec extends Spec {
// @alpha @deprecated (undocumented)
export type MetricSpecProps = ComponentProps<typeof Metric>;

// @public (undocumented)
// @public
export interface MetricStyle {
// (undocumented)
barBackground: Color;
Expand All @@ -2109,7 +2114,9 @@ export interface MetricStyle {
// (undocumented)
emptyBackground: Color;
// (undocumented)
iconAlign: 'left' | 'right';
extraTextAlign: MetricTextAlign;
Comment thread
markov00 marked this conversation as resolved.
Outdated
// (undocumented)
iconAlign: Extract<HorizontalAlignment, 'left' | 'right'>;
// (undocumented)
minHeight: Pixels;
// (undocumented)
Expand All @@ -2119,15 +2126,32 @@ export interface MetricStyle {
// (undocumented)
textDarkColor: Color;
// (undocumented)
textExtraDarkColor: Color;
// (undocumented)
textExtraLightColor: Color;
// (undocumented)
textLightColor: Color;
// (undocumented)
titlesTextAlign: 'left' | 'center' | 'right';
textSubtitleDarkColor: Color;
// (undocumented)
textSubtitleLightColor: Color;
// (undocumented)
titlesTextAlign: MetricTextAlign;
// (undocumented)
titleWeight: MetricFontWeight;
// (undocumented)
valueFontSize: 'default' | 'fit' | number;
// (undocumented)
valuesTextAlign: 'left' | 'center' | 'right';
valuePosition: 'top' | 'bottom';
// (undocumented)
valueTextAlign: MetricTextAlign;
Comment thread
markov00 marked this conversation as resolved.
Outdated
}

// Warning: (ae-forgotten-export) The symbol "TextAlign" needs to be exported by the entry point index.d.ts
//
// @public
export type MetricTextAlign = Extract<TextAlign, 'left' | 'center' | 'right'>;

// @alpha (undocumented)
export const MetricTrendShape: Readonly<{
Bars: "bars";
Expand Down Expand Up @@ -2671,6 +2695,19 @@ export const ScaleType: Readonly<{
// @public
export type ScaleType = $Values<typeof ScaleType>;

// @alpha
export interface SecondaryMetricProps {
ariaDescription?: string;
badgeBorderColor?: Color;
badgeColor?: Color;
icon?: string;
iconSide?: 'left' | 'right';
Comment thread
markov00 marked this conversation as resolved.
Outdated
label?: string;
style?: CSSProperties;
value: string;
valuePosition?: 'before' | 'after';
}

// @public (undocumented)
export interface SectorGeomSpecY {
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { Dispatch } from 'redux';
import { bindActionCreators } from 'redux';

import { renderBullet } from './bullet';
import type { ColorContrastOptions } from '../../../../common/color_calcs';
import type { ColorContrastOptions, TextContrastOptions } from '../../../../common/color_calcs';
import { colorToRgba } from '../../../../common/color_library_wrappers';
import type { Color } from '../../../../common/colors';
import { Colors } from '../../../../common/colors';
Expand Down Expand Up @@ -144,6 +144,12 @@ class Component extends React.Component<Props> {
darkColor: colorToRgba(metricStyle.textDarkColor),
};

const textContrastOptions: TextContrastOptions = {
text: contrastOptions,
subtitle: contrastOptions,
extra: contrastOptions,
};

if (!initialized || size.width === 0 || size.height === 0 || !spec) {
return null;
}
Expand Down Expand Up @@ -227,7 +233,7 @@ class Component extends React.Component<Props> {
rowIndex={stats.rowIndex}
style={bulletToMetricStyle}
backgroundColor={backgroundColor}
contrastOptions={contrastOptions}
textContrastOptions={textContrastOptions}
textDimensions={textDimensions}
/>
);
Expand Down
Loading